More tweaks to CI pipeline (#41941)

Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Conrad Irwin
2025-11-04 16:28:29 -07:00
committed by GitHub
parent 4339c772e4
commit 1b2e38bb33
7 changed files with 128 additions and 36 deletions
@@ -3,31 +3,57 @@ use gh_workflow::*;
use crate::tasks::workflows::{
runners,
steps::{self, NamedJob, named},
vars::Input,
vars::{self, Input, StepOutput},
};
pub fn cherry_pick() -> Workflow {
let branch = Input::string("branch", None);
let commit = Input::string("commit", None);
let cherry_pick = run_cherry_pick(&branch, &commit);
let channel = Input::string("channel", None);
let cherry_pick = run_cherry_pick(&branch, &commit, &channel);
named::workflow()
.on(Event::default().workflow_dispatch(
WorkflowDispatch::default()
.add_input(commit.name, commit.input())
.add_input(branch.name, branch.input()),
.add_input(branch.name, branch.input())
.add_input(channel.name, channel.input()),
))
.add_job(cherry_pick.name, cherry_pick.job)
}
fn run_cherry_pick(branch: &Input, commit: &Input) -> NamedJob {
fn cherry_pick(branch: &str, commit: &str) -> Step<Run> {
named::bash(&format!("./scripts/cherry-pick {branch} {commit}"))
fn run_cherry_pick(branch: &Input, commit: &Input, channel: &Input) -> NamedJob {
fn authenticate_as_zippy() -> (Step<Use>, StepOutput) {
let step = named::uses(
"actions",
"create-github-app-token",
"bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1",
) // v2
.add_with(("app-id", vars::ZED_ZIPPY_APP_ID))
.add_with(("private-key", vars::ZED_ZIPPY_APP_PRIVATE_KEY))
.id("get-app-token");
let output = StepOutput::new(&step, "token");
(step, output)
}
fn cherry_pick(
branch: &Input,
commit: &Input,
channel: &Input,
token: &StepOutput,
) -> Step<Run> {
named::bash(&format!("./script/cherry-pick {branch} {commit} {channel}"))
.add_env(("GIT_COMMITTER_NAME", "Zed Zippy"))
.add_env(("GIT_COMMITTER_EMAIL", "hi@zed.dev"))
.add_env(("GITHUB_TOKEN", token))
}
let (authenticate, token) = authenticate_as_zippy();
named::job(
Job::default()
.runs_on(runners::LINUX_SMALL)
.add_step(steps::checkout_repo())
.add_step(cherry_pick(&branch.var(), &commit.var())),
.add_step(authenticate)
.add_step(cherry_pick(branch, commit, channel, &token)),
)
}
@@ -11,28 +11,35 @@ use crate::tasks::workflows::{
pub fn compare_perf() -> Workflow {
let head = Input::string("head", None);
let base = Input::string("base", None);
let run_perf = run_perf(&base, &head);
let crate_name = Input::string("crate_name", Some("".to_owned()));
let run_perf = run_perf(&base, &head, &crate_name);
named::workflow()
.on(Event::default().workflow_dispatch(
WorkflowDispatch::default()
.add_input(head.name, head.input())
.add_input(base.name, base.input()),
.add_input(base.name, base.input())
.add_input(crate_name.name, crate_name.input()),
))
.add_job(run_perf.name, run_perf.job)
}
pub fn run_perf(base: &Input, head: &Input) -> NamedJob {
fn cargo_perf_test(ref_name: String) -> Step<Run> {
// TODO: vim not gpui, and ideally allow args
named::bash(&format!("cargo perf-test -p gpui -- --json={ref_name}"))
pub fn run_perf(base: &Input, head: &Input, crate_name: &Input) -> NamedJob {
fn cargo_perf_test(ref_name: &Input, crate_name: &Input) -> Step<Run> {
named::bash(&format!(
"
if [ -n \"{crate_name}\" ]; then
cargo perf-test -p {crate_name} -- --json={ref_name};
else
cargo perf-test -p vim -- --json={ref_name};
fi"
))
}
fn install_hyperfine() -> Step<Run> {
named::bash("cargo install hyperfine")
}
fn compare_runs(head: String, base: String) -> Step<Run> {
// TODO: this should really be swapped...
fn compare_runs(head: &Input, base: &Input) -> Step<Run> {
named::bash(&format!(
"cargo perf-compare --save=results.md {base} {head}"
))
@@ -45,11 +52,11 @@ pub fn run_perf(base: &Input, head: &Input) -> NamedJob {
.add_step(steps::setup_cargo_config(runners::Platform::Linux))
.map(steps::install_linux_dependencies)
.add_step(install_hyperfine())
.add_step(steps::git_checkout(&base.var()))
.add_step(cargo_perf_test(base.var()))
.add_step(steps::git_checkout(&head.var()))
.add_step(cargo_perf_test(head.var()))
.add_step(compare_runs(head.var(), base.var()))
.add_step(steps::git_checkout(base))
.add_step(cargo_perf_test(base, crate_name))
.add_step(steps::git_checkout(head))
.add_step(cargo_perf_test(head, crate_name))
.add_step(compare_runs(head, base))
.add_step(upload_artifact("results.md"))
.add_step(steps::cleanup_cargo_config(runners::Platform::Linux)),
)
+1 -1
View File
@@ -299,7 +299,7 @@ pub(crate) mod named {
}
}
pub fn git_checkout(ref_name: &str) -> Step<Run> {
pub fn git_checkout(ref_name: &dyn std::fmt::Display) -> Step<Run> {
named::bash(&format!(
"git fetch origin {ref_name} && git checkout {ref_name}"
))
+33 -5
View File
@@ -1,6 +1,6 @@
use std::cell::RefCell;
use gh_workflow::{Concurrency, Env, Expression, WorkflowDispatchInput};
use gh_workflow::{Concurrency, Env, Expression, Step, WorkflowDispatchInput};
use crate::tasks::workflows::{runners::Platform, steps::NamedJob};
@@ -34,6 +34,8 @@ secret!(ZED_CLIENT_CHECKSUM_SEED);
secret!(ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON);
secret!(ZED_SENTRY_MINIDUMP_ENDPOINT);
secret!(SLACK_APP_ZED_UNIT_EVALS_BOT_TOKEN);
secret!(ZED_ZIPPY_APP_ID);
secret!(ZED_ZIPPY_APP_PRIVATE_KEY);
// todo(ci) make these secrets too...
var!(AZURE_SIGNING_ACCOUNT_NAME);
@@ -116,6 +118,30 @@ impl PathCondition {
}
}
pub(crate) struct StepOutput {
name: &'static str,
step_id: String,
}
impl StepOutput {
pub fn new<T>(step: &Step<T>, name: &'static str) -> Self {
Self {
name,
step_id: step
.value
.id
.clone()
.expect("Steps that produce outputs must have an ID"),
}
}
}
impl std::fmt::Display for StepOutput {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "${{{{ steps.{}.outputs.{} }}}}", self.step_id, self.name)
}
}
pub(crate) struct Input {
pub input_type: &'static str,
pub name: &'static str,
@@ -131,10 +157,6 @@ impl Input {
}
}
pub fn var(&self) -> String {
format!("${{{{ inputs.{} }}}}", self.name)
}
pub fn input(&self) -> WorkflowDispatchInput {
WorkflowDispatchInput {
description: self.name.to_owned(),
@@ -145,6 +167,12 @@ impl Input {
}
}
impl std::fmt::Display for Input {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "${{{{ inputs.{} }}}}", self.name)
}
}
pub mod assets {
// NOTE: these asset names also exist in the zed.dev codebase.
pub const MAC_AARCH64: &str = "Zed-aarch64.dmg";