diff --git a/.eslintignore b/.eslintignore index 64f046d..2d0c064 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,3 @@ dist/ node_modules/ -coverage/ \ No newline at end of file +coverage/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb47eae..89c5e44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,11 +10,15 @@ permissions: contents: read jobs: - test: + pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - uses: actions/setup-node@v4 with: node-version: '20' @@ -23,21 +27,7 @@ jobs: - name: Install dependencies run: npm ci - - name: Run tests - 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 + - uses: pre-commit/action@v3.0.1 # Test the action itself test-action: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 767885e..943646f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,3 +21,18 @@ repos: - id: eslint files: \.js$ 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