Skip to content

Commit be4d624

Browse files
committed
fixed CI, updated Dockerfile
1 parent c897052 commit be4d624

File tree

10 files changed

+29
-41
lines changed

10 files changed

+29
-41
lines changed

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ Using `--no-verify` is a sign of poor craftsmanship and will not be tolerated.
3636
**The `.github/workflows/` directory is GENERATED by cigen itself. NEVER manually edit files in that directory.**
3737

3838
- CI configuration is defined in `.cigen/` directory
39-
- Workflows are generated by running: `cargo run -- generate --file .cigen/config.yml`
39+
- Workflows are generated by running: `cargo run -- --config .cigen generate`
4040
- All changes to CI must be made in `.cigen/workflows/` YAML files
4141
- The generated files contain "DO NOT EDIT" warnings at the top
4242
- To test CI locally: `act -j <job-name> --container-architecture linux/amd64`
4343

4444
If you need to modify CI behavior:
4545

4646
1. Edit files in `.cigen/workflows/ci/jobs/`
47-
2. Regenerate with `cargo run -- generate --file .cigen/config.yml`
47+
2. Regenerate with `cargo run -- --config .cigen generate`
4848
3. Test with `act` before committing
4949
4. Commit both the source `.cigen/` files AND generated `.github/` files together
5050

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ tokio = { workspace = true }
4949
tracing = { workspace = true }
5050
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
5151
which = "8.0.0"
52-
yaml-spanned = "0.0.2"
52+
yaml-spanned = "0.0.3"
5353
globwalk = "0.9.1"
5454
walkdir = "2.5.0"
5555
tonic = { workspace = true }
5656
prost = { workspace = true }
5757
tonic-prost = { workspace = true }
5858
hex = "0.4.3"
59+
libyaml-safer = "0.3.0"
5960

6061
[dev-dependencies]
6162
assert_cmd = "2.0.17"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
CIGen generates CI configuration from reusable, provider-agnostic files. The project is undergoing a major migration to a Terraform-style plugin architecture: the new Rust core spawns provider binaries over a length-prefixed stdio transport, and those plugins emit provider-specific YAML.
44

5-
Today the GitHub Actions provider plugin powers our own CI (`cargo run -- generate --file .cigen`), while the legacy CircleCI emitter is being rebuilt on top of the same plugin system. The CLI still provides the templating, schema validation, and hashing utilities that powered the earlier monolithic implementation.
5+
Today the GitHub Actions provider plugin powers our own CI (`cargo run -- --config .cigen generate`), while the legacy CircleCI emitter is being rebuilt on top of the same plugin system. The CLI still provides the templating, schema validation, and hashing utilities that powered the earlier monolithic implementation.
66

77
## Features (Current)
88

docker/cigen-bootstrap/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ RUN set -euxo pipefail \
1313
ca-certificates \
1414
curl \
1515
git \
16+
openssh-client \
17+
sudo \
1618
jq \
1719
tar \
1820
unzip \

internal_docs/SELF_HOSTING_ON_GITHUB_ACTIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This document outlines the complete plan to:
1515
- **Workflow generation**: `.cigen/` split config rendered through the GitHub provider plugin — the old workspace-specific scaffolding has been removed
1616
- **Caching**: Uses the skip-cache flow (via `actions/cache@v4`) plus a small build artifact for the `cigen` binary
1717
- **Package management**: Rust toolchain managed through rustup inside the `rust:latest` container; Node/pnpm steps only run when `act` needs them
18-
- **Plugin architecture**: Core spawns `cigen-provider-github` during `cargo run -- generate --file .cigen`
18+
- **Plugin architecture**: Core spawns `cigen-provider-github` during `cargo run -- --config .cigen generate`
1919

2020
## Goals
2121

plugins/provider-circleci/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tracing = { workspace = true }
1818
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
1919
serde_json = { workspace = true }
2020
thiserror = "2.0.12"
21-
yaml-spanned = "0.0.2"
21+
yaml-spanned = "0.0.3"
2222

2323
[dependencies.cigen]
2424
path = "../../"

plugins/provider-circleci/src/main.rs

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
use anyhow::{Context, Result, anyhow, bail};
44
use cigen::plugin::protocol::{
5-
self, CigenSchema, CommandDefinition, CommandParameter, CustomStep, Fragment, GenerateRequest,
5+
CigenSchema, CommandDefinition, CommandParameter, CustomStep, Fragment, GenerateRequest,
66
GenerateResult, Hello, JobDefinition, PlanRequest, PlanResult, PluginInfo, RunStep, Step,
77
UsesStep, WorkflowCondition as ProtoWorkflowCondition,
88
WorkflowConditionKind as ProtoWorkflowConditionKind,
99
};
10-
use cigen::schema::WorkflowConfig;
1110
use serde_yaml::{Mapping, Value};
1211
use std::collections::HashMap;
1312
use std::convert::TryFrom;
@@ -334,7 +333,7 @@ fn generate_setup_config(context: &CircleciContext) -> Result<Value> {
334333
grouped_jobs.entry(wf.to_string()).or_default().push(job);
335334
}
336335

