Compare a Pull Request's Sliced G-code With Its Base Branch in the Slice Check

On a pull request, the Slice check now finds the newest build of the
base branch at or before the pull request's base commit that saved
fingerprints, compares them with its own, and writes report.txt into
the gcode-fingerprints artifact and the report into the job summary.
Every build also writes made_with.txt, the fingerprint script's hash and
the runner, so a report warns when the two sides were made differently.

scripts/ci_check_gcode.py reads the baseline's artifact in memory: the
download and each file in it are capped, and a file compressed with
anything but stored or deflate is refused, since a capped read does not
bound bzip2 or LZMA. An error writes its type only, never the text of
the files, and the step cannot fail the job.
This commit is contained in:
Hanif Koh authored and HanifKoh committed 2026-11-28 22:08:48 +08:00
1 parent f6adf818ab
commit 9dafcc7314
3 files changed
+601 -3

No files matched your search

+23 -3
View File
@@ -279,6 +279,10 @@ jobs:
if: ${{ !cancelled() && success() }}
# Follows whichever Linux leg built the validator.
runs-on: ${{ vars.SELF_HOSTED && 'orca-lnx-server' || 'ubuntu-24.04-arm' }}
# actions: read finds the base branch's fingerprints for the comparison below.
permissions:
actions: read
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v7
@@ -294,8 +298,8 @@ jobs:
run: |
chmod +x validator-bin/OrcaSlicer_profile_validator
./validator-bin/OrcaSlicer_profile_validator -p "${{ github.workspace }}/resources/profiles" -s -l 2 -o "${{ runner.temp }}/sliced-gcode"
# The fingerprints are for comparing builds, not a check: neither step
# below may fail the job.
# The fingerprints are for comparing builds, not a check: none of the
# steps below may fail the job.
- name: Fingerprint the sliced G-code
id: fingerprint
continue-on-error: true
@@ -303,6 +307,22 @@ jobs:
run: |
mkdir -p "${{ runner.temp }}/gcode-fingerprints"
python3 scripts/gcode_fingerprint.py fingerprint "${{ runner.temp }}/sliced-gcode" -o "${{ runner.temp }}/gcode-fingerprints/fingerprints.tsv"
python3 scripts/ci_check_gcode.py made-with -o "${{ runner.temp }}/gcode-fingerprints/made_with.txt"
# check_gcode_comment.yml posts report.txt on a pull request with the
# check-gcode label. HEAD is the merge commit, so HEAD^1 is the base.
- name: Compare with the base branch
if: ${{ github.event_name == 'pull_request' && steps.fingerprint.outcome == 'success' }}
continue-on-error: true
timeout-minutes: 5
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
out="${{ runner.temp }}/gcode-fingerprints"
echo "$PR_NUMBER" > "$out/pr_number.txt"
git fetch --no-tags --depth=2 origin "$(git rev-parse HEAD)"
python3 scripts/ci_check_gcode.py report --repo "$GITHUB_REPOSITORY" --branch "$GITHUB_BASE_REF" \
--base-sha "$(git rev-parse HEAD^1)" --head-dir "$out" --out "$out/report.txt" --summary "$GITHUB_STEP_SUMMARY"
- name: Upload the fingerprints
if: ${{ steps.fingerprint.outcome == 'success' }}
continue-on-error: true
@@ -310,7 +330,7 @@ jobs:
uses: actions/upload-artifact@v7
with:
name: gcode-fingerprints
path: ${{ runner.temp }}/gcode-fingerprints/fingerprints.tsv
path: ${{ runner.temp }}/gcode-fingerprints/
# A re-run of the job replaces the file.
overwrite: true
# A pull request's file is compared with its base branch's, so those are kept longer.