Skip to content

Commit 53ccb1b

Browse files
ndbroadbentclaude
andcommitted
feat: add .cigen/ config for self-hosting
Created cigen's own CI configuration using cigen itself - demonstrating the "write once, run anywhere" philosophy. New files: - .cigen/config.yml - Main config with source file groups for job skipping - .cigen/workflows/ci.yml - CI workflow definition with job dependencies - .cigen/workflows/ci/jobs/clippy.yml .cigen/workflows/ci/jobs/fmt.yml .cigen/workflows/ci/jobs/test.yml - Individual job definitions (fmt, clippy, test) Job definitions: - fmt: Cargo format check with @rust source files - clippy: Linter with @rust source files - test: Full test suite with @rust, @tests, @examples source files - test depends on fmt + clippy passing Features demonstrated: - Source file groups (@rust, @tests, @examples, @docs) - Job skipping based on file changes - Job dependencies (test requires fmt + clippy) - Automatic cache injection (will use actions/cache@v4) Also updated: - Batch renamed cigen.yml → config.yml in docs and notes - Updated CLAUDE.md, various documentation files - Updated loader and validator to reflect config.yml convention Next: Generate GitHub Actions workflow from this config 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5a589e3 commit 53ccb1b

File tree

20 files changed

+132
-69
lines changed

20 files changed

+132
-69
lines changed

.cigen/config.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
provider: github-actions
2+
output_path: .github/workflows
3+
4+
# Source file groups for job skipping
5+
source_file_groups:
6+
rust:
7+
- "src/**/*.rs"
8+
- "Cargo.toml"
9+
- "Cargo.lock"
10+
11+
tests:
12+
- "tests/**/*.rs"
13+
- "tests/**/*.yml"
14+
- "tests/**/*.trycmd"
15+
16+
examples:
17+
- "examples/**/*.yml"
18+
- "examples/**/*.yaml"
19+
20+
docs:
21+
- "*.md"
22+
- "docs/**/*.md"
23+
- "notes/**/*.md"

.cigen/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
jobs:
2+
fmt:
3+
clippy:
4+
test:
5+
requires:
6+
- fmt
7+
- clippy
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
image: rust:latest
2+
source_files: "@rust"
3+
4+
steps:
5+
- name: Clippy check
6+
run: cargo clippy --all-targets --all-features -- -D warnings

.cigen/workflows/ci/jobs/fmt.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
image: rust:latest
2+
source_files: "@rust"
3+
4+
steps:
5+
- name: Format check
6+
run: cargo fmt -- --check

