diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b1edccf5..5835d846f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,9 +41,12 @@ jobs: PY - name: Compare production source env: - PR_BASE: ${{ github.event.pull_request.base.sha || inputs.base }} + # pull_request.base.sha is not refreshed when the base branch moves, so it can name a + # revision many commits behind and charge the PR for debt main introduced. The PR's own + # change starts at the merge-base with the base branch's current tip. + BASE_TIP: ${{ github.event.pull_request.base.ref && format('origin/{0}', github.event.pull_request.base.ref) || inputs.base }} PR_HEAD: ${{ github.event.pull_request.head.sha || inputs.head }} - run: PYTHONPATH="$PWD/.core-ratchet/src" PATH="$PWD/.venv/bin:$PATH" .venv/bin/python .core-ratchet/tools/debt_ratchet.py --root src/toad --base "$PR_BASE" --head "$PR_HEAD" + run: PYTHONPATH="$PWD/.core-ratchet/src" PATH="$PWD/.venv/bin:$PATH" .venv/bin/python .core-ratchet/tools/debt_ratchet.py --root src/toad --base "$(git merge-base "$BASE_TIP" "$PR_HEAD")" --head "$PR_HEAD" - name: Run surface guards run: .venv/bin/pytest tests/guards suite: