mirror of
https://github.com/imjasonh/apidiff-action
synced 2026-07-06 22:52:43 +00:00
Use pre-commit action in CI
- Replace individual lint/test/build steps with pre-commit action - Ensures CI runs exactly the same checks as local development - Includes dist up-to-date check via pre-commit hooks
This commit is contained in:
parent
805c061497
commit
f9bedf8b44
3 changed files with 22 additions and 17 deletions
|
|
@ -1,3 +1,3 @@
|
||||||
dist/
|
dist/
|
||||||
node_modules/
|
node_modules/
|
||||||
coverage/
|
coverage/
|
||||||
|
|
|
||||||
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
|
|
@ -10,11 +10,15 @@ permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
pre-commit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '20'
|
||||||
|
|
@ -23,21 +27,7 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Run tests
|
- uses: pre-commit/action@v3.0.1
|
||||||
run: npm test
|
|
||||||
|
|
||||||
- name: Lint
|
|
||||||
run: npm run lint
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: npm run build
|
|
||||||
|
|
||||||
- name: Check dist is up to date
|
|
||||||
run: |
|
|
||||||
if [ -n "$(git status --porcelain dist)" ]; then
|
|
||||||
echo "Generated dist files are out of date. Run 'npm run build' and commit the changes."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Test the action itself
|
# Test the action itself
|
||||||
test-action:
|
test-action:
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,18 @@ repos:
|
||||||
- id: eslint
|
- id: eslint
|
||||||
files: \.js$
|
files: \.js$
|
||||||
args: ['--fix']
|
args: ['--fix']
|
||||||
|
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: build-dist
|
||||||
|
name: Build dist
|
||||||
|
entry: npm run build
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
||||||
|
files: ^(index\.js|lib/.*\.js)$
|
||||||
|
- id: check-dist
|
||||||
|
name: Check dist is up to date
|
||||||
|
entry: bash -c 'if [ -n "$(git status --porcelain dist)" ]; then echo "dist is out of date. Run npm run build and commit the changes."; exit 1; fi'
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue