Skip to content

Commit a9466a3

Browse files
add workflows for pr and post merge
1 parent da07494 commit a9466a3

12 files changed

Lines changed: 226 additions & 214 deletions

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

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,20 @@ 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-
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: backend-api
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: backend-api
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.BACKEND_API_DEV_GH_ACTIONS_ROLE_ARN }}
48-
SIGNING_PROFILE_NAME: ${{ secrets.DEV_SIGNING_PROFILE_NAME }}
49-
TEST_IMAGE_REPOSITORY_URI: ${{ secrets.BACKEND_API_DEV_TEST_IMAGE_REPOSITORY }}
50-
51-
build-post-merge:
52-
name: Build and push image, build and upload artifact to S3 for build
53-
needs: dev-post-merge
20+
post-merge:
21+
name: Run tests, build and push image, build and upload artifact to S3 for dev and build
5422
uses:
5523
govuk-one-login/mobile-id-check-async/.github/workflows/workflow_post-merge.yml@DCMAW-11654
5624
with:
5725
WORKING_DIRECTORY: backend-api
5826
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 }}
27+
DEV_ARTIFACT_BUCKET_NAME: ${{ secrets.BACKEND_API_DEV_ARTIFACT_BUCKET }}
28+
DEV_CONTAINER_SIGN_KMS_KEY: ${{ secrets.DEV_CONTAINER_SIGN_KMS_KEY }}
29+
DEV_GH_ACTIONS_ROLE_ARN: ${{ secrets.BACKEND_API_DEV_GH_ACTIONS_ROLE_ARN }}
30+
DEV_SIGNING_PROFILE_NAME: ${{ secrets.DEV_SIGNING_PROFILE_NAME }}
31+
DEV_TEST_IMAGE_REPOSITORY_URI: ${{ secrets.BACKEND_API_DEV_TEST_IMAGE_REPOSITORY }}
32+
BUILD_ARTIFACT_BUCKET_NAME: ${{ secrets.BACKEND_API_BUILD_ARTIFACT_BUCKET }}
33+
BUILD_CONTAINER_SIGN_KMS_KEY: ${{ secrets.BUILD_CONTAINER_SIGN_KMS_KEY }}
34+
BUILD_GH_ACTIONS_ROLE_ARN: ${{ secrets.BACKEND_API_BUILD_GH_ACTIONS_ROLE_ARN }}
35+
BUILD_SIGNING_PROFILE_NAME: ${{ secrets.BUILD_SIGNING_PROFILE_NAME }}
36+
BUILD_TEST_IMAGE_REPOSITORY_URI: ${{ secrets.BACKEND_API_BUILD_TEST_IMAGE_REPOSITORY }}

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

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,12 @@ on:
1717
workflow_dispatch:
1818

1919
jobs:
20-
ci-checks:
21-
name: CI Checks
20+
pull-request:
21+
name: Run linters, test suite, and sonarQube
2222
if: github.event.pull_request.draft == false
2323
uses:
24-
govuk-one-login/mobile-id-check-async/.github/workflows/job_ci-checks.yml@DCMAW-11654
24+
govuk-one-login/mobile-id-check-async/.github/workflows/workflow_pull-request.yml@DCMAW-11654
2525
with:
26-
GENERATE_PROXY_OPEN_API_SPEC: true
27-
WORKING_DIRECTORY: backend-api
28-
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
37-
38-
sonarqube:
39-
name: SonarQube
40-
needs: run-test-suite
41-
uses:
42-
govuk-one-login/mobile-id-check-async/.github/workflows/job_sonarqube.yml@DCMAW-11654
43-
with:
44-
DOWNLOAD_TEST_COVERAGE: true
45-
RUN_SONARQUBE_QUALITY_GATE_CHECK: true
26+
RUN_SONARQUBE_SCAN: true
4627
WORKING_DIRECTORY: backend-api
4728
secrets: inherit

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ jobs:
6161
6262
- name: Sign image
6363
run: |
64-
cosign sign --key awskms:///$CONTAINER_SIGN_KMS_KEY TEST_IMAGE_REPOSITORY_URI:$IMAGE_TAG
64+
cosign sign --key awskms:///$CONTAINER_SIGN_KMS_KEY $TEST_IMAGE_REPOSITORY_URI:$IMAGE_TAG

