diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 6da928f..dc05795 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -24,6 +24,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + # Full history is required so `--from-ref`/`--to-ref` below can diff + # the PR's base and head commits. + fetch-depth: 0 - name: Setup python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 @@ -41,3 +45,11 @@ jobs: - name: Run pre-commit uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 + with: + # Pull requests: only check the files the PR actually changes, so lint + # debt elsewhere on master cannot block an unrelated contribution. + # Pushes to master and manual runs: check everything. + extra_args: >- + ${{ github.event_name == 'pull_request' + && format('--from-ref {0} --to-ref {1}', github.event.pull_request.base.sha, github.event.pull_request.head.sha) + || '--all-files' }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dddf381..e4c2123 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,12 @@ --- -# pre-commit install --allow-missing-config && pre-commit autoupdate && pre-commit run --all-files --color auto +# Local setup: pip install pre-commit && pre-commit install +# Run everything: pre-commit run --all-files exclude: | (?x)^( old-versions/.* ) -fail_fast: true +# Report every failing hook in one run instead of stopping at the first one. +fail_fast: false default_stages: - pre-commit default_language_version: diff --git a/README.md b/README.md index 490e703..322e733 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,18 @@ However, when using CI/CD tools to provide automation, keep in mind that the too Contributions are welcome: fix a typo, add a tool, or propose a new topic by opening an issue or pull request. Please keep tool lists vendor-neutral and alphabetically ordered, and update the Table of Contents when adding or renaming files (see [doc-utilities](doc-utilities/README.md) for the TOC generator). +### Running the checks locally + +CI runs [pre-commit](https://pre-commit.com/) (Markdown lint, trailing whitespace, end-of-file newline, YAML/JSON validity) on every pull request. Running the same hooks locally before you push avoids a red CI run: + +```bash +python3.13 -m pip install pre-commit +pre-commit install # run the hooks automatically on every commit +pre-commit run --all-files # or run them once across the whole repository +``` + +On pull requests CI only checks the files you changed; pushes to `master` check the whole repository. + ## Previous versions Earlier editions are kept in [old-versions](old-versions/) (V0.1, V0.2, V0.3).