CI Build Cache Skipping
By default, CI runners rebuild containers and run full test suites whenever a Pull Request touches any byte in a source file. Using canontra impact --pr-base, CI jobs can check whether edits changed real behavior before running slow build steps.
GitHub Actions Workflow (canontra impact --pr-base)
Section titled “GitHub Actions Workflow (canontra impact --pr-base)”The workflow below installs Canontra, checks the PR diff against origin/main in JSON mode, and skips downstream test jobs whenever all modified source files are Level 1 (Cosmetic / Trivia) (birLevel2LogicFiles and birLevel3ApiFiles are both empty):
name: Semantic CI Gate
on: pull_request: branches: [main]
jobs: semantic-triage: runs-on: ubuntu-latest outputs: run_tests: ${{ steps.triage.outputs.run_tests }} test_cmd: ${{ steps.triage.outputs.test_cmd }} steps: - name: Checkout full history for PR base diff uses: actions/checkout@v4 with: fetch-depth: 0
- name: Install Canontra run: curl -fsSL https://raw.githubusercontent.com/symtrace/canontra/main/install.sh | bash
- name: Compute PR batch semantic impact id: triage run: | export PATH="$HOME/.local/bin:$PATH" canontra impact --pr-base origin/${{ github.base_ref }} --json > impact.json cat impact.json
LOGIC_COUNT=$(jq '.birLevel2LogicFiles | length' impact.json) API_COUNT=$(jq '.birLevel3ApiFiles | length' impact.json) TEST_CMD=$(jq -r '.birTestCommand' impact.json)
if [ "$LOGIC_COUNT" -eq 0 ] && [ "$API_COUNT" -eq 0 ]; then echo "run_tests=false" >> "$GITHUB_OUTPUT" else echo "run_tests=true" >> "$GITHUB_OUTPUT" echo "test_cmd=$TEST_CMD" >> "$GITHUB_OUTPUT" fi
targeted-tests: needs: semantic-triage if: needs.semantic-triage.outputs.run_tests == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run minimal CSR-sliced test suite run: ${{ needs.semantic-triage.outputs.test_cmd }}Single-File Artifact Gate (canontra compare)
Section titled “Single-File Artifact Gate (canontra compare)”For single-file build targets (such as worker scripts or schema generators), compare the current file directly against the main revision:
git show origin/main:src/worker.py > /tmp/worker_base.pyif canontra compare /tmp/worker_base.py src/worker.py; then echo "Semantic F4 identical: skipping container rebuild."else docker build -t worker:latest .ficanontra compare returns exit code 0 when F4 matches and 1 when program behavior changed.