Skip to content

Commit 0d9700f

Browse files
CI: Restore prev ASV results before saving new ones
1 parent e8e489d commit 0d9700f

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

.github/workflows/main.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,18 @@ jobs:
127127
contents: write # gh-pages publishing
128128

129129
steps:
130+
# checkout code
130131
- uses: actions/checkout@v4
131132
with:
132133
fetch-depth: 0 # ASV history
133134

135+
# Get Python
134136
- name: Set up Python ${{ matrix.python-version }}
135137
uses: actions/setup-python@v4
136138
with:
137139
python-version: ${{ matrix.python-version }}
138140

141+
# Restore environment if it's cached
139142
- name: Cache pip
140143
uses: actions/cache@v4
141144
with:
@@ -144,12 +147,14 @@ jobs:
144147
restore-keys: |
145148
${{ runner.os }}-pip-
146149
150+
# Otherwise, restore environment
147151
- name: Install dependencies
148152
run: |
149153
pip install --upgrade pip
150154
pip install .[dev]
151155
pip install asv
152156
157+
# Restore any cached ASV environments
153158
- name: Cache ASV environments
154159
uses: actions/cache@v4
155160
with:
@@ -158,28 +163,57 @@ jobs:
158163
restore-keys: |
159164
asv-${{ runner.os }}-py${{ matrix.python-version }}-
160165
166+
# Detect machine information for benchmarks
161167
- name: Setup ASV machine
162168
run: |
163169
cd asv_bench
164170
asv machine --yes
165171
172+
# Check regressions of any benchmarks
166173
- name: Check regression
167174
if: github.event_name == 'pull_request'
168175
run: |
169176
cd asv_bench
170177
git fetch origin $GITHUB_BASE_REF:base $GITHUB_REF:pr
171178
asv continuous base pr -e
172179
180+
# This whole second section should be a separate workflow, triggered by
181+
# commit to main, not PRs
182+
# Checkout gh-pages into a side folder (if it exists)
183+
- uses: actions/checkout@v4
184+
continue-on-error: true
185+
with:
186+
ref: gh-pages
187+
path: gh-pages
188+
189+
# Restore historical ASV results into workspace
190+
- name: Restore ASV history
191+
run: |
192+
mkdir -p asv_bench/.asv/results
193+
if [ -d gh-pages/.asv/results ]; then
194+
rsync -a gh-pages/.asv/results/ asv_bench/.asv/results/
195+
fi
196+
197+
# Generate website benchmark results for new commits
173198
- name: Run benchmarks on main
174199
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
175200
run: |
176201
cd asv_bench
177-
asv run
202+
asv run --skip-existing-successful
178203
asv publish
204+
205+
# Stage site payload: html + updated results
206+
- name: Prepare Pages payload
207+
run: |
208+
rm -rf pages && mkdir -p pages/.asv
209+
rsync -a asv_bench/.asv/html/ pages/
210+
rsync -a asv_bench/.asv/results/ pages/.asv/results/
211+
212+
# Deploy
179213
- name: Deploy ASV dashboard to gh-pages
180214
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
181215
uses: peaceiris/actions-gh-pages@v4
182216
with:
183217
github_token: ${{ secrets.GITHUB_TOKEN }}
184218
publish_dir: asv_bench/.asv/html
185-
force_orphan: true
219+
force_orphan: false

0 commit comments

Comments
 (0)