|
| 1 | +name: Quality Checks |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + secrets: |
| 6 | + SONAR_TOKEN: |
| 7 | + required: true |
| 8 | + inputs: |
| 9 | + node_version: |
| 10 | + description: The version of node used in this project. |
| 11 | + required: true |
| 12 | + type: number |
| 13 | + |
| 14 | +jobs: |
| 15 | + quality_checks: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + ref: ${{ env.BRANCH_NAME }} |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + # Using a specific commit SHA for stability |
| 25 | + - name: Install asdf |
| 26 | + uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 |
| 27 | + with: |
| 28 | + asdf_branch: v0.14.1 |
| 29 | + |
| 30 | + - name: Cache asdf |
| 31 | + uses: actions/cache@v4 |
| 32 | + with: |
| 33 | + path: | |
| 34 | + ~/.asdf |
| 35 | + key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} |
| 36 | + restore-keys: | |
| 37 | + ${{ runner.os }}-asdf- |
| 38 | +
|
| 39 | + - name: Install asdf dependencies in .tool-versions |
| 40 | + uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 |
| 41 | + with: |
| 42 | + asdf_branch: v0.14.1 |
| 43 | + env: |
| 44 | + PYTHON_CONFIGURE_OPTS: --enable-shared |
| 45 | + |
| 46 | + - name: Setting up .npmrc |
| 47 | + env: |
| 48 | + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + run: | |
| 50 | + echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc |
| 51 | + echo "@nhsdigital:registry=https://npm.pkg.github.com" >> ~/.npmrc |
| 52 | +
|
| 53 | + - name: Install dependencies |
| 54 | + run: make install |
| 55 | + |
| 56 | + - name: Generate and check SBOMs |
| 57 | + uses: NHSDigital/eps-action-sbom@main |
| 58 | + with: |
| 59 | + node_version: {{ inputs.node_version }} |
| 60 | + |
| 61 | + - name: Upload SBOMs |
| 62 | + uses: actions/upload-artifact@v3 |
| 63 | + with: |
| 64 | + name: SBOMS |
| 65 | + path: '**/*sbom*.json' |
| 66 | + |
| 67 | + - name: Check licenses |
| 68 | + run: make check-licenses |
| 69 | + |
| 70 | + - name: Run linting |
| 71 | + run: make lint |
| 72 | + |
| 73 | + - name: Run unit tests |
| 74 | + run: make test |
| 75 | + |
| 76 | + - name: Run cfn-guard |
| 77 | + run: make cfn-guard |
| 78 | + |
| 79 | + - name: Show cfn-guard output |
| 80 | + if: failure() |
| 81 | + run: find cfn_guard_output -type f -print0 | xargs -0 cat |
| 82 | + |
| 83 | + - name: Upload cfn-guard output |
| 84 | + if: failure() |
| 85 | + uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: cfn_guard_output |
| 88 | + path: cfn_guard_output |
| 89 | + |
| 90 | + - name: SonarCloud Scan |
| 91 | + uses: SonarSource/sonarcloud-github-action@master |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
0 commit comments