Skip to content

Commit 941c379

Browse files
authored
Add workflow to check state of diff folder (#17)
Code changes need to be manually packaged by running `npm run package`. This workflow verifies that there's no diff to the `dist` folder after packaging the project.
1 parent 6c41589 commit 941c379

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

.github/workflows/check-dist.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# In TypeScript actions, `dist/` is a special directory. When you reference
2+
# an action with the `uses:` property, `dist/index.js` is the code that will be
3+
# run. For this project, the `dist/index.js` file is transpiled from other
4+
# source files. This workflow ensures the `dist/` directory contains the
5+
# expected transpiled code.
6+
#
7+
# If this workflow is run from a feature branch, it will act as an additional CI
8+
# check and fail if the checked-in `dist/` directory does not match what is
9+
# expected from the build.
10+
name: check-dist
11+
12+
on:
13+
pull_request:
14+
branches:
15+
- main
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
check-dist:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout
26+
id: checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Setup Node.js
30+
id: setup-node
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version-file: .node-version
34+
cache: npm
35+
36+
- name: Install Dependencies
37+
id: install
38+
run: npm ci
39+
40+
- name: Build dist/ Directory
41+
id: build
42+
run: npm run bundle
43+
44+
# This will fail the workflow if the `dist/` directory is different than
45+
# expected.
46+
- name: Compare Directories
47+
id: diff
48+
run: |
49+
if [ ! -d dist/ ]; then
50+
echo "Expected dist/ directory does not exist. See status below:"
51+
ls -la ./
52+
exit 1
53+
fi
54+
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
55+
echo "Detected uncommitted changes after build. See status below:"
56+
git diff --ignore-space-at-eol --text dist/
57+
exit 1
58+
fi

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"node": ">=20"
1313
},
1414
"scripts": {
15+
"bundle": "npm run format:write && npm run package",
1516
"format:write": "npx prettier --write .",
1617
"format:check": "npx prettier --check .",
1718
"lint": "npx eslint .",

0 commit comments

Comments
 (0)