Files
oak-gpui/tooling/xtask/src/tasks/workflows.rs
T
Conrad IrwinandBen Kunkle c656101862 Use gh-workflow for the run-bundling aspects of CI.yml (#41304)
To help make our GitHub Actions easier to understand, we're planning to
split the existing `ci.yml` into three separate workflows:

* run_bundling.yml (this PR)
* run_tests.yml 
* make_release.yml

To avoid the duplication that this might otherwise cause, we're planning
to write the workflows with gh-workflow, and use rust instead of
encoding logic in YAML conditions.

Release Notes:

- N/A

---------

Co-authored-by: Ben Kunkle <ben@zed.dev>
2025-10-28 09:12:04 -06:00

47 lines
1.2 KiB
Rust

use anyhow::{Context, Result};
use clap::Parser;
use std::fs;
use std::path::Path;
mod danger;
mod nix_build;
// mod release;
mod run_bundling;
// mod run_tests;
mod runners;
mod steps;
mod vars;
#[derive(Parser)]
pub struct GenerateWorkflowArgs {}
pub fn run_workflows(_: GenerateWorkflowArgs) -> Result<()> {
let dir = Path::new(".github/workflows");
let workflows = vec![
("danger.yml", danger::danger()),
("nix_build.yml", nix_build::nix_build()),
("run_bundling.yml", run_bundling::run_bundling()),
// ("run_tests.yml", run_tests::run_tests()),
// ("release.yml", release::release()),
];
fs::create_dir_all(dir)
.with_context(|| format!("Failed to create directory: {}", dir.display()))?;
for (filename, workflow) in workflows {
let content = workflow
.to_string()
.map_err(|e| anyhow::anyhow!("{}: {:?}", filename, e))?;
let content = format!(
"# Generated from xtask::workflows::{}\n# Rebuild with `cargo xtask workflows`.\n{}",
workflow.name.unwrap(),
content
);
let file_path = dir.join(filename);
fs::write(&file_path, content)?;
}
Ok(())
}