Skip to content

Commit 6da9d1e

Browse files
committed
Merge branch 'main' into upgrade-amazon-sdk
2 parents 31c6457 + 875bff6 commit 6da9d1e

File tree

159 files changed

+8904
-1908
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+8904
-1908
lines changed
Lines changed: 359 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,359 @@
1+
name: GP2GP Build Workflow
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
checkstyle:
13+
name: Checkstyle
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Java 21 LTS
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: 21
23+
distribution: 'temurin'
24+
25+
- name: Setup Gradle
26+
uses: gradle/actions/setup-gradle@v4
27+
28+
- name: Checkstyle
29+
run: |
30+
./gradlew checkStyleMain --parallel
31+
./gradlew checkstyleTest --parallel
32+
working-directory: ./service
33+
34+
- name: Collect Artifacts
35+
if: always()
36+
run: |
37+
mkdir -p artifacts
38+
cp -r ./service/build/reports ./artifacts
39+
40+
- name: Upload Artifacts
41+
uses: actions/upload-artifact@v4
42+
if: always()
43+
with:
44+
name: 'Checkstyle Reports'
45+
path: ./artifacts/**
46+
compression-level: 9
47+
48+
- name: Temporary Artifacts Cleanup
49+
run: rm -rf ./artifacts
50+
51+
spotbugs:
52+
name: Spotbugs
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Checkout Repository
56+
uses: actions/checkout@v4
57+
58+
- name: Setup Java 21 LTS
59+
uses: actions/setup-java@v4
60+
with:
61+
java-version: 21
62+
distribution: 'temurin'
63+
64+
- name: Setup Gradle
65+
uses: gradle/actions/setup-gradle@v4
66+
67+
- name: Spotbugs
68+
run: |
69+
./gradlew spotbugsMain --parallel
70+
./gradlew spotbugsTest --parallel
71+
working-directory: ./service
72+
73+
- name: Collect Artifacts
74+
if: always()
75+
run: |
76+
mkdir -p artifacts
77+
cp -r ./service/build/reports ./artifacts
78+
79+
- name: Upload Artifacts
80+
uses: actions/upload-artifact@v4
81+
if: always()
82+
with:
83+
name: 'Spotbugs Reports'
84+
path: ./artifacts/**
85+
compression-level: 9
86+
87+
- name: Temporary Artifacts Cleanup
88+
run: rm -rf ./artifacts
89+
90+
unit-tests:
91+
name: Unit Tests
92+
runs-on: ubuntu-latest
93+
needs: [checkstyle, spotbugs]
94+
steps:
95+
- name: Checkout Repository
96+
uses: actions/checkout@v4
97+
with:
98+
# Disabling shallow clone is recommended for improving relevancy of Sonar reporting
99+
fetch-depth: 0
100+
- name: Setup Java 21 LTS
101+
uses: actions/setup-java@v4
102+
with:
103+
java-version: 21
104+
distribution: 'temurin'
105+
106+
- name: Setup Gradle
107+
uses: gradle/actions/setup-gradle@v4
108+
109+
- name: Execute Unit Tests
110+
run: |
111+
if [[ $GITHUB_ACTOR == 'dependabot[bot]' ]]; then
112+
./gradlew test jacocoTestReport --parallel --build-cache
113+
else
114+
./gradlew test jacocoTestReport sonar --parallel --build-cache
115+
fi
116+
working-directory: ./service
117+
env:
118+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
119+
120+
- name: Collect Artifacts
121+
if: always()
122+
run: |
123+
mkdir -p artifacts
124+
cp -r ./service/build/reports ./artifacts
125+
126+
- name: Upload Artifacts
127+
uses: actions/upload-artifact@v4
128+
if: always()
129+
with:
130+
name: 'Unit Test Reports'
131+
path: ./artifacts/**
132+
compression-level: 9
133+
134+
- name: Temporary Artifacts Cleanup
135+
run: rm -rf ./artifacts
136+
137+
integration-tests:
138+
name: Integration Tests
139+
runs-on: ubuntu-latest
140+
needs: [checkstyle, spotbugs]
141+
steps:
142+
- name: Checkout Repository
143+
uses: actions/checkout@v4
144+
145+
- name: Setup Java 21 LTS
146+
uses: actions/setup-java@v4
147+
with:
148+
java-version: 21
149+
distribution: 'temurin'
150+
151+
- name: Setup Gradle
152+
uses: gradle/actions/setup-gradle@v4
153+
154+
- name: Start Docker Dependencies
155+
env:
156+
GPC_SUPPLIER_ODS_CODE: "XYZ222"
157+
GP2GP_SERVER_PORT: "8080"
158+
GP2GP_AMQP_BROKERS: "amqp://activemq:5672"
159+
GP2GP_MONGO_URI: "mongodb://mongodb:27017"
160+
GP2GP_MONGO_DATABASE_NAME: "gp2gp"
161+
GP2GP_MHS_OUTBOUND_URL: "http://mock-mhs-adaptor:8081/mock-mhs-endpoint/accept-only"
162+
GP2GP_GPC_GET_URL: "http://gpcc:8090/@ODS_CODE@/STU3/1/gpconnect"
163+
GP2GP_LARGE_ATTACHMENT_THRESHOLD: "4500000"
164+
GP2GP_LARGE_EHR_EXTRACT_THRESHOLD: "4500000"
165+
GPC_CONSUMER_SERVER_PORT: "8090"
166+
GPC_CONSUMER_SDS_URL: "http://wiremock:8080/spine-directory/"
167+
GPC_CONSUMER_SDS_APIKEY: "anykey"
168+
GP2GP_LOGGING_LEVEL: DEBUG
169+
GPC_CONSUMER_LOGGING_LEVEL: DEBUG
170+
run: |
171+
docker network create commonforgp2gp
172+
docker compose build
173+
docker compose up mock-mhs-adaptor mongodb activemq wiremock gpcc gp2gp --detach
174+
working-directory: ./docker
175+
176+
- name: Execute Integration Tests
177+
run: ./gradlew integrationTest
178+
working-directory: ./service
179+
180+
- name: Dump Docker Logs
181+
if: always()
182+
run: |
183+
chmod +x dump_docker_logs.sh
184+
./dump_docker_logs.sh
185+
working-directory: ./scripts
186+
shell: bash
187+
188+
- name: Collect Artifacts
189+
if: always()
190+
run: |
191+
mkdir -p artifacts
192+
cp -r ./service/build/reports ./artifacts
193+
cp -r ./scripts/logs ./artifacts
194+
195+
- name: Upload Artifacts
196+
uses: actions/upload-artifact@v4
197+
if: always()
198+
with:
199+
name: 'Integration Test Reports & Docker Logs'
200+
path: ./artifacts/**
201+
compression-level: 9
202+
203+
- name: Stop Docker Dependencies
204+
if: always()
205+
run: |
206+
docker compose down --rmi=local --remove-orphans
207+
docker compose rm
208+
docker network rm commonforgp2gp
209+
working-directory: ./docker
210+
211+
- name: Temporary Artifacts Cleanup
212+
run: rm -rf ./artifacts
213+
214+
end-to-end-tests:
215+
name: End-to-End Testing
216+
runs-on: ubuntu-latest
217+
needs: [checkstyle, spotbugs]
218+
steps:
219+
- name: Checkout Repository
220+
uses: actions/checkout@v4
221+
222+
- name: Run E2E Tests
223+
env:
224+
GP2GP_SERVER_PORT: "8080"
225+
GP2GP_BASE_URL: "http://gp2gp:8080"
226+
GP2GP_AMQP_BROKERS: "amqp://activemq:5672"
227+
GP2GP_MONGO_URI: "mongodb://mongodb:27017"
228+
GP2GP_MONGO_DATABASE_NAME: "gp2gp"
229+
GP2GP_MHS_MOCK_BASE_URL: "http://mock-mhs-adaptor:8081"
230+
GP2GP_MHS_OUTBOUND_URL: "http://mock-mhs-adaptor:8081/mock-mhs-endpoint"
231+
GP2GP_GPC_GET_URL: "http://gpcc:8090/@ODS_CODE@/STU3/1/gpconnect"
232+
GP2GP_LARGE_ATTACHMENT_THRESHOLD: "31216"
233+
GP2GP_LARGE_EHR_EXTRACT_THRESHOLD: "31216"
234+
GP2GP_GPC_CLIENT_MAX_BACKOFF_ATTEMPTS: 0
235+
GP2GP_MHS_CLIENT_MAX_BACKOFF_ATTEMPTS: 0
236+
GPC_CONSUMER_SERVER_PORT: "8090"
237+
GPC_CONSUMER_SDS_URL: "http://wiremock:8080/spine-directory/"
238+
GPC_CONSUMER_SDS_APIKEY: "anykey"
239+
GPC_CONSUMER_LOGGING_LEVEL: "DEBUG"
240+
GPC_SUPPLIER_ODS_CODE: "XYZ222"
241+
GP2GP_LOGGING_LEVEL: "DEBUG"
242+
MHS_MOCK_REQUEST_JOURNAL_ENABLED: "true"
243+
run: |
244+
docker network create commonforgp2gp
245+
docker compose -f docker-compose.yml -f docker-compose-e2e-tests.yml up --build --exit-code-from gp2gp-e2e-tests mongodb activemq gp2gp wiremock gpcc gp2gp-e2e-tests
246+
working-directory: ./docker
247+
248+
- name: Dump Docker Logs
249+
if: always()
250+
run: |
251+
chmod +x dump_docker_logs.sh
252+
./dump_docker_logs.sh
253+
working-directory: ./scripts
254+
shell: bash
255+
256+
- name: Collect Artifacts
257+
if: always()
258+
run: |
259+
mkdir -p artifacts
260+
docker cp e2e-tests:/home/gradle/e2e-tests/build/reports ./artifacts
261+
cp -r ./scripts/logs ./artifacts
262+
263+
- name: Upload Artifacts
264+
uses: actions/upload-artifact@v4
265+
if: always()
266+
with:
267+
name: 'End-to-End Test Results & Docker Logs'
268+
path: ./artifacts/**
269+
compression-level: 9
270+
271+
- name: Stop Docker Dependencies
272+
if: always()
273+
run: |
274+
docker compose -f docker-compose.yml -f docker-compose-e2e-tests.yml down
275+
docker network rm commonforgp2gp
276+
working-directory: ./docker
277+
278+
- name: Temporary Artifacts Cleanup
279+
run: rm -rf ./artifacts
280+
281+
build-and-publish-docker-images:
282+
name: Build & Publish Docker Images
283+
runs-on: ubuntu-latest
284+
needs: [unit-tests, integration-tests, end-to-end-tests]
285+
permissions:
286+
id-token: write
287+
contents: read
288+
strategy:
289+
matrix:
290+
config:
291+
- directory: service
292+
repository: gp2gp
293+
build-context: .
294+
- directory: wiremock
295+
repository: gp2gp-wiremock
296+
build-context: .
297+
- directory: mock-mhs-adaptor
298+
repository: gp2gp-mock-mhs
299+
build-context: .
300+
- directory: gpcc-mock
301+
repository: gp2gp-gpcc-mock
302+
build-context: ./docker/gpcc-mock
303+
- directory: gpc-api-mock
304+
repository: gp2gp-gpc-api-mock
305+
build-context: ./docker/gpc-api-mock
306+
- directory: sds-api-mock
307+
repository: gp2gp-sds-api-mock
308+
build-context: ./docker/sds-api-mock
309+
310+
steps:
311+
- name: Checkout Repository
312+
uses: actions/checkout@v4
313+
314+
- name: Configure AWS Credentials
315+
uses: aws-actions/configure-aws-credentials@v4
316+
with:
317+
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ROLE_TO_ASSUME }}
318+
role-session-name: gp2gp_github_action_build_workflow
319+
aws-region: ${{ secrets.AWS_REGION }}
320+
321+
- name: Generate Build ID
322+
run: |
323+
chmod +x ./create_build_id.sh
324+
325+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
326+
GIT_BRANCH=PR
327+
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
328+
GIT_BRANCH=main
329+
fi
330+
331+
BUILD_ID=$(./create_build_id.sh $GIT_BRANCH ${{ github.run_number }} ${{ github.sha }})
332+
echo "Generated the build tag: $BUILD_ID"
333+
echo "BUILD_ID=$BUILD_ID" >> $GITHUB_ENV
334+
working-directory: ./scripts
335+
shell: bash
336+
337+
- name: Build Docker Image
338+
run: |
339+
# Create Docker Tag
340+
DOCKER_REGISTRY="${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com"
341+
DOCKER_TAG="$DOCKER_REGISTRY/${{ matrix.config.repository }}:$BUILD_ID"
342+
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
343+
344+
# Build Image
345+
docker build -f ./docker/${{ matrix.config.directory }}/Dockerfile -t $DOCKER_TAG ${{ matrix.config.build-context }}
346+
347+
- name: Login to AWS ECR
348+
run: |
349+
DOCKER_REGISTRY="https://${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com"
350+
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin $DOCKER_REGISTRY
351+
352+
- name: Publish image to ECR
353+
run: docker push $DOCKER_TAG
354+
355+
- name: Logout of AWS ECR (Clean up Credentials)
356+
if: always()
357+
run: |
358+
DOCKER_REGISTRY="https://${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com"
359+
docker logout $DOCKER_REGISTRY

.github/workflows/mutationtesting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
pitest:
77
# Only run on PRs from the repo. PRs from forks will fail due to lack of permissions and
88
# must use a two stage process
9-
if: github.event.pull_request.head.repo.full_name == github.repository
9+
if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]'
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout project

0 commit comments

Comments
 (0)