Skip to content

Commit

Permalink
feat: add benchmark to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mehul-m-prajapati committed Dec 9, 2024
1 parent df3caa1 commit 3779192
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions crates/gh-workflow-tailcall/src/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ pub struct Workflow {

/// Name of the workflow.
pub name: String,

/// When enabled, a benchmark job is added to the workflow.
pub benchmarks: bool,
}

impl Default for Workflow {
fn default() -> Self {
Self { auto_release: false, name: "CI".into() }
Self { auto_release: false, name: "CI".into(), benchmarks: false }
}
}

Expand Down Expand Up @@ -61,7 +64,7 @@ impl From<Workflow> for GHWorkflow {
let cond = is_main.and(is_push);

// Jobs
let build = build_and_test();
let build = build_and_test(&value);
let mut workflow = GHWorkflow::new(value.name)
.add_env(flags)
.on(event)
Expand Down Expand Up @@ -115,8 +118,8 @@ fn release_job(cond: &Context<bool>, build: &Job, permissions: &Permissions) ->
.add_step(Release::default().command(Command::Release))
}

fn build_and_test() -> Job {
Job::new("Build and Test")
fn build_and_test(value: &Workflow) -> Job {
let mut job = Job::new("Build and Test")
.permissions(Permissions::default().contents(Level::Read))
.add_step(Step::checkout())
.add_step(
Expand All @@ -142,5 +145,15 @@ fn build_and_test() -> Job {
.nightly()
.args("--all-features --workspace -- -D warnings")
.name("Cargo Clippy"),
)
);

Check warning on line 148 in crates/gh-workflow-tailcall/src/workflow.rs

View workflow job for this annotation

GitHub Actions / Build and Test

Diff in /home/runner/work/gh-workflow/gh-workflow/crates/gh-workflow-tailcall/src/workflow.rs

if value.benchmarks {
job = job.add_step(
Cargo::new("bench")
.args("--workspace")
.name("Cargo Bench"),
);
}

job
}

0 comments on commit 3779192

Please sign in to comment.