mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-12 18:31:18 +00:00
* Add a /bot fix-tidy Command That Pushes clang-tidy's Missing Includes A maintainer comments /bot fix-tidy on a PR. A read-only job runs scripts/run_clang_tidy.sh --fix on the PR's merge commit and returns the patch; a second job, which never runs the PR's code, accepts it only when it adds nothing but #include lines to C++ files the PR already changes, then commits it on the PR head and pushes with CLANG_TIDY_BOT_TOKEN. * Post clang-tidy's Fix as Review Suggestions Instead of Pushing It A failed clang-tidy check now runs once more with --fix and uploads the patch as the clang-tidy-fix artifact; the check still fails. /bot fix-tidy downloads that patch for the PR's latest commit, checks it adds only includes to C++ files the PR changes, and posts one review: a one-click suggestion for each include on a line the PR's diff shows, and the whole patch with a git apply command. Nothing is pushed and no PR code runs in the bot, so the PR's author can run it too and no token is needed. * Make the clang-tidy Fix in Its Own PR-Scoped Workflow on Request clang_tidy.yml is back to main's version. clang_tidy_fix.yml runs on every PR push but skips its job on the first attempt; /bot fix-tidy re-runs it, so run_clang_tidy.sh --fix runs in the PR's own context with a read-only token and the PR's cache, never main's, and the PR's author can ask for it. When that re-run finishes, the bot posts the patch as review suggestions as before. When the clang-tidy step fails, the bot also comments asking the author to run the script or the command, edits that comment on later failures, and deletes it once the check passes. * Give the clang-tidy Bot Write Access to PRs It Answers * Tell /bot fix-tidy Users How to Start a Fix Run When There Is None to Re-Run
66 lines
2.3 KiB
YAML
66 lines
2.3 KiB
YAML
name: clang-tidy fix
|
|
|
|
# Makes the missing-include fix that /bot fix-tidy (pr-tidy-bot.yml) posts on a
|
|
# pull request: scripts/run_clang_tidy.sh --fix on the merge commit the
|
|
# clang-tidy check runs on, uploaded as the clang-tidy-fix artifact.
|
|
#
|
|
# Every push to a PR starts this workflow, and its job skips on that first
|
|
# attempt. The bot re-runs it on request. A re-run keeps the pull_request
|
|
# context, so the PR's code runs with a read-only token, no secrets and the
|
|
# PR's own cache, never main's, whoever asked for it.
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- release/*
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
fix:
|
|
if: github.run_attempt > 1
|
|
# A hosted runner, so nothing the PR's code leaves behind outlives the job.
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 60
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
lfs: 'false'
|
|
# The PR merge commit plus its first parent, the base it is diffed against.
|
|
fetch-depth: 2
|
|
persist-credentials: false
|
|
|
|
# Parsing needs the dependency headers, not a build of this PR's deps/, so
|
|
# a PR that changes deps/ falls back to the newest cache main has.
|
|
- name: Restore cached deps
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep
|
|
key: linux-clang-cache-orcaslicer_deps-build-${{ hashFiles('deps/**') }}
|
|
restore-keys: linux-clang-cache-orcaslicer_deps-build-
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Apt-Install Dependencies
|
|
uses: ./.github/actions/apt-install-deps
|
|
|
|
# The status says whether findings remain that --fix cannot fix.
|
|
- name: Fix the changed lines
|
|
run: |
|
|
mkdir -p "$RUNNER_TEMP/clang-tidy-fix"
|
|
status=0
|
|
scripts/run_clang_tidy.sh --base HEAD^1 --yes --fix || status=$?
|
|
echo "$status" > "$RUNNER_TEMP/clang-tidy-fix/status"
|
|
git -c core.quotePath=false diff --no-color --no-ext-diff --src-prefix=a/ --dst-prefix=b/ \
|
|
> "$RUNNER_TEMP/clang-tidy-fix/fix.patch"
|
|
|
|
- name: Upload the fix
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: clang-tidy-fix
|
|
path: ${{ runner.temp }}/clang-tidy-fix/
|
|
retention-days: 7
|
|
# A later re-run of the same run replaces the earlier fix.
|
|
overwrite: true
|