Skip to content

Commit 09487cb

Browse files
committed
Add check-dist workflow
1 parent 2b7d2eb commit 09487cb

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

.github/workflows/check-dist.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Check dist
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- 'releases/*'
9+
10+
jobs:
11+
verify-build: # make sure the checked in dist/ folder matches the output of a rebuild
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
ref: ${{ github.event.pull_request.head.sha }}
18+
19+
- name: Read .nvmrc
20+
id: nvm
21+
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v1
25+
with:
26+
node-version: ${{ steps.nvm.outputs.NVMRC }}
27+
28+
- name: Install NPM dependencies
29+
run: npm ci
30+
31+
- name: Rebuild the dist/ directory
32+
run: npm run package
33+
34+
- name: Compare the expected and actual dist/ directories
35+
run: script/check-diff
36+
verify-index-js: # make sure the entrypoint js files run on a clean machine without compiling first
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v2
40+
with:
41+
ref: ${{ github.event.pull_request.head.sha }}
42+
43+
- uses: ./
44+
with:
45+
milliseconds: 1000

script/check-diff

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Make sure we notice any untracked files generated by the build
4+
git add --intent-to-add .
5+
git diff --quiet dist/
6+
retVal=$?
7+
if [ $retVal -ne 0 ]; then
8+
echo "Detected uncommitted changes after build:"
9+
git --no-pager diff dist/
10+
exit 1
11+
fi

0 commit comments

Comments
 (0)