Skip to content

Commit 4a6e73f

Browse files
pull test suite step out into own job
1 parent 245f941 commit 4a6e73f

9 files changed

Lines changed: 152 additions & 67 deletions

.github/workflows/backend-api-post-merge.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,26 @@ permissions:
1717
id-token: write
1818

1919
jobs:
20+
run-test-suite:
21+
name: Run test suite
22+
uses:
23+
govuk-one-login/mobile-id-check-async/.github/workflows/job_test-suite.yml@DCMAW-11654
24+
with:
25+
WORKING_DIRECTORY: backend-api
26+
2027
sonarqube-scan:
2128
name: SonarQube Scan
29+
needs: run-test-suite
2230
uses:
2331
govuk-one-login/mobile-id-check-async/.github/workflows/job_sonarqube.yml@DCMAW-11654
2432
with:
25-
WORKING_DIRECTORY: ${{ inputs.WORKING_DIRECTORY }}
33+
DOWNLOAD_TEST_COVERAGE: true
34+
WORKING_DIRECTORY: backend-api
2635
secrets: inherit
2736

2837
dev-post-merge:
29-
name: Dev Post Merge
30-
needs: sonarqube-scan
38+
name: Build and push image, build and upload artifact to S3 for dev
39+
needs: run-test-suite
3140
uses:
3241
govuk-one-login/mobile-id-check-async/.github/workflows/workflow_post-merge.yml@DCMAW-11654
3342
with:
@@ -40,7 +49,7 @@ jobs:
4049
TEST_IMAGE_REPOSITORY_URI: ${{ secrets.BACKEND_API_DEV_TEST_IMAGE_REPOSITORY }}
4150

4251
build-post-merge:
43-
name: Build Post Merge
52+
name: Build and push image, build and upload artifact to S3 for build
4453
needs: dev-post-merge
4554
uses:
4655
govuk-one-login/mobile-id-check-async/.github/workflows/workflow_post-merge.yml@DCMAW-11654

.github/workflows/backend-api-pull-request.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,22 @@ jobs:
2626
GENERATE_PROXY_OPEN_API_SPEC: true
2727
WORKING_DIRECTORY: backend-api
2828
secrets: inherit
29+
30+
run-test-suite:
31+
name: Run test suite
32+
if: github.event.pull_request.draft == false
33+
uses:
34+
govuk-one-login/mobile-id-check-async/.github/workflows/job_test-suite.yml@DCMAW-11654
35+
with:
36+
WORKING_DIRECTORY: backend-api
2937

3038
sonarqube:
3139
name: SonarQube
32-
needs: ci-checks
40+
needs: run-test-suite
3341
uses:
3442
govuk-one-login/mobile-id-check-async/.github/workflows/job_sonarqube.yml@DCMAW-11654
3543
with:
44+
DOWNLOAD_TEST_COVERAGE: true
3645
RUN_SONARQUBE_QUALITY_GATE_CHECK: true
3746
WORKING_DIRECTORY: backend-api
3847
secrets: inherit

.github/workflows/job_build-and-push-test-image.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ jobs:
4848
aws-region: eu-west-2
4949
role-to-assume: ${{ secrets.GH_ACTIONS_ROLE_ARN }}
5050

51-
- name: Run custom tests
52-
run: npm run test
53-
5451
- name: Login to AWS ECR
5552
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 #v2.0.1
5653

.github/workflows/job_ci-checks.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ jobs:
6060
- name: Check formatting
6161
run: npm run format:check
6262

63-
- name: Run custom tests
64-
run: npm run test
65-
# output the file the unit tests generates for use in sonar quality gate
66-
6763
# - name: Generate proxy open api spec
6864
# if: ${{ inputs.GENERATE_PROXY_OPEN_API_SPEC }}
6965
# run: npm run generate-proxy-open-api

.github/workflows/job_sonarqube.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: SonarQube Scan
33
on:
44
workflow_call:
55
inputs:
6+
DOWNLOAD_TEST_COVERAGE:
7+
description: Set to true if test coverage artifact has been uploaded. If false, test suite will run
8+
required: false
9+
type: boolean
10+
default: false
611
RUN_SONARQUBE_QUALITY_GATE_CHECK:
712
description: Whether to run SonarQube Quality Gate check
813
required: false
@@ -38,7 +43,15 @@ jobs:
3843
- name: Install dependencies
3944
run: npm clean-install
4045

46+
- name: Download coverage artifact
47+
if: ${{ inputs.DOWNLOAD_TEST_COVERAGE }} == true
48+
uses: actions/download-artifact@v3
49+
with:
50+
name: test-coverage
51+
path: coverage/
52+
4153
- name: Generate test coverage report for SonarQube Quality Gate Check
54+
if: ${{ inputs.DOWNLOAD_TEST_COVERAGE }} == false
4255
run: npm run test:unit
4356

