Skip to content

Commit ecd8957

Browse files
authored
Create workflow Kani Extra for checks that run conditionally on labels (rust-lang#2837)
The "Auto Label" workflow correctly label our PRs; however, this action do not trigger a PR 'labeled' workflow. To automatically do that, we now changed the CI structure to have a new workflow with extra jobs that are conditional to labels and files being modified. This new workflow starts by triggering the auto-label job. The benchmark workflow is only triggered if after the auto-label job, the PR has a Z-BenchCI label. This also means that the benchmark workflow will now run after any update to a PR that has the 'Z-BenchCI' label. Resolves rust-lang#2606
1 parent 9f0a289 commit ecd8957

File tree

3 files changed

+57
-39
lines changed

3 files changed

+57
-39
lines changed

.github/workflows/bench.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
# Copyright Kani Contributors
22
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
#
4+
# Run performance benchmarks comparing two different Kani versions.
5+
# This workflow takes much longer than other workflows, so we don't run it by default.
6+
# This workflow will run when:
7+
# - Changes are pushed to 'main'.
8+
# - Triggered by another workflow
39
name: Kani Performance Benchmarks
410
on:
511
push:
612
branches:
713
- 'main'
8-
pull_request:
9-
types:
10-
- labeled
14+
workflow_call:
1115

1216
jobs:
1317
perf-benchcomp:
14-
if: ${{ github.event_name == 'push'
15-
|| (github.event_name == 'pull_request'
16-
&& github.event.action == 'labeled'
17-
&& github.event.label.name == 'Z-BenchCI')
18-
}}
1918
runs-on: ubuntu-20.04
2019
steps:
2120
- name: Save push event HEAD and HEAD~ to environment variables
@@ -25,7 +24,7 @@ jobs:
2524
echo "OLD_REF=${{ github.event.before }}" | tee -a "$GITHUB_ENV"
2625
2726
- name: Save pull request HEAD and base to environment variables
28-
if: ${{ github.event_name == 'pull_request' }}
27+
if: ${{ contains(fromJSON('["pull_request", "pull_request_target"]'), github.event_name) }}
2928
run: |
3029
echo "OLD_REF=${{ github.event.pull_request.base.sha }}" | tee -a "$GITHUB_ENV"
3130
echo "NEW_REF=${{ github.event.pull_request.head.sha }}" | tee -a "$GITHUB_ENV"

.github/workflows/extra_jobs.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
#
4+
# Workflow that execute jobs based on the files that were changed or some label configuration.
5+
#
6+
# The first job in this workflow will auto label the PR, while the following jobs will conditionally
7+
# run according to the auto-label result.
8+
#
9+
# This workflow runs on `pull_request_target` because the labeler needs extra write permission.
10+
# Thus, we keep this job minimal, and the only actions used are from the same verified publisher.
11+
#
12+
# Other jobs should not require extra permissions, so be careful when adding new jobs to not propagate write
13+
# permissions.
14+
#
15+
# Note that this also means that the workflow version run is the one currently in `main`,
16+
# not the one from the PR. This is only relevant if a PR is changing this workflow.
17+
#
18+
# See <https://github.com/actions/labeler/issues/121> for more details.
19+
20+
name: Kani Extra
21+
on: pull_request_target
22+
23+
jobs:
24+
# Keep this job minimal since it requires extra permission
25+
auto-label:
26+
name: Auto Label
27+
permissions:
28+
contents: read
29+
pull-requests: write
30+
outputs:
31+
all-labels: ${{ steps.labeler.outputs.all-labels }}
32+
new-labels: ${{ steps.labeler.outputs.new-labels }}
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout Kani
36+
uses: actions/checkout@v3
37+
38+
- name: Label PR
39+
id: labeler
40+
uses: actions/labeler@v4
41+
with:
42+
dot: true
43+
44+
verification-bench:
45+
name: Verification Benchmarks
46+
needs: auto-label
47+
permissions: {}
48+
if: contains(needs.auto-label.outputs.all-labels, 'Z-BenchCI')
49+
uses: ./.github/workflows/bench.yml

.github/workflows/labeler.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)