|
| 1 | +# Biome is a seperate workflow because it should be run both on frontend source files and backend static files. |
| 2 | + |
| 3 | +name: biome |
| 4 | + |
| 5 | +on: workflow_call |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + runs-on: ubuntu-24.04 |
| 9 | + |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + - uses: actions/setup-node@v4 |
| 13 | + with: |
| 14 | + node-version: '20.18.1' # version that's pinned in Dockerfile for kpi release |
| 15 | + check-latest: true # download newer semver match if available |
| 16 | + cache: 'npm' |
| 17 | + |
| 18 | + - name: Identify resolved node version |
| 19 | + id: resolved-node-version |
| 20 | + run: echo "NODE_VERSION=$(node --version)" >> "$GITHUB_OUTPUT" |
| 21 | + |
| 22 | + # Cache: Use cache for node_modules |
| 23 | + # Keyed on os, node version, package-lock, and patches |
| 24 | + - uses: actions/cache@v4 |
| 25 | + name: Check for cached node_modules |
| 26 | + id: cache-nodemodules |
| 27 | + env: |
| 28 | + cache-name: cache-node-modules |
| 29 | + with: |
| 30 | + path: node_modules |
| 31 | + key: ${{ runner.os }}-build-${{ env.cache-name }}-node-v${{ steps.resolved-node-version.outputs.NODE_VERSION }}-${{ hashFiles('**/package-lock.json', 'patches/**/*.patch') }} |
| 32 | + |
| 33 | + # Cache hit: If the cache key matches, |
| 34 | + # /node_modules/ will have been copied from a previous run. |
| 35 | + # (Run the post-install step, `npm run copy-fonts`) |
| 36 | + - name: Run copy-fonts (if using cached node_modules) |
| 37 | + if: steps.cache-nodemodules.outputs.cache-hit == 'true' |
| 38 | + run: npm run copy-fonts |
| 39 | + |
| 40 | + # Cache miss: If node_modules has not been cached, |
| 41 | + # `npm install` |
| 42 | + # (This includes `npm run copy-fonts` as post-install step) |
| 43 | + - name: Install JavaScript dependencies (npm install) |
| 44 | + if: steps.cache-nodemodules.outputs.cache-hit != 'true' |
| 45 | + run: npm install |
| 46 | + |
| 47 | + # Check for Biome formatting errors |
| 48 | + - name: Check Biome formatting, import order and linter |
| 49 | + run: npm run lint:biome |
0 commit comments