.cigen/workflows/ci/jobs/test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
image: rust:latest
2+
source_files:
3+
- "@rust"
4+
- "@tests"
5+
- "@examples"
6+
7+
steps:
8+
- name: Run tests
9+
run: cargo test --all-features

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ You can also reference `/Users/ndbroadbent/code/docspring/lib/tools/generate_cir
257257

258258
## Use Our Own Tool
259259

260-
The goal is to eventually become 'self-hosting' for our own CI pipeline on GitHub Actions. We must have `nx.json` and `project.json` file in the root of the repository, a `.cigen/` directory, and a `.cigen/cigen.yml` file.
260+
The goal is to eventually become 'self-hosting' for our own CI pipeline on GitHub Actions. We must have `nx.json` and `project.json` file in the root of the repository, a `.cigen/` directory, and a `.cigen/config.yml` file.
261261

262262
We will start by hand-writing our own GitHub Actions workflow files, but eventually migrate to using `cigen` to generate our CI configuration.
263263

@@ -289,13 +289,13 @@ When working on DocSpring configuration conversion:
289289

290290
## Split Configuration
291291

292-
**IMPORTANT**: CIGen supports a "split config" style where different top-level keys can be refactored into their own files under `.cigen/config/`, and it all gets merged together. This prevents `.cigen/cigen.yml` from becoming unmaintainable.
292+
**IMPORTANT**: CIGen supports a "split config" style where different top-level keys can be refactored into their own files under `.cigen/config/`, and it all gets merged together. This prevents `.cigen/config.yml` from becoming unmaintainable.
293293

294294
We MUST use split config for large configuration sections:
295295

296296
- Source file groups are already split: `docspring/.cigen/config/source_file_groups.yml`
297297
- Any other config section that grows beyond ~20 lines should be split into its own file
298-
- Files in `.cigen/config/` are automatically merged with the main `cigen.yml`
298+
- Files in `.cigen/config/` are automatically merged with the main `config.yml`
299299
- Use descriptive filenames that match the top-level key (e.g., `cache_definitions.yml` for cache definitions)
300300

301301
## Key Concepts

docs/src/content/docs/advanced/job-skipping.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ Cigen contains an initial scaffold for job skipping based on a hash of source fi
1616
## How It Works
1717

1818
<Steps>
19-
1. Calculate SHA-256 hash of configured source files
20-
2. Check for a local skip marker file for that hash
21-
3. If present, halt remaining steps (CircleCI)
22-
4. Otherwise, run the job and write the marker file at the end
19+
1. Calculate SHA-256 hash of configured source files 2. Check for a local skip
20+
marker file for that hash 3. If present, halt remaining steps (CircleCI) 4.
21+
Otherwise, run the job and write the marker file at the end
2322
</Steps>
2423

2524
<Aside type="tip">
26-
This is non-persistent. Markers live under `/tmp` in the job container and are not restored across runs yet.
25+
This is non-persistent. Markers live under `/tmp` in the job container and are
26+
not restored across runs yet.
2727
</Aside>
2828

2929
## Source File Configuration
@@ -32,7 +32,7 @@ Cigen contains an initial scaffold for job skipping based on a hash of source fi
3232

3333
Define reusable patterns in your configuration:
3434

35-
<Code code={`# In cigen.yml or config/source_file_groups.yml
35+
<Code code={`# In config.yml or config/source_file_groups.yml
3636
source_file_groups:
3737
ruby:
3838
- '**/*.rb'

docs/src/content/docs/commands/generate.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ For CircleCI (`provider: circleci`):
9393

9494
### Multi-Architecture Jobs
9595

96-
<Code code={`# Input (cigen.yml):
96+
<Code code={`# Input (config.yml):
9797
jobs:
9898
build:
9999
architectures: [amd64, arm64]
@@ -112,7 +112,7 @@ resource_class: arm.medium`} lang="yaml" title="Architecture expansion" />
112112

113113
### Cache Injection
114114

115-
<Code code={`# Input (cigen.yml):
115+
<Code code={`# Input (config.yml):
116116
jobs:
117117
test:
118118
cache: [node_modules]
@@ -194,7 +194,7 @@ Override built-in templates by placing files in your config directory:
194194
195195
```
196196
.cigen/
197-
├── cigen.yml
197+
├── config.yml
198198
├── templates/
199199
│ └── custom_job.yml
200200
└── workflows/

docs/src/content/docs/commands/validate.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Structure your config for easier validation:
230230

231231
```
232232
.cigen/
233-
├── cigen.yml # Main config
233+
├── config.yml # Main config
234234
├── jobs/ # Job definitions
235235
├── workflows/ # Workflow definitions
236236
└── templates/ # Custom templates

docs/src/content/docs/configuration/cache.mdx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,36 @@ Cigen ships default definitions for common technologies that you can extend or o
4343

4444
### Ruby Gems
4545

46-
<Code code={`cache_definitions:
46+
<Code
47+
code={`cache_definitions:
4748
gems:
4849
versions: [ruby, bundler]
4950
checksum_sources: [Gemfile, Gemfile.lock]
5051
paths: [vendor/bundle, .bundle]
51-
`} lang="yaml" title="Ruby cache definition (paths and sources)" />
52+
`}
53+
lang="yaml"
54+
title="Ruby cache definition (paths and sources)"
55+
/>
5256

5357
### Node.js Modules
5458

55-
<Code code={`cache_definitions:
59+
<Code
60+
code={`cache_definitions:
5661
node_modules:
5762
versions: [node]
5863
checksum_sources:
5964
- package.json
6065
- detect: [package-lock.json, yarn.lock, bun.lockb, pnpm-lock.yaml]
6166
paths: [node_modules]
62-
`} lang="yaml" title="Node.js cache definition" />
67+
`}
68+
lang="yaml"
69+
title="Node.js cache definition"
70+
/>
6371

6472
### Python Packages
6573

66-
<Code code={`cache_definitions:
74+
<Code
75+
code={`cache_definitions:
6776
pip:
6877
versions: [python, pip]
6978
checksum_sources:
@@ -72,7 +81,10 @@ Cigen ships default definitions for common technologies that you can extend or o
7281
paths:
7382
- detect: [.venv, venv]
7483
- ~/.cache/pip
75-
`} lang="yaml" title="Python cache definition" />
84+
`}
85+
lang="yaml"
86+
title="Python cache definition"
87+
/>
7688

7789
## Using Caches in Jobs
7890

@@ -96,11 +108,12 @@ jobs:
96108
```
97109
98110
The `restore_cache` field is a shorthand for:
111+
99112
```yaml
100113
cache:
101114
gems:
102-
restore: true # Always true by default anyway
103-
save: false # This is what restore_cache does
115+
restore: true # Always true by default anyway
116+
save: false # This is what restore_cache does
104117
```
105118

106119
### Simple Cache Usage
@@ -151,12 +164,11 @@ This injects a `restore_cache` step before, and a `save_cache` step after, when
151164
title="Customizing cache paths"
152165
/>
153166

154-
155167
## Advanced Cache Configuration
156168

157169
### Custom Cache Types
158170

159-
<Code code={`# In cigen.yml
171+
<Code code={`# In config.yml
160172
cache_definitions:
161173
ml_models:
162174
versions: [python]

0 commit comments

Comments
 (0)