Skip to content

Commit 98e12c5

Browse files
authored
Use full SHA (#38)
1 parent ad50246 commit 98e12c5

File tree

2 files changed

+65
-20
lines changed

2 files changed

+65
-20
lines changed

.github/workflows/run_asvs.yaml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
# Results and other data are stored away from the main branch.
1414
# This keeps the main branch clean and allows us to clear out
1515
# objects / history after being built up for long periods of time.
16-
BRANCH_NAME: pandas_20250109
16+
BRANCH_NAME: pandas_20250203
1717

1818
permissions:
1919
contents: read
@@ -29,7 +29,7 @@ jobs:
2929
contents: write
3030
issues: write
3131
outputs:
32-
new_commit: ${{ steps.new-commit.outputs.new_commit }}
32+
new_commit: ${{ steps.get-commit.outputs.new_commit }}
3333
steps:
3434
# In order to run pandas' actions, we have to checkout into the root directory.
3535
- name: Checkout pandas
@@ -44,60 +44,62 @@ jobs:
4444
ref: ${{ env.BRANCH_NAME }}
4545
path: asv-runner/
4646

47-
- name: Compare Commit SHAs
48-
id: new-commit
47+
- name: Set up Conda
48+
uses: ./.github/actions/setup-conda
49+
50+
- name: Get Commit
51+
id: get-commit
4952
run: |
50-
if [ "$(git rev-parse HEAD)" = "$(cat asv-runner/data/latest_sha.txt)" ]; then
53+
sha="$(python asv-runner/ci/find_commit_to_run.py --input-path=asv-runner/data/ --repo-path=.)"
54+
echo "sha: $sha"
55+
if [ "$sha" = "NONE" ]; then
5156
echo "new_commit=no"
5257
echo "new_commit=no" >> "$GITHUB_OUTPUT"
5358
else
5459
echo "new_commit=yes"
5560
echo "new_commit=yes" >> "$GITHUB_OUTPUT"
5661
fi
57-
echo "$(git rev-parse HEAD)" > asv-runner/data/latest_sha.txt
62+
echo "$sha" >> asv-runner/data/shas.txt
63+
git checkout $sha
5864
5965
# Prevent another job from kicking off and running on this commit
60-
- name: Update latest_sha.txt
61-
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
66+
- name: Commit shas.txt
67+
if: ${{ steps.get-commit.outputs.new_commit == 'yes' }}
6268
uses: stefanzweifel/git-auto-commit-action@v5
6369
with:
64-
commit_message: Update latest SHA
70+
commit_message: Update shas.txt
6571
branch: ${{ env.BRANCH_NAME }}
6672
repository: asv-runner
67-
file_pattern: 'data/latest_sha.txt'
68-
69-
- name: Set up Conda
70-
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
71-
uses: ./.github/actions/setup-conda
73+
file_pattern: 'data/shas.txt'
7274

7375
- name: Build pandas
74-
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
76+
if: ${{ steps.get-commit.outputs.new_commit == 'yes' }}
7577
uses: ./.github/actions/build_pandas
7678

7779
- name: Run ASV Benchmarks
78-
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
80+
if: ${{ steps.get-commit.outputs.new_commit == 'yes' }}
7981
run: |
8082
cd asv_bench
8183
asv machine --machine=asvrunner --yes
8284
asv run --machine=asvrunner --python=same --set-commit-hash=$(git rev-parse HEAD) --show-stderr
8385
8486
- name: Update asv-runner branch
8587
# In case there was a push by another job.
86-
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
88+
if: ${{ steps.get-commit.outputs.new_commit == 'yes' }}
8789
run: |
8890
cd asv-runner
8991
git fetch && git pull
9092
9193
- name: Move results into asv-runner
92-
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
94+
if: ${{ steps.get-commit.outputs.new_commit == 'yes' }}
9395
run: |
9496
mkdir -p asv-runner/data/results/asvrunner/
9597
cp asv_bench/results/benchmarks.json asv-runner/data/results/
9698
cp asv_bench/results/asvrunner/machine.json asv-runner/data/results/asvrunner/
97-
cp asv_bench/results/asvrunner/$(git rev-parse --short=8 HEAD)-existing*.json asv-runner/data/results/asvrunner/
99+
cp asv_bench/results/asvrunner/$(git rev-parse --short=8 HEAD)-existing*.json asv-runner/data/results/asvrunner/$(git rev-parse HEAD).json
98100
99101
- name: Commit results to branch
100-
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
102+
if: ${{ steps.get-commit.outputs.new_commit == 'yes' }}
101103
uses: stefanzweifel/git-auto-commit-action@v5
102104
with:
103105
commit_message: Results

ci/find_commit_to_run.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from __future__ import annotations
2+
3+
import argparse
4+
import subprocess
5+
from pathlib import Path
6+
7+
8+
def run(*, input_path: str | Path, repo_path: str | Path):
9+
if isinstance(input_path, str):
10+
input_path = Path(input_path)
11+
if isinstance(repo_path, str):
12+
repo_path = Path(repo_path)
13+
14+
shas_path = input_path / "shas.txt"
15+
existing_shas: set[str]
16+
if not shas_path.exists():
17+
existing_shas = set()
18+
else:
19+
with open(input_path / "shas.txt") as fh:
20+
existing_shas = {line.strip() for line in fh.readlines()}
21+
22+
response = subprocess.run(
23+
f"cd {repo_path} && git log -40 --oneline --no-abbrev-commit",
24+
capture_output=True,
25+
shell=True,
26+
check=False,
27+
)
28+
recent_shas = [
29+
line[: line.find(" ")] for line in response.stdout.decode().strip().split("\n")
30+
]
31+
for sha in recent_shas:
32+
if sha not in existing_shas:
33+
print(sha)
34+
return
35+
print("NONE")
36+
37+
38+
if __name__ == "__main__":
39+
parser = argparse.ArgumentParser()
40+
parser.add_argument("--input-path")
41+
parser.add_argument("--repo-path")
42+
args = parser.parse_args()
43+
run(input_path=args.input_path, repo_path=args.repo_path)

0 commit comments

Comments
 (0)