Use a separate workflow to check the diff compilation

This commit is contained in:
Barry Gordon
2022-04-19 18:22:23 +01:00
parent 083b8484d8
commit 6790cb69ed
3 changed files with 58 additions and 10 deletions

35
.github/workflows/check-dist.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Check dist
on:
pull_request:
push:
branches:
- main
- 'releases/*'
jobs:
verify-build: # make sure the checked in dist/ folder matches the output of a rebuild
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Read .nvmrc
id: nvm
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ steps.nvm.outputs.NVMRC }}
- name: Install NPM dependencies
run: npm ci
- name: Rebuild the dist/ directory
run: npm run build
- name: Compare the expected and actual dist/ directories
run: script/check-diff

View File

@@ -13,15 +13,20 @@ jobs:
name: CI
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Setup nodejs
uses: actions/setup-node@v2
- uses: actions/checkout@v3
with:
node-version: '16'
ref: ${{ github.event.pull_request.head.sha }}
- name: Install dependencies
- name: Read .nvmrc
id: nvm
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ steps.nvm.outputs.NVMRC }}
- name: Install NPM dependencies
run: npm ci
- name: Run linter
@@ -29,6 +34,3 @@ jobs:
- name: Run tests
run: npm test
- name: Verify the build artefact is updated
run: npm run build && git diff --quiet

11
bin/check-diff Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
# Make sure we notice any untracked files generated by the build
git add --intent-to-add .
git diff --quiet dist/
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Detected uncommitted changes after build:"
git --no-pager diff dist/
exit 1
fi