Skip to content

Commit 0948a46

Browse files
authored
Merge pull request #482 from lincc-frameworks/issue/477/fix-asv-failures
Fix asv failures and upgrade its default version
2 parents 9409cac + 12b42b9 commit 0948a46

File tree

4 files changed

+118
-188
lines changed

4 files changed

+118
-188
lines changed

python-project-template/.github/workflows/{% if include_benchmarks %}asv-main.yml{% endif %}.jinja

Lines changed: 45 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# This workflow will run benchmarks with airspeed velocity (asv),
33
# store the new results in the "benchmarks" branch and publish them
44
# to a dashboard on GH Pages.
5-
65
name: Run ASV benchmarks for main
76

87
on:
@@ -11,93 +10,61 @@ on:
1110

1211
env:
1312
PYTHON_VERSION: "3.10"
14-
WORKING_DIR: ${{ github.workspace }}/benchmarks
13+
ASV_VERSION: "0.6.4"
14+
WORKING_DIR: ${{github.workspace}}/benchmarks
1515

1616
concurrency:
17-
group: ${{ github.workflow }}-${{ github.ref }}
17+
group: ${{github.workflow}}-${{github.ref}}
1818
cancel-in-progress: true
1919

2020
jobs:
21-
22-
setup-python:
23-
runs-on: ubuntu-latest
24-
25-
steps:
26-
- name: Cache Python ${{ env.PYTHON_VERSION }}
27-
uses: actions/cache@v4
28-
with:
29-
path: ~/.cache/pip
30-
key: python-${{ env.PYTHON_VERSION }}
31-
32-
- name: Set up Python ${{ env.PYTHON_VERSION }}
33-
uses: actions/setup-python@v5
34-
with:
35-
python-version: "${{ env.PYTHON_VERSION }}"
36-
3721
asv-main:
3822
runs-on: ubuntu-latest
39-
needs: setup-python
40-
4123
permissions:
4224
contents: write
43-
4425
defaults:
4526
run:
46-
working-directory: ${{ env.WORKING_DIR }}
47-
27+
working-directory: ${{env.WORKING_DIR}}
4828
steps:
49-
- name: Checkout main branch of the repository
50-
uses: actions/checkout@v4
51-
with:
52-
fetch-depth: 0
53-
54-
- name: Cache Python ${{ env.PYTHON_VERSION }}
55-
uses: actions/cache@v4
56-
with:
57-
path: ~/.cache/pip
58-
key: python-${{ env.PYTHON_VERSION }}
59-
60-
- name: Install dependencies
61-
run: |
62-
sudo apt-get update
63-
python -m pip install --upgrade pip
64-
pip install asv==0.6.1 virtualenv tabulate
65-
66-
- name: Configure git
67-
run: |
68-
git config user.name "github-actions[bot]"
69-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
70-
71-
- name: Create ASV machine config file
72-
run: asv machine --machine gh-runner --yes
73-
74-
- name: Fetch previous results from the "benchmarks" branch
75-
run: |
76-
if git ls-remote --exit-code origin benchmarks > /dev/null 2>&1; then
77-
git merge origin/benchmarks \
78-
--allow-unrelated-histories \
79-
--no-commit
80-
mv ../_results .
81-
fi
82-
83-
- name: Run ASV for the main branch
84-
run: asv run ALL --skip-existing --verbose || true
85-
86-
- name: Submit new results to the "benchmarks" branch
87-
uses: JamesIves/github-pages-deploy-action@v4
88-
with:
89-
branch: benchmarks
90-
folder: ${{ env.WORKING_DIR }}/_results
91-
target-folder: _results
92-
93-
- name: Generate dashboard HTML
94-
run: |
95-
asv show
96-
asv publish
97-
98-
- name: Deploy to Github pages
99-
uses: JamesIves/github-pages-deploy-action@v4
100-
with:
101-
branch: gh-pages
102-
folder: ${{ env.WORKING_DIR }}/_html
29+
- name: Set up Python ${{env.PYTHON_VERSION}}
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{env.PYTHON_VERSION}}
33+
- name: Checkout main branch of the repository
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
- name: Install dependencies
38+
run: pip install "asv[virtualenv]==${{env.ASV_VERSION}}"
39+
- name: Configure git
40+
run: |
41+
git config user.name "github-actions[bot]"
42+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
43+
- name: Create ASV machine config file
44+
run: asv machine --machine gh-runner --yes
45+
- name: Fetch previous results from the "benchmarks" branch
46+
run: |
47+
if git ls-remote --exit-code origin benchmarks > /dev/null 2>&1; then
48+
git merge origin/benchmarks \
49+
--allow-unrelated-histories \
50+
--no-commit
51+
mv ../_results .
52+
fi
53+
- name: Run ASV for the main branch
54+
run: asv run ALL --skip-existing --verbose || true
55+
- name: Submit new results to the "benchmarks" branch
56+
uses: JamesIves/github-pages-deploy-action@v4
57+
with:
58+
branch: benchmarks
59+
folder: ${{env.WORKING_DIR}}/_results
60+
target-folder: _results
61+
- name: Generate dashboard HTML
62+
run: |
63+
asv show
64+
asv publish
65+
- name: Deploy to Github pages
66+
uses: JamesIves/github-pages-deploy-action@v4
67+
with:
68+
branch: gh-pages
69+
folder: ${{env.WORKING_DIR}}/_html
10370
{%- endraw -%}

