Skip to content

Commit 7141021

Browse files
Run autoharness jobs only in the merge queue (#738)
## Problem Five CI jobs (autoharness, metrics, list, analyzer, build JSON) run on every PR push and take about five runner-hours. Every PR waits on them. #730 asks to run them only before merging. ## Fix Add `if: merge_group || workflow_dispatch` to those five jobs. Autoharness is a required check, so it cannot be skipped as a whole job: a skipped job loses the `(ubuntu-latest)` part of its name and the required check never turns green. So for that job the `if:` is on each step. The job still runs, does nothing, and passes in seconds. ## Testing On my fork, a manual run passed all 16 jobs ([run](https://github.com/Tianshu-Huang/verify-rust-std/actions/runs/40005615582)), and a PR skipped the five jobs with the two autoharness required checks green ([PR](Tianshu-Huang#1)). Did not test `merge_group`. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Felipe R. Monteiro <rms.felipe@gmail.com>
1 parent c0bd09c commit 7141021

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Runs the autoharness and Kani metrics jobs on a PR that has the run-autoharness label, so a
2+
# contributor can see those results before the merge queue (#730). This is a separate workflow
3+
# so that adding a label never starts a new run of kani.yml: GitHub reads required checks from
4+
# the latest run, and a label-only run would leave the partitions "expected".
5+
name: Kani autoharness on request
6+
7+
on:
8+
pull_request:
9+
branches: [ main ]
10+
types: [labeled, synchronize, reopened]
11+
12+
jobs:
13+
autoharness:
14+
if: >-
15+
contains(github.event.pull_request.labels.*.name, 'run-autoharness') &&
16+
(github.event.action != 'labeled' || github.event.label.name == 'run-autoharness')
17+
uses: ./.github/workflows/kani.yml
18+
with:
19+
autoharness: true

‎.github/workflows/kani.yml‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ name: Kani
22

33
on:
44
workflow_dispatch:
5+
# Called by kani-autoharness-request.yml when a PR has the run-autoharness label.
6+
workflow_call:
7+
inputs:
8+
autoharness:
9+
description: Run only the autoharness and metrics jobs
10+
type: boolean
11+
default: false
512
merge_group:
613
pull_request:
714
branches: [ main ]
@@ -18,6 +25,8 @@ defaults:
1825
jobs:
1926
check-kani-on-std:
2027
name: Verify std library (partition ${{ matrix.partition }})
28+
# When called for autoharness only, the partitions already ran for this commit.
29+
if: ${{ !inputs.autoharness }}
2130
runs-on: ${{ matrix.os }}
2231
strategy:
2332
matrix:
@@ -67,6 +76,13 @@ jobs:
6776

6877
kani_autoharness:
6978
name: Verify std library using autoharness
79+
# Autoharness, Metrics, List, Analyzer and Build JSON run only in the merge queue, on
80+
# workflow_dispatch, or on PRs with the run-autoharness label, through
81+
# kani-autoharness-request.yml (#730): they cost about 5
82+
# runner-hours per run and decide how long a PR waits.
83+
# This job is a required check under its matrix name, and a job skipped by a job-level
84+
# `if:` reports without the "(os)" suffix, which would leave PRs pending. So the gate is
85+
# on each step instead: on a PR the job starts, skips every step and passes in seconds.
7086
runs-on: ${{ matrix.os }}
7187
strategy:
7288
matrix:
@@ -80,7 +96,7 @@ jobs:
8096

8197
steps:
8298
- name: Remove unnecessary software to free up disk space
83-
if: matrix.os == 'ubuntu-latest'
99+
if: matrix.os == 'ubuntu-latest' && (github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness)
84100
run: |
85101
# inspired by https://github.com/easimon/maximize-build-space/blob/master/action.yml
86102
df -h
@@ -89,6 +105,7 @@ jobs:
89105
90106
# Step 1: Check out the repository
91107
- name: Checkout Repository
108+
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness
92109
uses: actions/checkout@v4
93110
with:
94111
submodules: true
@@ -107,6 +124,7 @@ jobs:
107124
# Unicode tables were regenerated (nightly-2026-09-25) they exceed the 10m
108125
# timeout on macOS and the ubuntu runner died while verifying them.
109126
- name: Run Kani Verification
127+
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness
110128
run: |
111129
scripts/run-kani.sh --run autoharness --kani-args \
112130
--include-pattern "<(.+)[[:space:]]as[[:space:]](.+)>::disjoint_bitor" \
@@ -219,6 +237,7 @@ jobs:
219237
gzip autoharness-verification.log
220238
221239
- name: Upload Autoharness Verification Log
240+
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness
222241
uses: actions/upload-artifact@v4
223242
with:
224243
name: ${{ matrix.os }}-autoharness-verification.log.gz
@@ -229,6 +248,7 @@ jobs:
229248

230249
run_kani_metrics:
231250
name: Kani Metrics
251+
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness
232252
runs-on: ${{ matrix.os }}
233253
strategy:
234254
matrix:
@@ -299,6 +319,7 @@ jobs:
299319

300320
run-log-analysis:
301321
name: Build JSON from logs
322+
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness
302323
needs: [run_kani_metrics, kani_autoharness]
303324
runs-on: ${{ matrix.os }}
304325
strategy:
@@ -351,6 +372,7 @@ jobs:
351372

352373
run-kani-list:
353374
name: Kani List
375+
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness
354376
runs-on: ubuntu-latest
355377
steps:
356378
- name: Remove unnecessary software to free up disk space
@@ -396,6 +418,7 @@ jobs:
396418
397419
run-autoharness-analyzer:
398420
name: Kani Autoharness Analyzer
421+
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || inputs.autoharness
399422
runs-on: ubuntu-latest
400423
steps:
401424
# Step 1: Check out the repository

0 commit comments

Comments
 (0)