forked from CMSgov/beneficiary-fhir-data
-
Notifications
You must be signed in to change notification settings - Fork 1
143 lines (134 loc) · 4.42 KB
/
ci-java.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: 'CI - Java'
on: pull_request
env:
# workflow file matchers - workflow jobs will only run if matching files are found
# please see https://github.com/CMSgov/beneficiary-fhir-data/pull/773 for why we
# are using this workflow logic
workflow_files_re: >
(^apps/bfd- |
^apps/Dockerfile |
^apps/pom.xml |
^ops/ansible |
^.github/workflows/ci-ansible.yml |
^.github/workflows/ci-java.yml)
jobs:
workflow:
name: Checking workflow
runs-on: ubuntu-latest
outputs:
files: ${{ steps.workflow_files.outputs.files }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- id: workflow_files
run: |
echo "::set-output name=files::$(git diff --name-only --diff-filter=ACMRTD HEAD^ HEAD | grep -E '${{ env.workflow_files_re }}')"
mvn-fmt-maven-plugin:
runs-on: ubuntu-latest
needs: workflow
if: needs.workflow.outputs.files
steps:
- uses: actions/checkout@v2
- name: 'Setup JDK'
uses: actions/setup-java@v1
with:
java-version: '11'
- name: 'Generate maven toolchain config'
run: |
cat << EOF > ~/.m2/toolchains.xml
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
<vendor>OpenJDK</vendor>
</provides>
<configuration>
<jdkHome>$JAVA_HOME</jdkHome>
</configuration>
</toolchain>
</toolchains>
EOF
- name: 'Run maven ${{ matrix.mvn_commmand }}'
run: mvn com.coveo:fmt-maven-plugin:check
working-directory: ./apps
mvn-verify:
runs-on: ubuntu-latest
needs: workflow
if: needs.workflow.outputs.files
steps:
- name: 'Configure AWS credentials'
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.GA_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.GA_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: 'Checkout repo'
uses: actions/checkout@v2
- name: 'Setup JDK'
uses: actions/setup-java@v1
with:
java-version: '11'
- name: 'Generate Maven Config'
run: |
cat << EOF > ~/.m2/toolchains.xml
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
<vendor>OpenJDK</vendor>
</provides>
<configuration>
<jdkHome>$JAVA_HOME</jdkHome>
</configuration>
</toolchain>
</toolchains>
EOF
- name: 'Run Maven Build'
run: mvn --batch-mode --threads 1C verify
working-directory: ./apps
- name: Login to GitHub Container Registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" \
| docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and Deliver Apps Container Image
run: |
SANITIZED_REF="${GITHUB_REF_NAME////-}"
IMAGE_NAME="ghcr.io/cmsgov/bfd-apps"
SHORT_SHA="$(git rev-parse --short HEAD)"
FULL_BRANCH_TAG="${IMAGE_NAME}:${SANITIZED_REF}" # human readable, branch name tag
FULL_COMMIT_TAG="${IMAGE_NAME}:${SHORT_SHA}" # a short sha suffixed image tag
docker build . --tag "$FULL_BRANCH_TAG"
docker tag "$FULL_BRANCH_TAG" "$FULL_COMMIT_TAG"
docker push "$FULL_BRANCH_TAG"
docker push "$FULL_COMMIT_TAG"
working-directory: apps
- name: 'Upload test artifacts'
uses: actions/upload-artifact@v2
if: always()
with:
name: mvn-verify-build-logs
path: |
**/target/surefire-reports/*
**/target/failsafe-reports/*
bfd-server/bfd-server-war/target/server-work/access.*
bfd-server/bfd-server-war/target/server-work/server-console.log
# ansible system testing
ansible-role-bfd-pipeline:
needs: mvn-verify
uses: ./.github/workflows/ci-ansible.yml
with:
role: bfd-pipeline
ansible-role-bfd-server:
needs: mvn-verify
uses: ./.github/workflows/ci-ansible.yml
with:
role: bfd-server
ansible-role-bfd-db-migrator:
needs: mvn-verify
uses: ./.github/workflows/ci-ansible.yml
with:
role: bfd-db-migrator