Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions .github/workflows/run_asvs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
# Results and other data are stored away from the main branch.
# This keeps the main branch clean and allows us to clear out
# objects / history after being built up for long periods of time.
BRANCH_NAME: pandas_20250109
BRANCH_NAME: pandas_20250203

permissions:
contents: read
Expand All @@ -29,7 +29,7 @@ jobs:
contents: write
issues: write
outputs:
new_commit: ${{ steps.new-commit.outputs.new_commit }}
new_commit: ${{ steps.get-commit.outputs.new_commit }}
steps:
# In order to run pandas' actions, we have to checkout into the root directory.
- name: Checkout pandas
Expand All @@ -44,60 +44,62 @@ jobs:
ref: ${{ env.BRANCH_NAME }}
path: asv-runner/

- name: Compare Commit SHAs
id: new-commit
- name: Set up Conda
uses: ./.github/actions/setup-conda

- name: Get Commit
id: get-commit
run: |
if [ "$(git rev-parse HEAD)" = "$(cat asv-runner/data/latest_sha.txt)" ]; then
sha="$(python asv-runner/ci/find_commit_to_run.py --input-path=asv-runner/data/ --repo-path=.)"
echo "sha: $sha"
if [ "$sha" = "NONE" ]; then
echo "new_commit=no"
echo "new_commit=no" >> "$GITHUB_OUTPUT"
else
echo "new_commit=yes"
echo "new_commit=yes" >> "$GITHUB_OUTPUT"
fi
echo "$(git rev-parse HEAD)" > asv-runner/data/latest_sha.txt
echo "$sha" >> asv-runner/data/shas.txt
git checkout $sha

# Prevent another job from kicking off and running on this commit
- name: Update latest_sha.txt
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
- name: Commit shas.txt
if: ${{ steps.get-commit.outputs.new_commit == 'yes' }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update latest SHA
commit_message: Update shas.txt
branch: ${{ env.BRANCH_NAME }}
repository: asv-runner
file_pattern: 'data/latest_sha.txt'

- name: Set up Conda
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
uses: ./.github/actions/setup-conda
file_pattern: 'data/shas.txt'

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

- name: Run ASV Benchmarks
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
if: ${{ steps.get-commit.outputs.new_commit == 'yes' }}
run: |
cd asv_bench
asv machine --machine=asvrunner --yes
asv run --machine=asvrunner --python=same --set-commit-hash=$(git rev-parse HEAD) --show-stderr

- name: Update asv-runner branch
# In case there was a push by another job.
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
if: ${{ steps.get-commit.outputs.new_commit == 'yes' }}
run: |
cd asv-runner
git fetch && git pull

- name: Move results into asv-runner
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
if: ${{ steps.get-commit.outputs.new_commit == 'yes' }}
run: |
mkdir -p asv-runner/data/results/asvrunner/
cp asv_bench/results/benchmarks.json asv-runner/data/results/
cp asv_bench/results/asvrunner/machine.json asv-runner/data/results/asvrunner/
cp asv_bench/results/asvrunner/$(git rev-parse --short=8 HEAD)-existing*.json asv-runner/data/results/asvrunner/
cp asv_bench/results/asvrunner/$(git rev-parse --short=8 HEAD)-existing*.json asv-runner/data/results/asvrunner/$(git rev-parse HEAD).json

- name: Commit results to branch
if: ${{ steps.new-commit.outputs.new_commit == 'yes' }}
if: ${{ steps.get-commit.outputs.new_commit == 'yes' }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Results
Expand Down
43 changes: 43 additions & 0 deletions ci/find_commit_to_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from __future__ import annotations

import argparse
import subprocess
from pathlib import Path


def run(*, input_path: str | Path, repo_path: str | Path):
if isinstance(input_path, str):
input_path = Path(input_path)
if isinstance(repo_path, str):
repo_path = Path(repo_path)

shas_path = input_path / "shas.txt"
existing_shas: set[str]
if not shas_path.exists():
existing_shas = set()
else:
with open(input_path / "shas.txt") as fh:
existing_shas = {line.strip() for line in fh.readlines()}

response = subprocess.run(
f"cd {repo_path} && git log -40 --oneline --no-abbrev-commit",
capture_output=True,
shell=True,
check=False,
)
recent_shas = [
line[: line.find(" ")] for line in response.stdout.decode().strip().split("\n")
]
for sha in recent_shas:
if sha not in existing_shas:
print(sha)
return
print("NONE")


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--input-path")
parser.add_argument("--repo-path")
args = parser.parse_args()
run(input_path=args.input_path, repo_path=args.repo_path)