.github/workflows/job_build-and-upload-sam-app.yml

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

51-
# - name: Cache SAM builds
52-
# uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # pin@v4
53-
# with:
54-
# path: |
55-
# ./backend-api/.aws-sam/cache
56-
# ./backend-api/.aws-sam/deps
57-
# ./backend-api/.aws-sam/build.toml
58-
# key: sam-${{ inputs.WORKING_DIRECTORY }}
59-
6051
- name: Sam validate
6152
run: |
6253
echo "SAM_CLI_TELEMETRY=0" >> $GITHUB_ENV
6354
sam validate --lint --template $TEMPLATE_NAME
6455
65-
- name: Build SAM artifact from template file
56+
- name: Get cache key
57+
id: get-cache-key
58+
run: |
59+
echo "cache-key=sam-$WORKING_DIRECTORY-${{ hashFiles('**/template.yaml') }}" >> "$GITHUB_OUTPUT"
60+
echo "restore-keys=sam-$WORKING_DIRECTORY-" >> "$GITHUB_OUTPUT"
61+
62+
- name: Cache SAM dependencies
63+
uses: actions/cache@v4
64+
with:
65+
key: ${{ steps.get-cache-key.outputs.cache-key }}
66+
restore-keys: ${{ steps.get-cache-key.outputs.restore-keys }}
67+
path: .aws-sam
68+
69+
- name: Build SAM artifact from template
6670
run: |
67-
sam build --template $TEMPLATE_NAME
71+
sam build --cached --template $TEMPLATE_NAME
6872
6973
- name: Upload SAM artifact into the S3 artifact bucket
7074
uses: govuk-one-login/devplatform-upload-action@a3ea2d79b7ee95bc6ecea69aea6ec75f19faee41 #v3.9.3

.github/workflows/job_ci-checks.yml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@ name: CI Checks
33
on:
44
workflow_call:
55
inputs:
6-
GENERATE_PROXY_OPEN_API_SPEC:
7-
description: Whether to run script to generate proxy openAPI spec
8-
required: false
9-
type: boolean
10-
default: false
11-
RUN_LINTER:
12-
description: Whether to run a linter
13-
required: false
14-
type: boolean
15-
default: true
166
TEMPLATE_NAME:
177
description: CloudFormation template name
188
required: false
@@ -54,20 +44,18 @@ jobs:
5444
run: npm clean-install
5545

5646
- name: Linting
57-
if: ${{ inputs.RUN_LINTER }}
5847
run: npm run lint
5948

60-
- name: Check formatting
61-
run: npm run format:check
62-
63-
# - name: Generate proxy open api spec
64-
# if: ${{ inputs.GENERATE_PROXY_OPEN_API_SPEC }}
65-
# run: npm run generate-proxy-open-api
66-
6749
- name: Set up Homebrew
6850
if: ${{ inputs.VERIFY_TEMPLATE_RAIN }}
6951
id: set-up-homebrew
70-
uses: Homebrew/actions/setup-homebrew@a7a36215df86859f163fbb774ebe0cecf9ec8547
52+
run: |
53+
# The suggested command doesn't persist across steps: eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
54+
# The following commands mimics the output from the suggested command. It may break for future runners.
55+
echo "HOMEBREW_CELLAR=/home/linuxbrew/.linuxbrew/Cellar" >> $GITHUB_ENV
56+
echo "HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew/Homebrew" >> $GITHUB_ENV
57+
echo "/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
58+
echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH
7159
7260
- name: Install rain
7361
if: ${{ inputs.VERIFY_TEMPLATE_RAIN }}

.github/workflows/job_sonarqube.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ jobs:
4444
run: npm clean-install
4545

4646
- name: Download coverage artifact
47-
if: ${{ inputs.DOWNLOAD_TEST_COVERAGE }} == true
47+
if: ${{ inputs.DOWNLOAD_TEST_COVERAGE }}
4848
uses: actions/download-artifact@v3
4949
with:
5050
name: test-coverage
5151
path: coverage/
5252

5353
- name: Generate test coverage report for SonarQube Quality Gate Check
54-
if: ${{ inputs.DOWNLOAD_TEST_COVERAGE }} == false
54+
if: ${{ ! inputs.DOWNLOAD_TEST_COVERAGE }}
5555
run: npm run test:unit
5656

