From c9039482c980d10828ab0b8e7fc4e87bc8bddd9f Mon Sep 17 00:00:00 2001 From: Farhan Ashraf <53370109+farhanashrafdev@users.noreply.github.com> Date: Sun, 4 Oct 2026 14:05:19 +0500 Subject: [PATCH 1/2] ci: run pre-commit on changed files for PRs, drop fail_fast, document local setup Closes #112. - master.yml: on pull_request pass --from-ref base.sha --to-ref head.sha to pre-commit/action so only files the PR touches are checked; pushes to master and workflow_dispatch keep --all-files. Checkout now uses fetch-depth: 0 so both refs are available. - .pre-commit-config.yaml: fail_fast false so one CI run reports every failing hook instead of stopping at the first. - README.md: add "Running the checks locally" under Contributing. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/master.yml | 12 ++++++++++++ .pre-commit-config.yaml | 6 ++++-- README.md | 12 ++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) 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..b4adbc0 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 +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). From 26e178ce9918866b6ac90ea0b791c42d5be7023a Mon Sep 17 00:00:00 2001 From: Ali Yazdani Date: Sun, 4 Oct 2026 11:47:22 +0200 Subject: [PATCH 2/2] Change pip command to python3.13 for pre-commit Updated Python command for installing pre-commit. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4adbc0..322e733 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ Contributions are welcome: fix a typo, add a tool, or propose a new topic by ope 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 -pip install pre-commit +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 ```