python-project-template/.github/workflows/{% if include_benchmarks %}asv-nightly.yml{% endif %}.jinja

Lines changed: 52 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# This workflow will run daily at 06:45.
33
# It will run benchmarks with airspeed velocity (asv)
44
# and compare performance with the previous nightly build.
5-
65
name: Run benchmarks nightly job
76

87
on:
@@ -12,84 +11,64 @@ on:
1211

1312
env:
1413
PYTHON_VERSION: "3.10"
15-
WORKING_DIR: ${{ github.workspace }}/benchmarks
14+
ASV_VERSION: "0.6.4"
15+
WORKING_DIR: ${{github.workspace}}/benchmarks
1616
NIGHTLY_HASH_FILE: nightly-hash
1717

1818
jobs:
19-
2019
asv-nightly:
2120
runs-on: ubuntu-latest
22-
2321
defaults:
2422
run:
25-
working-directory: ${{ env.WORKING_DIR }}
26-
23+
working-directory: ${{env.WORKING_DIR}}
2724
steps:
28-
- name: Checkout main branch of the repository
29-
uses: actions/checkout@v4
30-
with:
31-
fetch-depth: 0
32-
33-
- name: Cache Python ${{ env.PYTHON_VERSION }}
34-
uses: actions/cache@v4
35-
with:
36-
path: ~/.cache/pip
37-
key: python-${{ env.PYTHON_VERSION }}
38-
39-
- name: Set up Python ${{ env.PYTHON_VERSION }}
40-
uses: actions/setup-python@v5
41-
with:
42-
python-version: "${{ env.PYTHON_VERSION }}"
43-
44-
- name: Install dependencies
45-
run: |
46-
sudo apt-get update
47-
python -m pip install --upgrade pip
48-
pip install asv==0.6.1 virtualenv
49-
50-
- name: Configure git
51-
run: |
52-
git config user.name "github-actions[bot]"
53-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
54-
55-
- name: Create ASV machine config file
56-
run: asv machine --machine gh-runner --yes
57-
58-
- name: Fetch previous results from the "benchmarks" branch
59-
run: |
60-
if git ls-remote --exit-code origin benchmarks > /dev/null 2>&1; then
61-
git merge origin/benchmarks \
62-
--allow-unrelated-histories \
63-
--no-commit
64-
mv ../_results .
65-
fi
66-
67-
- name: Get nightly dates under comparison
68-
id: nightly-dates
69-
run: |
70-
echo "yesterday=$(date -d yesterday +'%Y-%m-%d')" >> $GITHUB_OUTPUT
71-
echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
72-
73-
- name: Use last nightly commit hash from cache
74-
uses: actions/cache@v4
75-
with:
76-
path: ${{ env.WORKING_DIR }}
77-
key: nightly-results-${{ steps.nightly-dates.outputs.yesterday }}
78-
79-
- name: Run comparison of main against last nightly build
80-
run: |
81-
HASH_FILE=${{ env.NIGHTLY_HASH_FILE }}
82-
CURRENT_HASH=${{ github.sha }}
83-
if [ -f $HASH_FILE ]; then
84-
PREV_HASH=$(cat $HASH_FILE)
85-
asv continuous $PREV_HASH $CURRENT_HASH --verbose || true
86-
asv compare $PREV_HASH $CURRENT_HASH --sort ratio --verbose
87-
fi
88-
echo $CURRENT_HASH > $HASH_FILE
89-
90-
- name: Update last nightly hash in cache
91-
uses: actions/cache@v4
92-
with:
93-
path: ${{ env.WORKING_DIR }}
94-
key: nightly-results-${{ steps.nightly-dates.outputs.today }}
25+
- name: Set up Python ${{env.PYTHON_VERSION}}
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: ${{env.PYTHON_VERSION}}
29+
- name: Checkout main branch of the repository
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
- name: Install dependencies
34+
run: pip install "asv[virtualenv]==${{env.ASV_VERSION}}"
35+
- name: Configure git
36+
run: |
37+
git config user.name "github-actions[bot]"
38+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
39+
- name: Create ASV machine config file
40+
run: asv machine --machine gh-runner --yes
41+
- name: Fetch previous results from the "benchmarks" branch
42+
run: |
43+
if git ls-remote --exit-code origin benchmarks > /dev/null 2>&1; then
44+
git merge origin/benchmarks \
45+
--allow-unrelated-histories \
46+
--no-commit
47+
mv ../_results .
48+
fi
49+
- name: Get nightly dates under comparison
50+
id: nightly-dates
51+
run: |
52+
echo "yesterday=$(date -d yesterday +'%Y-%m-%d')" >> $GITHUB_OUTPUT
53+
echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
54+
- name: Use last nightly commit hash from cache
55+
uses: actions/cache@v4
56+
with:
57+
path: ${{env.WORKING_DIR}}
58+
key: nightly-results-${{steps.nightly-dates.outputs.yesterday}}
59+
- name: Run comparison of main against last nightly build
60+
run: |
61+
HASH_FILE=${{env.NIGHTLY_HASH_FILE}}
62+
CURRENT_HASH=${{github.sha}}
63+
if [ -f $HASH_FILE ]; then
64+
PREV_HASH=$(cat $HASH_FILE)
65+
asv continuous $PREV_HASH $CURRENT_HASH --verbose || true
66+
asv compare $PREV_HASH $CURRENT_HASH --sort ratio --verbose
67+
fi
68+
echo $CURRENT_HASH > $HASH_FILE
69+
- name: Update last nightly hash in cache
70+
uses: actions/cache@v4
71+
with:
72+
path: ${{env.WORKING_DIR}}
73+
key: nightly-results-${{steps.nightly-dates.outputs.today}}
9574
{%- endraw -%}

