Improve compare_perf.yml, cherry_pick.yml (#41606)
Release Notes: - N/A --------- Co-authored-by: Nia Espera <nia@zed.dev>
This commit is contained in:
co-authored by
Nia Espera
parent
2a2e04bb5c
commit
43a7f96462
@@ -0,0 +1,33 @@
|
||||
use gh_workflow::*;
|
||||
|
||||
use crate::tasks::workflows::{
|
||||
runners,
|
||||
steps::{self, NamedJob, named},
|
||||
vars::Input,
|
||||
};
|
||||
|
||||
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);
|
||||
named::workflow()
|
||||
.on(Event::default().workflow_dispatch(
|
||||
WorkflowDispatch::default()
|
||||
.add_input(commit.name, commit.input())
|
||||
.add_input(branch.name, branch.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}"))
|
||||
}
|
||||
|
||||
named::job(
|
||||
Job::default()
|
||||
.runs_on(runners::LINUX_SMALL)
|
||||
.add_step(steps::checkout_repo())
|
||||
.add_step(cherry_pick(&branch.var(), &commit.var())),
|
||||
)
|
||||
}
|
||||
@@ -1,22 +1,56 @@
|
||||
use gh_workflow::*;
|
||||
|
||||
use crate::tasks::workflows::run_bundling::upload_artifact;
|
||||
use crate::tasks::workflows::steps::FluentBuilder;
|
||||
use crate::tasks::workflows::{
|
||||
runners,
|
||||
steps::{self, NamedJob, named},
|
||||
vars::Input,
|
||||
};
|
||||
|
||||
/// Generates the danger.yml workflow
|
||||
pub fn compare_perf() -> Workflow {
|
||||
let run_perf = run_perf();
|
||||
let head = Input::string("head", None);
|
||||
let base = Input::string("base", None);
|
||||
let run_perf = run_perf(&base, &head);
|
||||
named::workflow()
|
||||
.on(Event::default().workflow_dispatch(WorkflowDispatch::default()))
|
||||
.on(Event::default().workflow_dispatch(
|
||||
WorkflowDispatch::default()
|
||||
.add_input(head.name, head.input())
|
||||
.add_input(base.name, base.input()),
|
||||
))
|
||||
.add_job(run_perf.name, run_perf.job)
|
||||
}
|
||||
|
||||
pub fn run_perf() -> NamedJob {
|
||||
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}"))
|
||||
}
|
||||
|
||||
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...
|
||||
named::bash(&format!(
|
||||
"cargo perf-compare --save=results.md {base} {head}"
|
||||
))
|
||||
}
|
||||
|
||||
named::job(
|
||||
Job::default()
|
||||
.runs_on(runners::LINUX_SMALL)
|
||||
.add_step(steps::checkout_repo()),
|
||||
.runs_on(runners::LINUX_DEFAULT)
|
||||
.add_step(steps::checkout_repo())
|
||||
.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(upload_artifact("results.md"))
|
||||
.add_step(steps::cleanup_cargo_config(runners::Platform::Linux)),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -298,3 +298,9 @@ pub(crate) mod named {
|
||||
.join("::")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn git_checkout(ref_name: &str) -> Step<Run> {
|
||||
named::bash(&format!(
|
||||
"git fetch origin {ref_name} && git checkout {ref_name}"
|
||||
))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::cell::RefCell;
|
||||
|
||||
use gh_workflow::{Concurrency, Env, Expression};
|
||||
use gh_workflow::{Concurrency, Env, Expression, WorkflowDispatchInput};
|
||||
|
||||
use crate::tasks::workflows::{runners::Platform, steps::NamedJob};
|
||||
|
||||
@@ -107,7 +107,7 @@ impl PathCondition {
|
||||
name: job.name,
|
||||
job: job
|
||||
.job
|
||||
.add_needs(set_by_step.clone())
|
||||
.add_need(set_by_step.clone())
|
||||
.cond(Expression::new(format!(
|
||||
"needs.{}.outputs.{} == 'true'",
|
||||
&set_by_step, self.name
|
||||
@@ -116,6 +116,35 @@ impl PathCondition {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct Input {
|
||||
pub input_type: &'static str,
|
||||
pub name: &'static str,
|
||||
pub default: Option<String>,
|
||||
}
|
||||
|
||||
impl Input {
|
||||
pub fn string(name: &'static str, default: Option<String>) -> Self {
|
||||
Self {
|
||||
input_type: "string",
|
||||
name,
|
||||
default,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn var(&self) -> String {
|
||||
format!("${{{{ inputs.{} }}}}", self.name)
|
||||
}
|
||||
|
||||
pub fn input(&self) -> WorkflowDispatchInput {
|
||||
WorkflowDispatchInput {
|
||||
description: self.name.to_owned(),
|
||||
required: self.default.is_none(),
|
||||
input_type: self.input_type.to_owned(),
|
||||
default: self.default.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod assets {
|
||||
// NOTE: these asset names also exist in the zed.dev codebase.
|
||||
pub const MAC_AARCH64: &str = "Zed-aarch64.dmg";
|
||||
|
||||
Reference in New Issue
Block a user