Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

Test pull requests against their merged result (#2113)

Ali Khokharf919f46de3ae
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 362d3f26..31bb8cdd 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -14,6 +14,7 @@ env:
UV_MALWARE_CHECK: "1"
UV_PREVIEW_FEATURES: "malware-check"
+# Every checkout uses this event's fixed merge commit, including for fork PRs.
on:
pull_request:
@@ -31,8 +32,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
- ref: ${{ github.event.pull_request.head.sha || github.ref }}
- repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
+ ref: ${{ github.sha }}
fetch-depth: 0
- name: "Fail on type ignores and legacy future annotations"
@@ -62,8 +62,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
- ref: ${{ github.event.pull_request.head.sha || github.ref }}
- repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
+ ref: ${{ github.sha }}
fetch-depth: 0
- name: Set up CI environment
@@ -87,8 +86,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
- ref: ${{ github.event.pull_request.head.sha || github.ref }}
- repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
+ ref: ${{ github.sha }}
- name: Generate test matrices
id: matrix
@@ -110,8 +108,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
- ref: ${{ github.event.pull_request.head.sha || github.ref }}
- repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
+ ref: ${{ github.sha }}
fetch-depth: 0
- name: Set up CI environment
@@ -140,8 +137,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
- ref: ${{ github.event.pull_request.head.sha || github.ref }}
- repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
+ ref: ${{ github.sha }}
fetch-depth: 0
- name: Set up CI environment
@@ -184,8 +180,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
- ref: ${{ github.event.pull_request.head.sha || github.ref }}
- repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
+ ref: ${{ github.sha }}
fetch-depth: 0
- uses: ./.github/actions/ci-environment
id: environment
@@ -220,8 +215,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
- ref: ${{ github.event.pull_request.head.sha || github.ref }}
- repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
+ ref: ${{ github.sha }}
fetch-depth: 0
- uses: ./.github/actions/ci-environment
id: environment
diff --git a/tests/scripts/test_release_workflow.py b/tests/scripts/test_release_workflow.py
index 6f0e34d6..4e0806db 100644
--- a/tests/scripts/test_release_workflow.py
+++ b/tests/scripts/test_release_workflow.py
@@ -100,6 +100,23 @@ def test_all_project_setup_jobs_have_history_and_fetch_canonical_tags():
assert fetch["env"]["CI_REPOSITORY"] == "${{ github.repository }}"
+def test_ci_checks_out_the_event_merge_commit_from_the_base_repository():
+ config = load("tests.yml")
+ assert set(config[True]) == {"pull_request"}
+ checkouts = [
+ step["with"]
+ for job in config["jobs"].values()
+ for step in job["steps"]
+ if step.get("uses", "").startswith("actions/checkout@")
+ ]
+ assert checkouts
+ for checkout in checkouts:
+ assert checkout["ref"] == "${{ github.sha }}"
+ assert checkout.get("repository", "${{ github.repository }}") == (
+ "${{ github.repository }}"
+ )
+
+
@pytest.mark.parametrize("conflicting_tag", [False, True])
def test_ci_tag_fetch_uses_only_canonical_tags(tmp_path, conflicting_tag):
upstream = tmp_path / "upstream.git"