337-
for (wf_id, _) in &grouped_jobs {
336+
for wf_id in grouped_jobs.keys() {
338337
let variants = collect_job_variants_for_workflow(context, wf_id)?;
339338
all_variants.extend(variants);
340339
}
@@ -399,7 +398,7 @@ fn generate_main_config(context: &CircleciContext) -> Result<Value> {
399398
let mut all_variants = Vec::new();
400399
let mut workflow_variants_map: HashMap<String, Vec<JobVariant>> = HashMap::new();
401400

402-
for (wf_id, _) in &grouped_jobs {
401+
for wf_id in grouped_jobs.keys() {
403402
let variants = collect_job_variants_for_workflow(context, wf_id)?;
404403
workflow_variants_map.insert(wf_id.clone(), variants.clone());
405404
all_variants.extend(variants);
@@ -465,10 +464,10 @@ fn build_workflow_def(
465464
) -> Result<Value> {
466465
let mut workflow_map = Mapping::new();
467466

468-
if let Some(conditions) = context.workflow_conditions.get(workflow_id) {
469-
if let Some(when_value) = build_circleci_when(conditions)? {
470-
workflow_map.insert(Value::String("when".into()), when_value);
471-
}
467+
if let Some(conditions) = context.workflow_conditions.get(workflow_id)
468+
&& let Some(when_value) = build_circleci_when(conditions)?
469+
{
470+
workflow_map.insert(Value::String("when".into()), when_value);
472471
}
473472

474473
workflow_map.insert(
@@ -543,12 +542,11 @@ fn convert_job(variant: &JobVariant, context: &CircleciContext) -> Result<Option
543542
let job = variant.job;
544543

545544
// Skip approval jobs in definition list (they only appear in workflows)
546-
if let Some(extra_type) = job.extra.get("type") {
547-
if let Ok(val) = parse_yaml_value(extra_type) {
548-
if val.as_str() == Some("approval") {
549-
return Ok(None);
550-
}
551-
}
545+
if let Some(extra_type) = job.extra.get("type")
546+
&& let Ok(val) = parse_yaml_value(extra_type)
547+
&& val.as_str() == Some("approval")
548+
{
549+
return Ok(None);
552550
}
553551

554552
let mut map = Mapping::new();
@@ -638,12 +636,6 @@ fn convert_job(variant: &JobVariant, context: &CircleciContext) -> Result<Option
638636
Ok(Some(Value::Mapping(map)))
639637
}
640638

641-
// ... (rest of the file: helper functions build_checkout_invocation, etc. - copied from original, no substitution logic)
642-
643-
fn sanitize_job_name(name: &str) -> String {
644-
name.replace(['/', '\\'], "_")
645-
}
646-
647639
fn convert_steps_list(steps: &[Step]) -> Result<Vec<Value>> {
648640
let mut converted = Vec::new();
649641
for step in steps {
@@ -1579,14 +1571,6 @@ fn extract_checkout_config(raw_config: &Value) -> CheckoutConfig {
15791571
config
15801572
}
15811573

1582-
fn extract_mapping(raw_config: &Value, key: &str) -> Option<Mapping> {
1583-
raw_config
1584-
.as_mapping()
1585-
.and_then(|map| map.get(&Value::String(key.into())))
1586-
.and_then(Value::as_mapping)
1587-
.cloned()
1588-
}
1589-
15901574
fn build_circleci_when(conditions: &[WorkflowRunCondition]) -> Result<Option<Value>> {
15911575
let mut clauses = Vec::new();
15921576

plugins/provider-github/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ fn render_workflow_file(
376376

377377
let mut yaml = String::from("# DO NOT EDIT - This file is generated by cigen\n");
378378
yaml.push_str("# Source: .cigen/workflows/\n");
379-
yaml.push_str("# Regenerate with: cargo run -- generate --file .cigen\n");
379+
yaml.push_str("# Regenerate with: cargo run -- --config .cigen generate\n");
380380
yaml.push_str("#\n");
381381

382382
let rendered = serde_yaml::to_string(&workflow_map)

tests/circleci_job_status.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ fn jobs_with_sources(config_dir: &Path, workflow: &str) -> (HashSet<String>, Has
3232
(with_sources, without_sources)
3333
}
3434

35-
fn run_generate(file: &Path, output_dir: &Path) {
35+
fn run_generate(config_dir: &Path, output_dir: &Path) {
3636
let mut cmd = Command::cargo_bin("cigen").expect("cigen binary not found");
3737
cmd.arg("generate")
3838
.arg("--file")
39-
.arg(file)
39+
.arg(config_dir)
4040
.arg("--output")
4141
.arg(output_dir)
4242
.current_dir(repo_root())

0 commit comments

Comments
 (0)