@@ -109,6 +109,14 @@ jobs:
109109 echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
110110 echo "@nhsdigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
111111
112+ - name : Cache npm dependencies
113+ uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
114+ with :
115+ path : ./node_modules
116+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
117+ restore-keys : |
118+ ${{ runner.os }}-node-
119+
112120 - name : make install
113121 run : |
114122 make install
@@ -143,6 +151,58 @@ jobs:
143151 echo "uses_java=false" >> "$GITHUB_OUTPUT"
144152 fi
145153
154+ - name : Check licenses (Makefile)
155+ run : |
156+ make check-licenses
157+
158+ - name : Run code lint
159+ run : make lint
160+
161+ - name : actionlint
162+ uses : raven-actions/actionlint@3a24062651993d40fed1019b58ac6fbdfbf276cc
163+
164+ - name : Run ShellCheck
165+ uses : ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38
166+ with :
167+ ignore_paths : >-
168+ *test*
169+ .venv
170+ node_modules
171+ .git
172+
173+ - name : Run unit tests
174+ run : make test
175+
176+ - name : Generate and check SBOMs
177+ uses : NHSDigital/eps-action-sbom@7684ce6314e515df7b7929fac08b4464f8a03d06
178+
179+ - name : " check is SONAR_TOKEN exists"
180+ env :
181+ super_secret : ${{ secrets.SONAR_TOKEN }}
182+ if : ${{ env.super_secret != '' && inputs.run_sonar == true }}
183+ run : echo "SONAR_TOKEN_EXISTS=true" >> "$GITHUB_ENV"
184+
185+ - name : Run SonarQube analysis
186+ if : ${{ steps.check_java.outputs.uses_java == 'true' && env.SONAR_TOKEN_EXISTS == 'true' }}
187+ run : mvn sonar:sonar -Dsonar.login=${{ secrets.SONAR_TOKEN }}
188+
189+ - name : SonarCloud Scan
190+ uses : SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602
191+ if : ${{ steps.check_java.outputs.uses_java == 'false' && env.SONAR_TOKEN_EXISTS == 'true' }}
192+ env :
193+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
194+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
195+
196+ # CloudFormation validation (runs only if templates exist, ~3-5 minutes)
197+ cloudformation-validation :
198+ runs-on : ubuntu-22.04
199+ steps :
200+ - name : Checkout code
201+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
202+ with :
203+ ref : ${{ env.BRANCH_NAME }}
204+ fetch-depth : 0
205+
146206 - name : Check for SAM templates
147207 id : check_sam_templates
148208 run : |
@@ -188,34 +248,34 @@ jobs:
188248 echo "cdk_exists=false" >> "$GITHUB_OUTPUT"
189249 fi
190250
191- - name : Check licenses (Makefile)
192- run : |
193- make check-licenses
194-
195- - name : Run code lint
196- run : make lint
197-
198- - name : actionlint
199- uses : raven-actions/actionlint@3a24062651993d40fed1019b58ac6fbdfbf276cc
200-
201- - name : Run ShellCheck
202- uses : ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38
203- with :
204- ignore_paths : >-
205- *test*
206- .venv
207- node_modules
208- .git
209-
210251 - name : Run cfn-lint
211252 if : steps.check_sam_templates.outputs.sam_exists == 'true' || steps.check_cf_templates.outputs.cf_exists == 'true'
212253 run : |
213254 pip install cfn-lint
214255 cfn-lint -I "cloudformation/**/*.y*ml" 2>&1 | awk '/Run scan/ { print } /^[EW][0-9]/ { print; getline; print }'
215256 cfn-lint -I "SAMtemplates/**/*.y*ml" 2>&1 | awk '/Run scan/ { print } /^[EW][0-9]/ { print; getline; print }'
216257
217- - name : Run unit tests
218- run : make test
258+ - name : Cache npm dependencies
259+ if : steps.check_cdk.outputs.cdk_exists == 'true'
260+ uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
261+ with :
262+ path : ~/.npm
263+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
264+ restore-keys : |
265+ ${{ runner.os }}-node-
266+
267+ - name : Setting up .npmrc
268+ if : steps.check_cdk.outputs.cdk_exists == 'true'
269+ env :
270+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
271+ run : |
272+ echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
273+ echo "@nhsdigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
274+
275+ - name : make install NodeJS
276+ if : steps.check_cdk.outputs.cdk_exists == 'true'
277+ run : |
278+ make install-node && make compile
219279
220280 - name : Run cdk-synth
221281 if : steps.check_cdk.outputs.cdk_exists == 'true'
@@ -347,23 +407,3 @@ jobs:
347407 with :
348408 name : cfn_guard_output
349409 path : cfn_guard_output
350-
351- - name : Generate and check SBOMs
352- uses : NHSDigital/eps-action-sbom@7684ce6314e515df7b7929fac08b4464f8a03d06
353-
354- - name : " check is SONAR_TOKEN exists"
355- env :
356- super_secret : ${{ secrets.SONAR_TOKEN }}
357- if : ${{ env.super_secret != '' && inputs.run_sonar == true }}
358- run : echo "SONAR_TOKEN_EXISTS=true" >> "$GITHUB_ENV"
359-
360- - name : Run SonarQube analysis
361- if : ${{ steps.check_java.outputs.uses_java == 'true' && env.SONAR_TOKEN_EXISTS == 'true' }}
362- run : mvn sonar:sonar -Dsonar.login=${{ secrets.SONAR_TOKEN }}
363-
364- - name : SonarCloud Scan
365- uses : SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602
366- if : ${{ steps.check_java.outputs.uses_java == 'false' && env.SONAR_TOKEN_EXISTS == 'true' }}
367- env :
368- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
369- SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
0 commit comments