python-project-template/.github/workflows/{% if include_benchmarks %}asv-pr.yml{% endif %}.jinja

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,77 +12,61 @@ on:
1212
workflow_dispatch:
1313

1414
concurrency:
15-
group: ${{ github.workflow }}-${{ github.ref }}
15+
group: ${{github.workflow}}-${{github.ref}}
1616
cancel-in-progress: true
1717

1818
env:
1919
PYTHON_VERSION: "3.10"
20-
WORKING_DIR: ${{ github.workspace }}/benchmarks
21-
ARTIFACTS_DIR: ${{ github.workspace }}/artifacts
20+
ASV_VERSION: "0.6.4"
21+
WORKING_DIR: ${{github.workspace}}/benchmarks
22+
ARTIFACTS_DIR: ${{github.workspace}}/artifacts
2223

2324
jobs:
24-
setup-python:
25-
runs-on: ubuntu-latest
26-
steps:
27-
- name: Cache Python ${{ env.PYTHON_VERSION }}
28-
uses: actions/cache@v4
29-
with:
30-
path: ~/.cache/pip
31-
key: python-${{ env.PYTHON_VERSION }}
32-
- name: Set up Python ${{ env.PYTHON_VERSION }}
33-
uses: actions/setup-python@v5
34-
with:
35-
python-version: ${{ env.PYTHON_VERSION }}
3625
asv-pr:
3726
runs-on: ubuntu-latest
38-
needs: setup-python
3927
defaults:
4028
run:
41-
working-directory: ${{ env.WORKING_DIR }}
29+
working-directory: ${{env.WORKING_DIR}}
4230
steps:
31+
- name: Set up Python ${{env.PYTHON_VERSION}}
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: ${{env.PYTHON_VERSION}}
4335
- name: Checkout PR branch of the repository
4436
uses: actions/checkout@v4
4537
with:
4638
fetch-depth: 0
4739
- name: Display Workflow Run Information
4840
run: |
49-
echo "Workflow Run ID: ${{ github.run_id }}"
50-
- name: Cache Python ${{ env.PYTHON_VERSION }}
51-
uses: actions/cache@v4
52-
with:
53-
path: ~/.cache/pip
54-
key: python-${{ env.PYTHON_VERSION }}
41+
echo "Workflow Run ID: ${{github.run_id}}"
5542
- name: Install dependencies
56-
run: |
57-
sudo apt-get update
58-
python -m pip install --upgrade pip
59-
pip install asv==0.6.1 virtualenv tabulate lf-asv-formatter
43+
run: pip install "asv[virtualenv]==${{env.ASV_VERSION}}" lf-asv-formatter
6044
- name: Make artifacts directory
61-
run: mkdir -p ${{ env.ARTIFACTS_DIR }}
45+
run: mkdir -p ${{env.ARTIFACTS_DIR}}
6246
- name: Save pull request number
63-
run: echo ${{ github.event.pull_request.number }} > ${{ env.ARTIFACTS_DIR }}/pr
47+
run: echo ${{github.event.pull_request.number}} > ${{env.ARTIFACTS_DIR}}/pr
6448
- name: Get current job logs URL
6549
uses: Tiryoh/gha-jobid-action@v1
6650
id: jobs
6751
with:
68-
github_token: ${{ secrets.GITHUB_TOKEN }}
69-
job_name: ${{ github.job }}
52+
github_token: ${{secrets.GITHUB_TOKEN}}
53+
job_name: ${{github.job}}
7054
- name: Create ASV machine config file
7155
run: asv machine --machine gh-runner --yes
7256
- name: Save comparison of PR against main branch
7357
run: |
74-
git remote add upstream https://github.com/${{ github.repository }}.git
58+
git remote add upstream https://github.com/${{github.repository}}.git
7559
git fetch upstream
7660
asv continuous upstream/main HEAD --verbose || true
7761
asv compare upstream/main HEAD --sort ratio --verbose | tee output
78-
python -m lf_asv_formatter --asv_version "$(echo asv --version)"
62+
python -m lf_asv_formatter --asv_version "$(asv --version | awk '{print $2}')"
7963
printf "\n\nClick [here]($STEP_URL) to view all benchmarks." >> output
80-
mv output ${{ env.ARTIFACTS_DIR }}
64+
mv output ${{env.ARTIFACTS_DIR}}
8165
env:
82-
STEP_URL: "${{ steps.jobs.outputs.html_url }}#step:11:1"
66+
STEP_URL: ${{steps.jobs.outputs.html_url}}#step:10:1
8367
- name: Upload artifacts (PR number and benchmarks output)
8468
uses: actions/upload-artifact@v4
8569
with:
8670
name: benchmark-artifacts
87-
path: ${{ env.ARTIFACTS_DIR }}
71+
path: ${{env.ARTIFACTS_DIR}}
8872
{%- endraw -%}

0 commit comments

Comments
 (0)