-
Notifications
You must be signed in to change notification settings - Fork 3
118 lines (107 loc) · 4.07 KB
/
job_test-suite.yml
File metadata and controls
118 lines (107 loc) · 4.07 KB
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
name: Run Test Suite
description: {
"name": "test-suite",
"version": "v1.0.0",
"message":
"This update adds versioning to the test-suite job."
}
on:
workflow_call:
inputs:
RUN_INFRA_TESTS:
description: Whether to run infra tests using `test:infra` npm script
type: string
default: true
RUN_SONARQUBE:
description: Whether to run SonarQube checks. Needs RUN_UNIT_TESTS to be true.
type: string
default: true
RUN_UNIT_TESTS:
description: Whether to run unit tests using `test:unit` npm script
type: string
default: true
SONARQUBE_CONTINUE_ON_ERROR:
description: Whether to continue running the workflow if SonarQube quality gate fails
type: string
default: false
WORKING_DIRECTORY:
description: Path to working directory in repo
required: true
type: string
PRIVATE_PACKAGES_REQUIRED:
description: Whether private packages must be installed
type: string
default: false
RUN_PACT_TESTS:
description: Whether to run pact tests using `test:pact:ci` npm script
type: string
default: false
secrets:
SONAR_TOKEN:
description: The token used for secure access to the SonarQube platform
required: false
jobs:
run-test-suite:
name: Run test suite and SonarQube
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
working-directory: ${{ inputs.WORKING_DIRECTORY }}
env:
CONTINUE_ON_ERROR: ${{ inputs.SONARQUBE_CONTINUE_ON_ERROR }}
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
submodules: true
- name: Setup NodeJS
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
cache: npm
cache-dependency-path: ${{ inputs.WORKING_DIRECTORY }}/package-lock.json
node-version-file: ${{ inputs.WORKING_DIRECTORY }}/.nvmrc
- name: Configure Authentication for Private Packages in .npmrc
if: inputs.GENERATE_OPEN_PROXY_API_SPEC == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "engine-strict=true" > .npmrc
echo "@govuk-one-login:registry=https://npm.pkg.github.com/" >> .npmrc
echo "//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN" >> .npmrc
- name: Install Dependencies
run: npm clean-install
- name: Run Unit Tests
if: inputs.RUN_UNIT_TESTS == 'true'
run: npm run test:unit
- name: Run Infra Tests
if: inputs.RUN_INFRA_TESTS == 'true'
run: npm run test:infra
- name: Run Pact Tests
if: inputs.RUN_PACT_TESTS == 'true'
continue-on-error: true # Pact tests are currently failing - remove step once fixed
env:
PACT_BROKER_URL: "https://pactbroker-onelogin.account.gov.uk"
PACT_BROKER_USERNAME: ${{ secrets.PACT_BROKER_USERNAME }}
PACT_BROKER_PASSWORD: ${{ secrets.PACT_BROKER_PASSWORD }}
PACT_BROKER_SOURCE_SECRET: ${{ secrets.PACT_BROKER_SOURCE_SECRET }}
PUBLISH_PACT_VERIFICATION_RESULTS: "false"
run: npm run test:pact:ci
- name: Run SonarQube Scan
if: inputs.RUN_SONARQUBE == 'true'
uses: sonarsource/sonarqube-scan-action@8c71dc039c2dd71d3821e89a2b58ecc7fee6ced9 #v5.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: ${{ inputs.WORKING_DIRECTORY }}
- name: Run SonarQube Quality Gate Check
if: inputs.RUN_SONARQUBE == 'true'
uses: Sonarsource/sonarqube-quality-gate-action@8406f4f1edaffef38e9fb9c53eb292fc1d7684fa #master
continue-on-error: ${{ fromJSON(env.CONTINUE_ON_ERROR) }}
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
scanMetadataReportFile: ${{ inputs.WORKING_DIRECTORY }}/.scannerwork/report-task.txt