4457
- name: Run SonarQube Scan
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Run Test Suite
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
WORKING_DIRECTORY:
7+
description: Working directory
8+
required: true
9+
type: string
10+
11+
jobs:
12+
run-test-suite:
13+
name: Run test suite and upload coverage artifact
14+
runs-on: ubuntu-24.04
15+
defaults:
16+
run:
17+
shell: bash
18+
working-directory: ${{ inputs.WORKING_DIRECTORY }}
19+
steps:
20+
- name: Check out repository code
21+
uses: actions/checkout@9a9194f87191a7e9055e3e9b95b8cfb13023bb08 #main
22+
with:
23+
fetch-depth: 0
24+
submodules: true
25+
26+
- name: Setup nodeJS v20
27+
uses: actions/setup-node@26961cf329f22f6837d5f54c3efd76b480300ace #main
28+
with:
29+
cache: npm
30+
cache-dependency-path: ${{ inputs.WORKING_DIRECTORY }}/package-lock.json
31+
node-version: 20
32+
33+
- name: Install dependencies
34+
run: npm clean-install
35+
36+
- name: Run all tests
37+
run: npm run test
38+
39+
- name: Upload coverage artifact
40+
uses: actions/upload-artifact@v3
41+
with:
42+
name: test-coverage
43+
path: coverage/

.github/workflows/test-resources-post-merge.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/test-resources-pull-request.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,21 @@ jobs:
2626
WORKING_DIRECTORY: test-resources
2727
secrets: inherit
2828

29+
run-test-suite:
30+
name: Run test suite
31+
if: github.event.pull_request.draft == false
32+
uses:
33+
govuk-one-login/mobile-id-check-async/.github/workflows/job_test-suite.yml@DCMAW-11654
34+
with:
35+
WORKING_DIRECTORY: test-resources
36+
2937
sonarqube:
3038
name: SonarQube
31-
needs: ci-checks
39+
needs: run-test-suite
3240
uses:
3341
govuk-one-login/mobile-id-check-async/.github/workflows/job_sonarqube.yml@DCMAW-11654
3442
with:
43+
DOWNLOAD_TEST_COVERAGE: true
3544
RUN_SONARQUBE_QUALITY_GATE_CHECK: true
3645
WORKING_DIRECTORY: test-resources
3746
secrets: inherit
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: test-resources post merge
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "test-resources/**"
9+
- ".github/workflows/test-resources-post-merge.yml"
10+
- "!test-resources/**/*.md"
11+
- "!test-resources/**/*.png"
12+
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: read
17+
id-token: write
18+
19+
jobs:
20+
# run-test-suite:
21+
# name: Run test suite
22+
# uses:
23+
# govuk-one-login/mobile-id-check-async/.github/workflows/job_test-suite.yml@DCMAW-11654
24+
# with:
25+
# WORKING_DIRECTORY: test-resources
26+
27+
# sonarqube-scan:
28+
# name: SonarQube Scan
29+
# needs: run-test-suite
30+
# uses:
31+
# govuk-one-login/mobile-id-check-async/.github/workflows/job_sonarqube.yml@DCMAW-11654
32+
# with:
33+
# DOWNLOAD_TEST_COVERAGE: true
34+
# WORKING_DIRECTORY: test-resources
35+
# secrets: inherit
36+
37+
dev-post-merge:
38+
name: Build and push image, build and upload artifact to S3 for dev
39+
needs: run-test-suite
40+
uses:
41+
govuk-one-login/mobile-id-check-async/.github/workflows/workflow_post-merge.yml@DCMAW-11654
42+
with:
43+
WORKING_DIRECTORY: test-resources
44+
secrets:
45+
ARTIFACT_BUCKET_NAME: ${{ secrets.TEST_RESOURCES_DEV_ARTIFACT_BUCKET }}
46+
CONTAINER_SIGN_KMS_KEY: ${{ secrets.DEV_CONTAINER_SIGN_KMS_KEY }}
47+
GH_ACTIONS_ROLE_ARN: ${{ secrets.TEST_RESOURCES_DEV_GH_ACTIONS_ROLE_ARN }}
48+
SIGNING_PROFILE_NAME: ${{ secrets.DEV_SIGNING_PROFILE_NAME }}
49+
TEST_IMAGE_REPOSITORY_URI: ${{ secrets.TEST_RESOURCES_DEV_TEST_IMAGE_REPOSITORY_URI }}
50+
51+
# build-post-merge:
52+
# name: Build and push image, build and upload artifact to S3 for build
53+
# needs: dev-post-merge
54+
# uses:
55+
# govuk-one-login/mobile-id-check-async/.github/workflows/workflow_post-merge.yml@DCMAW-11654
56+
# with:
57+
# WORKING_DIRECTORY: test-resources
58+
# secrets:
59+
# ARTIFACT_BUCKET_NAME: ${{ secrets.TEST_RESOURCES_BUILD_ARTIFACT_BUCKET }}
60+
# CONTAINER_SIGN_KMS_KEY: ${{ secrets.BUILD_CONTAINER_SIGN_KMS_KEY }}
61+
# GH_ACTIONS_ROLE_ARN: ${{ secrets.BACKEND_API_BUILD_GH_ACTIONS_ROLE_ARN }}
62+
# SIGNING_PROFILE_NAME: ${{ secrets.BUILD_SIGNING_PROFILE_NAME }}
63+
# TEST_IMAGE_REPOSITORY_URI: ${{ secrets.BACKEND_API_BUILD_TEST_IMAGE_REPOSITORY }}

0 commit comments

Comments
 (0)