From f9f21017b3dbd24d6e971aea220bb91c7e7267e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Tue, 23 Dec 2025 14:48:54 +0000 Subject: [PATCH 1/6] CI: Post pre-commit fixes as suggestions In order to skip checks, prek was used instead of pre-commit --- .github/workflows/additional_checks.yml | 30 ++++++++++++++++++++++++- .github/workflows/post-pr-reviews.yml | 24 +++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/.github/workflows/additional_checks.yml b/.github/workflows/additional_checks.yml index 05ea074c6c7..e911cf934a7 100644 --- a/.github/workflows/additional_checks.yml +++ b/.github/workflows/additional_checks.yml @@ -72,7 +72,35 @@ jobs: path: ~/.cache/pre-commit key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - - name: "Run pre-commit" + - name: "Run pre-commit/prek for fixes" + run: | + echo '```console' > "$GITHUB_STEP_SUMMARY" + # Enable color output for pre-commit and remove it for the summary + # Use --hook-stage=manual to enable slower pre-commit hooks that are skipped by default + # Skip hooks already handled in another workflow, to avoid duplicate suggestions + # Skip hooks with no fixes made with these hooks (for now) + uvx prek run --all-files --show-diff-on-failure --color=always --hook-stage=manual \ + --skip ruff-check --skip ruff-format \ + --skip actionlint \ + --skip editorconfig-checker \ + --skip flake8 \ + --skip yamllint | \ + tee >(sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[mGK]//g' >> "$GITHUB_STEP_SUMMARY") >&1 + exit_code="${PIPESTATUS[0]}" + echo '```' >> "$GITHUB_STEP_SUMMARY" + exit "$exit_code" + + - name: Create and uploads code suggestions to apply for pre-commit + # Will fail fast here if there are changes required + id: diff-pre-commit + # To run after pre-commit step exits with failure + if: ${{ !cancelled() }} + uses: ./.github/actions/create-upload-suggestions + with: + tool-name: pre-commit + # To keep repo's file structure in formatted changes artifact + extra-upload-changes: pyproject.toml + - name: "Run pre-commit/prek" run: | echo '```console' > "$GITHUB_STEP_SUMMARY" # Enable color output for pre-commit and remove it for the summary diff --git a/.github/workflows/post-pr-reviews.yml b/.github/workflows/post-pr-reviews.yml index fa4bd603e5e..71f91f7348c 100644 --- a/.github/workflows/post-pr-reviews.yml +++ b/.github/workflows/post-pr-reviews.yml @@ -4,7 +4,10 @@ name: Post PR code suggestions on: # zizmor: ignore[dangerous-triggers] Only selected workflows, and whitelisted input values are used workflow_run: - workflows: ["ClangFormat Check", "Python Code Quality"] + workflows: + - "Additional checks" + - "ClangFormat Check" + - "Python Code Quality" types: - completed permissions: {} @@ -48,6 +51,7 @@ jobs: INPUT_TOOL_NAMES: >- black clang-format + pre-commit ruff - name: Post Black suggestions if: ${{ steps.tools.outputs.black == 'true' }} @@ -85,6 +89,24 @@ jobs: CI_REPO_OWNER: ${{ github.event.workflow_run.repository.owner.login }} CI_REPO_NAME: ${{ github.event.workflow_run.repository.name }} # CI_PULL_REQUEST: "" # Populated from reviewdog's "-guess" flag since hard to get + - name: Post pre-commit suggestions + if: ${{ steps.tools.outputs.pre-commit == 'true' }} + run: | + TMPFILE="diff-${INPUT_TOOL_NAME}.patch" + GITHUB_ACTIONS="" reviewdog \ + -name="${INPUT_TOOL_NAME:-reviewdog-suggester}" \ + -f=diff \ + -f.diff.strip=1 \ + -filter-mode=nofilter \ + -guess \ + -reporter="github-pr-review" < "${TMPFILE}" + env: + INPUT_TOOL_NAME: pre-commit + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CI_COMMIT: ${{ github.event.workflow_run.head_sha }} + CI_REPO_OWNER: ${{ github.event.workflow_run.repository.owner.login }} + CI_REPO_NAME: ${{ github.event.workflow_run.repository.name }} + # CI_PULL_REQUEST: "" # Populated from reviewdog's "-guess" flag since hard to get - name: Post Ruff suggestions if: ${{ steps.tools.outputs.ruff == 'true' }} run: | From 573c7fdb31ee10f2a8547cf434f6941ae4c2c6fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Tue, 23 Dec 2025 14:49:50 +0000 Subject: [PATCH 2/6] CI: Cache prek environments --- .github/workflows/additional_checks.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/additional_checks.yml b/.github/workflows/additional_checks.yml index e911cf934a7..5b859390f05 100644 --- a/.github/workflows/additional_checks.yml +++ b/.github/workflows/additional_checks.yml @@ -65,11 +65,12 @@ jobs: "${GITHUB_REF_NAME}" \ "$(git rev-parse HEAD~30)" \ "" - - name: "Cache pre-commit" + - name: "Cache pre-commit/prek" # Not used for releases, only for running pre-commit uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 # zizmor: ignore[cache-poisoning] with: - path: ~/.cache/pre-commit + path: |- + ~/.cache/prek key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - name: "Run pre-commit/prek for fixes" @@ -105,7 +106,7 @@ jobs: echo '```console' > "$GITHUB_STEP_SUMMARY" # Enable color output for pre-commit and remove it for the summary # Use --hook-stage=manual to enable slower pre-commit hooks that are skipped by default - uvx pre-commit run --all-files --show-diff-on-failure --color=always --hook-stage=manual | \ + uvx prek run --all-files --show-diff-on-failure --color=always --hook-stage=manual | \ tee >(sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[mGK]//g' >> "$GITHUB_STEP_SUMMARY") >&1 exit_code="${PIPESTATUS[0]}" echo '```' >> "$GITHUB_STEP_SUMMARY" From b0d3241d2a71cba383c7fc622cd1aa19312a0d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Tue, 23 Dec 2025 14:50:11 +0000 Subject: [PATCH 3/6] CI: Display reviewdog version installed for debugging --- .github/workflows/post-pr-reviews.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/post-pr-reviews.yml b/.github/workflows/post-pr-reviews.yml index 71f91f7348c..d987d27290b 100644 --- a/.github/workflows/post-pr-reviews.yml +++ b/.github/workflows/post-pr-reviews.yml @@ -31,6 +31,7 @@ jobs: github-token: ${{ github.token }} run-id: ${{github.event.workflow_run.id }} - uses: reviewdog/action-setup@d8a7baabd7f3e8544ee4dbde3ee41d0011c3a93f # v1.5.0 + - run: reviewdog -version - name: Check what tools have suggestions to post # Using this pattern to have expected file names explicitly named id: tools From 63088cf1da3bdd372478afe2292fdb16204b0608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Tue, 23 Dec 2025 15:21:06 +0000 Subject: [PATCH 4/6] CI: Install prek with a pinned version --- .github/workflows/additional_checks.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/additional_checks.yml b/.github/workflows/additional_checks.yml index 5b859390f05..8bf475116d7 100644 --- a/.github/workflows/additional_checks.yml +++ b/.github/workflows/additional_checks.yml @@ -25,6 +25,9 @@ jobs: runs-on: ubuntu-24.04 permissions: contents: read + env: + # renovate: datasource=pypi depName=prek + PREK_VERSION: 0.2.24 steps: - name: Checkout repository contents @@ -72,7 +75,8 @@ jobs: path: |- ~/.cache/prek key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - + - name: Install prek + run: uv tool install "prek@${PREK_VERSION}" - name: "Run pre-commit/prek for fixes" run: | echo '```console' > "$GITHUB_STEP_SUMMARY" @@ -80,7 +84,7 @@ jobs: # Use --hook-stage=manual to enable slower pre-commit hooks that are skipped by default # Skip hooks already handled in another workflow, to avoid duplicate suggestions # Skip hooks with no fixes made with these hooks (for now) - uvx prek run --all-files --show-diff-on-failure --color=always --hook-stage=manual \ + prek run --all-files --show-diff-on-failure --color=always --hook-stage=manual \ --skip ruff-check --skip ruff-format \ --skip actionlint \ --skip editorconfig-checker \ @@ -106,7 +110,7 @@ jobs: echo '```console' > "$GITHUB_STEP_SUMMARY" # Enable color output for pre-commit and remove it for the summary # Use --hook-stage=manual to enable slower pre-commit hooks that are skipped by default - uvx prek run --all-files --show-diff-on-failure --color=always --hook-stage=manual | \ + prek run --all-files --show-diff-on-failure --color=always --hook-stage=manual | \ tee >(sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[mGK]//g' >> "$GITHUB_STEP_SUMMARY") >&1 exit_code="${PIPESTATUS[0]}" echo '```' >> "$GITHUB_STEP_SUMMARY" From f91da36ad5f5597c633bd03a73e9aad64d1c8c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Tue, 23 Dec 2025 16:21:57 +0000 Subject: [PATCH 5/6] CI: Install pytest-timeout plugin to fix warning --- .github/workflows/additional_checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/additional_checks.yml b/.github/workflows/additional_checks.yml index 8bf475116d7..1c16455cff9 100644 --- a/.github/workflows/additional_checks.yml +++ b/.github/workflows/additional_checks.yml @@ -53,7 +53,7 @@ jobs: - name: Generate core modules with last commit JSON file and test it run: | - python -m pip install pytest pytest-depends + python -m pip install pytest pytest-depends pytest-timeout python utils/generate_last_commit_file.py . pytest utils/test_generate_last_commit_file.py From 3f06d2d91405442c2b1e205eb5136614e5c44425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Tue, 23 Dec 2025 16:23:17 +0000 Subject: [PATCH 6/6] CI: Upload generated files (release notes & core modules json) and remove them before running pre-commit --- .github/workflows/additional_checks.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/additional_checks.yml b/.github/workflows/additional_checks.yml index 1c16455cff9..8e1fd3969b1 100644 --- a/.github/workflows/additional_checks.yml +++ b/.github/workflows/additional_checks.yml @@ -67,7 +67,18 @@ jobs: python ./utils/generate_release_notes.py log \ "${GITHUB_REF_NAME}" \ "$(git rev-parse HEAD~30)" \ - "" + "" | \ + tee -a "release_notes_sample.md" + - name: Upload release notes and core modules with last commit JSON file + if: ${{ !cancelled() }} + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: release_notes-core_modules_with_last_commit + path: |- + core_modules_with_last_commit.json + release_notes_sample.md + - name: Remove created files + run: rm --verbose -f release_notes_sample.md core_modules_with_last_commit.json - name: "Cache pre-commit/prek" # Not used for releases, only for running pre-commit uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 # zizmor: ignore[cache-poisoning]