From 55225928a149be3b2f4091089e811aac97755edc Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Wed, 3 Aug 2022 18:30:55 -0500 Subject: [PATCH 1/4] Add workflow to verify distributables are built --- .github/workflows/check-dist.yml | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/check-dist.yml diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml new file mode 100644 index 0000000..cc4b07d --- /dev/null +++ b/.github/workflows/check-dist.yml @@ -0,0 +1,51 @@ +# `dist/index.js` is a special file in Actions. +# When you reference an action with `uses:` in a workflow, +# `index.js` is the code that will run. +# For our project, we generate this file using `ncc` +# We need to make sure the checked-in `index.js` actually matches what we expect it to be. +name: Check dist/ + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + workflow_dispatch: + +jobs: + check-dist: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Rebuild the dist/ directory + run: npm run prepare + + - name: Compare the expected and actual dist/ directories + run: | + if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then + echo "Detected uncommitted changes after build in dist folder. See status below:" + git diff + exit 1 + fi + + if [ "$(git diff --ignore-space-at-eol pre/ | wc -l)" -gt "0" ]; then + echo "Detected uncommitted changes after build in pre folder. See status below:" + git diff + exit 1 + fi From e2ea66d572fe566c39ced5084f96c9827e057dfd Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Wed, 3 Aug 2022 21:46:57 -0500 Subject: [PATCH 2/4] Revise comment --- .github/workflows/check-dist.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index cc4b07d..ecbfc2b 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -1,8 +1,7 @@ -# `dist/index.js` is a special file in Actions. -# When you reference an action with `uses:` in a workflow, -# `index.js` is the code that will run. -# For our project, we generate this file using `ncc` -# We need to make sure the checked-in `index.js` actually matches what we expect it to be. +# When you reference this Action with `uses:` in a workflow, +# `dist/index.js` is the code that will run. +# For our project, we generate this file using `ncc`. +# We need to make sure the checked-in `dist/index.js` actually matches what we expect it to be. name: Check dist/ on: From 2a2b0fadb6b7a91c1021c6e75a604797fdec0a37 Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Wed, 3 Aug 2022 21:47:18 -0500 Subject: [PATCH 3/4] Remove diff of 'pre' since this Action doesn't have that directory --- .github/workflows/check-dist.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index ecbfc2b..7ed2580 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -42,9 +42,3 @@ jobs: git diff exit 1 fi - - if [ "$(git diff --ignore-space-at-eol pre/ | wc -l)" -gt "0" ]; then - echo "Detected uncommitted changes after build in pre folder. See status below:" - git diff - exit 1 - fi From 2fc7b604aaed13d014c4e58d86854f9fdbcde6b2 Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Fri, 5 Aug 2022 13:08:52 -0500 Subject: [PATCH 4/4] Add explicit `permissions` to workflow --- .github/workflows/check-dist.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 7ed2580..092b408 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -15,6 +15,9 @@ on: - '**.md' workflow_dispatch: +permissions: + contents: read + jobs: check-dist: runs-on: ubuntu-latest