5757
- name: Run SonarQube Scan

.github/workflows/job_test-suite.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: Run Test Suite
33
on:
44
workflow_call:
55
inputs:
6+
RUN_SONARQUBE_SCAN:
7+
description: Whether to run sonarQube scans
8+
required: false
9+
type: boolean
10+
default: false
611
WORKING_DIRECTORY:
712
description: Working directory
813
required: true
@@ -36,7 +41,8 @@ jobs:
3641
- name: Run all tests
3742
run: npm run test
3843

39-
- name: Upload coverage artifact
44+
- name: Upload coverage artifact, if running SonarQube scan
45+
if: ${{ inputs.RUN_SONARQUBE_SCAN }}
4046
uses: actions/upload-artifact@v3
4147
with:
4248
name: test-coverage
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
post-merge:
21+
name: Run tests, build and push image, build and upload artifact to S3 for dev and build
22+
uses:
23+
govuk-one-login/mobile-id-check-async/.github/workflows/workflow_post-merge.yml@DCMAW-11654
24+
with:
25+
WORKING_DIRECTORY: test-resources
26+
secrets:
27+
DEV_ARTIFACT_BUCKET_NAME: ${{ secrets.TEST_RESOURCES_DEV_ARTIFACT_BUCKET }}
28+
DEV_CONTAINER_SIGN_KMS_KEY: ${{ secrets.DEV_CONTAINER_SIGN_KMS_KEY }}
29+
DEV_GH_ACTIONS_ROLE_ARN: ${{ secrets.TEST_RESOURCES_DEV_GH_ACTIONS_ROLE_ARN }}
30+
DEV_SIGNING_PROFILE_NAME: ${{ secrets.DEV_SIGNING_PROFILE_NAME }}
31+
DEV_TEST_IMAGE_REPOSITORY_URI: ${{ secrets.TEST_RESOURCES_DEV_TEST_IMAGE_REPOSITORY_URI }}
32+
BUILD_ARTIFACT_BUCKET_NAME: ${{ secrets.TEST_RESOURCES_BUILD_ARTIFACT_BUCKET }}
33+
BUILD_CONTAINER_SIGN_KMS_KEY: ${{ secrets.BUILD_CONTAINER_SIGN_KMS_KEY }}
34+
BUILD_GH_ACTIONS_ROLE_ARN: ${{ secrets.TEST_RESOURCES_BUILD_GH_ACTIONS_ROLE_ARN }}
35+
BUILD_SIGNING_PROFILE_NAME: ${{ secrets.BUILD_SIGNING_PROFILE_NAME }}
36+
BUILD_TEST_IMAGE_REPOSITORY_URI: ${{ secrets.TEST_RESOURCES_BUILD_TEST_IMAGE_REPOSITORY_URI }}

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

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,20 @@ on:
99
- ready_for_review
1010
- synchronize
1111
paths:
12-
- "test-resources/**"
1312
- ".github/workflows/test-resources-pull-request.yml"
13+
- "test-resources/**"
1414
- "!test-resources/**/*.md"
1515
- "!test-resources/**/*.png"
1616

1717
workflow_dispatch:
1818

1919
jobs:
20-
ci-checks:
21-
name: CI Checks
20+
pull-request:
21+
name: Run linters, test suite, and sonarQube
2222
if: github.event.pull_request.draft == false
2323
uses:
24-
govuk-one-login/mobile-id-check-async/.github/workflows/job_ci-checks.yml@DCMAW-11654
24+
govuk-one-login/mobile-id-check-async/.github/workflows/workflow_pull-request.yml@DCMAW-11654
2525
with:
26+
RUN_SONARQUBE_SCAN: true
2627
WORKING_DIRECTORY: test-resources
2728
secrets: inherit
28-
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-
37-
sonarqube:
38-
name: SonarQube
39-
needs: run-test-suite
40-
uses:
41-
govuk-one-login/mobile-id-check-async/.github/workflows/job_sonarqube.yml@DCMAW-11654
42-
with:
43-
DOWNLOAD_TEST_COVERAGE: true
44-
RUN_SONARQUBE_QUALITY_GATE_CHECK: true
45-
WORKING_DIRECTORY: test-resources
46-
secrets: inherit

.github/workflows/test-resources-push-to-main.yml

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

0 commit comments

Comments
 (0)