Skip to content

Commit 499b87e

Browse files
CopilotbenhillisBen Hillis
authored
ci: add label-based trigger for release PR gates workflow with draft protection (#1887)
This change adds the ability to easily queue the release version of PR gates using GitHub labels, while preserving the original draft PR protection behavior. ## Problem The OpenVMM repository has a release version of PR gates (`openvmm-pr-release.yaml`) that runs the same checks as regular PR gates but compiled in release mode. This workflow was only triggerable manually via `workflow_dispatch`, making it cumbersome for maintainers to queue when needed. ## Solution Added label-based triggering to the release PR gates workflow with proper safeguards. Now maintainers can simply add the `run-release-gates` label to any non-draft PR to automatically trigger the release version of the gates. ## Changes ### Workflow Triggers The release PR workflow now responds to: - **Manual trigger**: `workflow_dispatch` (preserved for backward compatibility) - **Label trigger**: `pull_request` with `types: [labeled]` on main and release branches ### Conditional Execution All jobs include a condition to only run when both requirements are met: ```yaml if: contains(github.event.pull_request.labels.*.name, 'run-release-gates') && github.event.pull_request.draft == false ``` ### Draft Protection Unlike the initial implementation, this preserves the original draft PR gating behavior. The workflow will only run when: - The specific `run-release-gates` label is present **AND** - The PR is not in draft status ### Code Changes - Modified `flowey/flowey_hvlite/src/pipelines/checkin_gates.rs` to add PR triggers for the `PrRelease` configuration - Added conditional logic using `gh_dangerous_override_if` to check for both the required label and draft status - Updated documentation in the coding conventions guide ## Usage 1. Developer creates a PR 2. Maintainer adds the `run-release-gates` label when release testing is needed 3. GitHub automatically triggers the release gates workflow (only if PR is not draft) 4. All tests run in release mode and report results back to the PR ## Technical Notes The implementation uses GitHub's standard approach for label-based triggering (`types: [labeled]` + job-level filtering) as GitHub Actions doesn't provide a way to trigger workflows on specific labels directly. This is the same pattern used by major open-source projects and follows GitHub's documented best practices. ## Benefits - **Easy to use**: Simple one-click label addition - **Controlled access**: Only maintainers can add labels to PRs - **Automatic**: No need to manually navigate to GitHub Actions - **Selective**: Only runs when specifically requested - **Protected**: Maintains draft PR protection behavior - **Efficient**: Workflow starts for any label but immediately skips jobs if conditions aren't met - **Backward compatible**: Manual trigger still works, regular PR workflow unchanged Fixes #1560. <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/openvmm/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: benhillis <[email protected]> Co-authored-by: Ben Hillis <[email protected]>
1 parent af84210 commit 499b87e

File tree

3 files changed

+83
-25
lines changed

3 files changed

+83
-25
lines changed

.github/workflows/openvmm-pr-release.yaml

Lines changed: 27 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Guide/src/dev_guide/contrib/code.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,38 @@ goes more in-depth as to why.
443443

444444
Instead, name things based on what they logically provide, like functionality or
445445
data types.
446+
447+
## Release Gates Workflow
448+
449+
_Triggered Manually:_ **Yes** (via GitHub labels)
450+
451+
In addition to the standard PR gates that run in debug mode, OpenVMM also provides
452+
a "Release Gates" workflow that runs the same checks but compiled in release mode.
453+
This workflow takes significantly longer to run but can catch issues that only
454+
manifest in optimized builds.
455+
456+
### When to Use Release Gates
457+
458+
The release gates workflow should be used when:
459+
460+
- Making changes to performance-critical code paths
461+
- Modifying compiler flags or build configuration
462+
- Implementing low-level optimizations
463+
- Debugging issues that only appear in release builds
464+
- Before merging large refactoring changes
465+
466+
### How to Trigger Release Gates
467+
468+
To run the release gates on your PR:
469+
470+
1. Ensure your PR is ready for review (not in draft mode)
471+
2. Add the `release-ci-required` label to your PR
472+
3. The workflow will automatically trigger and run all checks in release mode
473+
474+
The workflow will only run when the specific label is present, so you have full
475+
control over when to use this more resource-intensive testing.
476+
477+
### Label Management
478+
479+
Only repository maintainers can add labels to PRs. If you need release gates
480+
run on your PR, ask a maintainer to add the `release-ci-required` label for you.

flowey/flowey_hvlite/src/pipelines/checkin_gates.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,15 @@ impl IntoPipeline for CheckinGatesCli {
8585
.gh_set_name("[flowey] OpenVMM PR");
8686
}
8787
PipelineConfig::PrRelease => {
88-
// This workflow is triggered manually.
89-
pipeline.gh_set_name("[flowey] OpenVMM Release PR");
88+
// This workflow is triggered when a specific label is added to a PR.
89+
pipeline
90+
.gh_set_pr_triggers(GhPrTriggers {
91+
branches,
92+
types: vec!["labeled".into()],
93+
auto_cancel: false,
94+
exclude_branches: vec![],
95+
})
96+
.gh_set_name("[flowey] OpenVMM Release PR");
9097
}
9198
}
9299
}
@@ -116,7 +123,8 @@ impl IntoPipeline for CheckinGatesCli {
116123
)?;
117124

118125
pipeline.inject_all_jobs_with(move |job| {
119-
job.dep_on(&cfg_common_params)
126+
let mut job = job
127+
.dep_on(&cfg_common_params)
120128
.dep_on(|_| flowey_lib_hvlite::_jobs::cfg_versions::Request {})
121129
.dep_on(
122130
|_| flowey_lib_hvlite::_jobs::cfg_hvlite_reposource::Params {
@@ -130,7 +138,16 @@ impl IntoPipeline for CheckinGatesCli {
130138
.gh_grant_permissions::<flowey_lib_common::gh_task_azure_login::Node>([(
131139
GhPermission::IdToken,
132140
GhPermissionValue::Write,
133-
)])
141+
)]);
142+
143+
// For the release pipeline, only run if the "release-ci-required" label is present and PR is not draft
144+
if matches!(config, PipelineConfig::PrRelease) {
145+
job = job.gh_dangerous_override_if(
146+
"contains(github.event.pull_request.labels.*.name, 'release-ci-required') && github.event.pull_request.draft == false",
147+
);
148+
}
149+
150+
job
134151
});
135152

136153
let openhcl_musl_target = |arch: CommonArch| -> Triple {

0 commit comments

Comments
 (0)