diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index a2a3e29e..62528028 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -98,9 +98,14 @@ jobs: invoke release --dry-run - name: Benchmark if: github.event_name == 'pull_request' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Github pull request event has the merge commit as the HEAD on checkout + # https://github.com/actions/checkout/issues/261 + COMMIT_SHA: ${{ github.event.after }} run: | . $VENV/bin/activate - invoke benchmark + invoke benchmark --report release: name: Release runs-on: ubuntu-latest @@ -137,6 +142,7 @@ jobs: - name: Benchmark env: GH_TOKEN: ${{ secrets.TOPHAT_BOT_GH_TOKEN }} + COMMIT_SHA: ${{ env.GITHUB_SHA }} run: | . $VENV/bin/activate invoke benchmark --report diff --git a/benchmarks/__init__.py b/benchmarks/__init__.py index 97f587de..16bafbe0 100644 --- a/benchmarks/__init__.py +++ b/benchmarks/__init__.py @@ -45,7 +45,7 @@ def get_commit(github: "Github") -> "Commit": """ Get current commit the github ci run is for """ - github_sha = get_req_env("GITHUB_SHA") + github_sha = get_req_env("COMMIT_SHA") return github.get_repo(GH_REPO).get_commit(github_sha) @@ -63,7 +63,7 @@ def get_target_url() -> str: """ repo_url = f"https://github.com/{GH_REPO}" all_results_url = f"{repo_url}/tree/{GH_BENCH_BRANCH}/{GH_BENCH_FILE_PATH}" - commit_sha = get_req_env("GITHUB_SHA") + commit_sha = get_req_env("COMMIT_SHA") return all_results_url + (f"/{commit_sha}" if commit_sha else "") @@ -102,7 +102,7 @@ def measure_perf( if not github: return repo = github.get_repo(GH_REPO) - commit_sha = get_req_env("GITHUB_SHA") + commit_sha = get_req_env("COMMIT_SHA") with open(BENCH_PERF_FILE, "r", encoding="utf-8") as bench_file: try: repo.create_file(