From ec4d38a9a5b3ff3aa174a2ce8485018f5aa238a1 Mon Sep 17 00:00:00 2001 From: Robert Brignull Date: Tue, 12 May 2020 12:16:51 +0100 Subject: [PATCH] add PR check of node modules --- .../{lint-build-test.yml => pr-checks.yml} | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) rename .github/workflows/{lint-build-test.yml => pr-checks.yml} (51%) diff --git a/.github/workflows/lint-build-test.yml b/.github/workflows/pr-checks.yml similarity index 51% rename from .github/workflows/lint-build-test.yml rename to .github/workflows/pr-checks.yml index ca47f74b4..fb30c74a7 100644 --- a/.github/workflows/lint-build-test.yml +++ b/.github/workflows/pr-checks.yml @@ -1,4 +1,4 @@ -name: "Lint, Build & Test" +name: "PR checks" on: [push, pull_request] @@ -30,10 +30,38 @@ jobs: if [ ! -z "$(git status --porcelain)" ]; then # If we get a fail here then the PR needs attention >&2 echo "Failed: JavaScript files are not up to date. Run 'npm run-script build' to update" + git status exit 1 fi echo "Success: JavaScript files are up to date" + check-node-modules: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Check node modules up to date + run: | + # Sanity check that repo is clean to start with + if [ ! -z "$(git status --porcelain)" ]; then + # If we get a fail here then this workflow needs attention... + >&2 echo "Failed: Repo should be clean before testing!" + exit 1 + fi + + # Reinstall modules and then clean to remove absolute paths + # Use 'npm ci' instead of 'npm install' as this is intended to be reproducible + npm ci + npm run removeNPMAbsolutePaths + # Check that repo is still clean + if [ ! -z "$(git status --porcelain)" ]; then + # If we get a fail here then the PR needs attention + >&2 echo "Failed: node_modules are not up to date. Run 'npm ci' and 'npm run removeNPMAbsolutePaths' to update" + git status + exit 1 + fi + echo "Success: node_modules are up to date" + npm-test: runs-on: ubuntu-latest