1- name : " Test stage"
1+ name : ' Test stage'
22
33on :
44 workflow_call :
55 inputs :
66 build_datetime :
7- description : " Build datetime, set by the CI/CD pipeline workflow"
7+ description : ' Build datetime, set by the CI/CD pipeline workflow'
88 required : true
99 type : string
1010 build_timestamp :
11- description : " Build timestamp, set by the CI/CD pipeline workflow"
11+ description : ' Build timestamp, set by the CI/CD pipeline workflow'
1212 required : true
1313 type : string
1414 build_epoch :
15- description : " Build epoch, set by the CI/CD pipeline workflow"
15+ description : ' Build epoch, set by the CI/CD pipeline workflow'
1616 required : true
1717 type : string
1818 nodejs_version :
19- description : " Node.js version, set by the CI/CD pipeline workflow"
19+ description : ' Node.js version, set by the CI/CD pipeline workflow'
2020 required : true
2121 type : string
2222 python_version :
23- description : " Python version, set by the CI/CD pipeline workflow"
23+ description : ' Python version, set by the CI/CD pipeline workflow'
2424 required : true
2525 type : string
2626 terraform_version :
27- description : " Terraform version, set by the CI/CD pipeline workflow"
27+ description : ' Terraform version, set by the CI/CD pipeline workflow'
2828 required : true
2929 type : string
3030 version :
31- description : " Version of the software, set by the CI/CD pipeline workflow"
31+ description : ' Version of the software, set by the CI/CD pipeline workflow'
3232 required : true
3333 type : string
3434
@@ -38,118 +38,200 @@ env:
3838
3939permissions :
4040 id-token : write # This is required for requesting the JWT
41- contents : read # This is required for actions/checkout
41+ contents : read # This is required for actions/checkout
4242
4343jobs :
44+ setup-dependencies :
45+ name : ' Setup dependencies'
46+ runs-on : ubuntu-latest
47+ timeout-minutes : 10
48+ outputs :
49+ cache-hit : ${{ steps.cache-nodemodules.outputs.cache-hit }}
50+ steps :
51+ - name : ' Checkout code'
52+ 53+
54+ - name : ' Setup Node.js'
55+ uses : actions/setup-node@v4
56+ with :
57+ node-version : ${{ inputs.nodejs_version }}
58+ cache : ' npm'
59+
60+ - name : ' Cache node_modules'
61+ id : cache-nodemodules
62+ uses : actions/cache@v4
63+ with :
64+ path : node_modules
65+ key : ${{ runner.os }}-node-modules-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
66+ restore-keys : |
67+ ${{ runner.os }}-node-modules-${{ inputs.nodejs_version }}-
68+ ${{ runner.os }}-node-modules-
69+
70+ - name : ' Install dependencies'
71+ if : steps.cache-nodemodules.outputs.cache-hit != 'true'
72+ run : npm ci
4473 check-generated-dependencies :
45- name : " Check generated dependencies"
74+ name : ' Check generated dependencies'
75+ needs : [setup-dependencies]
4676 runs-on : ubuntu-latest
4777 timeout-minutes : 5
4878 steps :
49- - name : " Checkout code"
79+ - name : ' Checkout code'
508051- - name : " Repo setup"
52- run : |
53- npm ci
54- - name : " Generate dependencies"
81+
82+ - name : ' Setup Node.js'
83+ uses : actions/setup-node@v4
84+ with :
85+ node-version : ${{ inputs.nodejs_version }}
86+
87+ - name : ' Restore dependencies'
88+ uses : actions/cache/restore@v4
89+ with :
90+ path : |
91+ node_modules
92+ **/node_modules
93+ key : ${{ runner.os }}-full-setup-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}
94+ fail-on-cache-miss : true
95+
96+ - name : ' Generate dependencies'
5597 run : |
5698 npm run generate-dependencies --workspaces --if-present
5799 git diff --exit-code
58100 test-unit :
59- name : " Unit tests"
101+ name : ' Unit tests'
60102 runs-on : ubuntu-latest
61103 timeout-minutes : 5
62104 steps :
63- - name : " Checkout code"
105+ - name : ' Checkout code'
6410665- - name : " Repo setup"
66- run : |
67- npm ci
68- - name : " Generate dependencies"
107+
108+ - name : ' Setup Node.js'
109+ uses : actions/setup-node@v4
110+ with :
111+ node-version : ${{ inputs.nodejs_version }}
112+
113+ - name : ' Restore dependencies'
114+ uses : actions/cache/restore@v4
115+ with :
116+ path : |
117+ node_modules
118+ **/node_modules
119+ key : ${{ runner.os }}-full-setup-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}
120+ fail-on-cache-miss : true
121+
122+ - name : ' Generate dependencies'
69123 run : |
70124 npm run generate-dependencies --workspaces --if-present
71- - name : " Run unit test suite"
125+
126+ - name : ' Run unit test suite'
72127 run : |
73128 make test-unit
74- - name : " Save the result of fast test suite"
129+
130+ - name : ' Save the result of fast test suite'
75131 uses : actions/upload-artifact@v4
76132 with :
77133 name : unit-tests
78- path : " **/.reports/unit"
134+ path : ' **/.reports/unit'
79135 include-hidden-files : true
80- if : always()
81- - name : " Save the result of code coverage"
136+ if : !cancelled()
137+
138+ - name : ' Save the result of code coverage'
82139 uses : actions/upload-artifact@v4
83140 with :
84141 name : code-coverage-report
85- path : " .reports/lcov.info"
142+ path : ' .reports/lcov.info'
86143 if : always()
87144 test-lint :
88- name : " Linting"
145+ name : ' Linting'
89146 runs-on : ubuntu-latest
90147 timeout-minutes : 5
91148 steps :
92- - name : " Checkout code"
149+ - name : ' Checkout code'
9315094- - name : " Repo setup"
95- run : |
96- npm ci
97- - name : " Generate dependencies"
151+
152+ - name : ' Setup Node.js'
153+ uses : actions/setup-node@v4
154+ with :
155+ node-version : ${{ inputs.nodejs_version }}
156+
157+ - name : ' Restore dependencies'
158+ uses : actions/cache/restore@v4
159+ with :
160+ path : |
161+ node_modules
162+ **/node_modules
163+ key : ${{ runner.os }}-full-setup-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}
164+ fail-on-cache-miss : true
165+
166+ - name : ' Generate dependencies'
98167 run : |
99168 npm run generate-dependencies --workspaces --if-present
100- - name : " Run linting"
169+
170+ - name : ' Run linting'
101171 run : |
102172 make test-lint
103173 test-typecheck :
104- name : " Typecheck"
174+ name : ' Typecheck'
105175 runs-on : ubuntu-latest
106176 timeout-minutes : 5
107177 steps :
108- - name : " Checkout code"
178+ - name : ' Checkout code'
109179110- - name : " Repo setup"
111- run : |
112- npm ci
113- - name : " Generate dependencies"
180+
181+ - name : ' Setup Node.js'
182+ uses : actions/setup-node@v4
183+ with :
184+ node-version : ${{ inputs.nodejs_version }}
185+
186+ - name : ' Restore dependencies'
187+ uses : actions/cache/restore@v4
188+ with :
189+ path : |
190+ node_modules
191+ **/node_modules
192+ key : ${{ runner.os }}-full-setup-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}
193+ fail-on-cache-miss : true
194+
195+ - name : ' Generate dependencies'
114196 run : |
115197 npm run generate-dependencies --workspaces --if-present
116- - name : " Run typecheck"
198+ - name : ' Run typecheck'
117199 run : |
118200 make test-typecheck
119201 test-coverage :
120- name : " Test coverage"
202+ name : ' Test coverage'
121203 needs : [test-unit]
122204 runs-on : ubuntu-latest
123205 timeout-minutes : 5
124206 steps :
125- - name : " Checkout code"
207+ - name : ' Checkout code'
126208127- - name : " Run test coverage check"
209+ - name : ' Run test coverage check'
128210 run : |
129211 make test-coverage
130- - name : " Save the coverage check result"
212+ - name : ' Save the coverage check result'
131213 run : |
132214 echo "Nothing to save"
133215 perform-static-analysis :
134- name : " Perform static analysis"
216+ name : ' Perform static analysis'
135217 needs : [test-unit]
136218 runs-on : ubuntu-latest
137219 permissions :
138220 id-token : write
139221 contents : read
140222 timeout-minutes : 5
141223 steps :
142- - name : " Checkout code"
224+ - name : ' Checkout code'
143225144226 with :
145227 fetch-depth : 0 # Full history is needed to improving relevancy of reporting
146- - name : " Download coverage report for SONAR"
228+ - name : ' Download coverage report for SONAR'
147229 uses : actions/download-artifact@v5
148230 with :
149231 name : code-coverage-report
150- - name : " Perform static analysis"
232+ - name : ' Perform static analysis'
151233 uses : ./.github/actions/perform-static-analysis
152234 with :
153- sonar_organisation_key : " ${{ vars.SONAR_ORGANISATION_KEY }}"
154- sonar_project_key : " ${{ vars.SONAR_PROJECT_KEY }}"
155- sonar_token : " ${{ secrets.SONAR_TOKEN }}"
235+ sonar_organisation_key : ' ${{ vars.SONAR_ORGANISATION_KEY }}'
236+ sonar_project_key : ' ${{ vars.SONAR_PROJECT_KEY }}'
237+ sonar_token : ' ${{ secrets.SONAR_TOKEN }}'
0 commit comments