Skip to content

Commit 6c4ff50

Browse files
committed
more advanced config options for git checkout
1 parent f4f7407 commit 6c4ff50

File tree

15 files changed

+611
-275
lines changed

15 files changed

+611
-275
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The tool can generate both static CircleCI configs and setup/dynamic configs. Th
1313
- Package installation step generation and job deduplication
1414
- Basic automatic cache step injection when `job.cache` is declared
1515
- Architecture variants per job (e.g., `build_amd64`, `build_arm64`)
16+
- Advanced git checkout: shallow clone by default with configurable clone/fetch options, host key scanning, and path overrides
1617
- Descriptive error messages and schema/data validation ([miette], JSON Schema)
1718

1819
## Not Yet Implemented / In Progress

docs/astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default defineConfig({
5252
label: 'Configuration',
5353
items: [
5454
{ label: 'Overview', slug: 'configuration/overview' },
55+
{ label: 'Checkout', slug: 'configuration/checkout' },
5556
{ label: 'Cache System', slug: 'configuration/cache' },
5657
{ label: 'Package Management', slug: 'configuration/packages' },
5758
],

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ cache:
111111
image: cimg/ruby:3.3
112112
cache: gems # Uses all defaults from gems cache definition
113113
steps:
114-
- checkout
115114
- run: bundle install
116115
- run: bundle exec rspec`}
117116
lang="yaml"
@@ -129,7 +128,6 @@ This injects a `restore_cache` step before, and a `save_cache` step after, when
129128
cache: [gems, node_modules] # Multiple cache types
130129
services: [postgres]
131130
steps:
132-
- checkout
133131
- run: bundle install
134132
- run: npm install
135133
- run: bundle exec rspec`}
@@ -148,7 +146,6 @@ This injects a `restore_cache` step before, and a `save_cache` step after, when
148146
paths: [vendor/rubygems, .bundle] # Override paths
149147
# versions and checksum_sources from definition
150148
steps:
151-
- checkout
152149
- run: bundle install --path vendor/rubygems`}
153150
lang="yaml"
154151
title="Customizing cache paths"
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
title: Checkout
3+
description: Advanced, configurable git checkout with shallow clone by default
4+
---
5+
6+
import { Code, Aside, Steps, CardGrid, Card } from '@astrojs/starlight/components';
7+
8+
Cigen automatically inserts a checkout step at the start of every job. By default this is a fast, shallow checkout implemented by a built-in `shallow_checkout` command.
9+
10+
## Configuration
11+
12+
Checkout can be configured at multiple levels, with this precedence:
13+
14+
- Job-level `checkout`
15+
- Workflow-level `checkout`
16+
- Global `checkout`
17+
- Defaults (shallow checkout)
18+
19+
### Parameters
20+
21+
- `shallow` (boolean, default: true): when false, use CircleCI’s standard `checkout` step
22+
- `clone_options` (string): options for the initial clone, e.g. `--depth 1 --verbose`
23+
- `fetch_options` (string): options for `git fetch`, e.g. `--depth 10`
24+
- `tag_fetch_options` (string): options for fetching tags (default: `--tags`)
25+
- `keyscan` (map): add SSH host keys (`github`, `gitlab`, `bitbucket` ⇒ boolean)
26+
- `path` (string): checkout directory
27+
28+
### Disable Checkout
29+
30+
Set `checkout: false` at the global, workflow, or job level to skip inserting any checkout step for those scopes.
31+
32+
<Code code={`jobs:
33+
lint:
34+
image: cimg/node:20.11
35+
checkout: false # do not checkout repo for this job
36+
steps:
37+
- run: npm run lint`} lang="yaml" title="Disable checkout for a job" />
38+
39+
### Global Example
40+
41+
<Code code={`checkout:
42+
shallow: true
43+
clone_options: "--depth 1"
44+
fetch_options: "--depth 10"
45+
tag_fetch_options: "--tags"
46+
keyscan:
47+
github: true
48+
gitlab: false
49+
bitbucket: false
50+
path: "."`} lang="yaml" title="Global checkout configuration" />
51+
52+
### Job Override Example
53+
54+
<Code code={`jobs:
55+
build:
56+
image: cimg/node:20.11
57+
checkout:
58+
shallow: true
59+
fetch_options: "--depth 50 --no-tags"
60+
steps:
61+
- run: npm run build`} lang="yaml" title="Job-level checkout override" />
62+
63+
<Aside type="note">
64+
Do not add `checkout` or `shallow_checkout` in your job steps — cigen inserts the checkout step automatically.
65+
Set `shallow: false` to emit CircleCI's standard `checkout` step (optionally with `path`).
66+
</Aside>
67+
68+
## Generated Output
69+
70+
<Code code={`steps:
71+
- shallow_checkout
72+
- run:
73+
name: Build application
74+
command: npm run build`} lang="yaml" title="Shallow checkout (default)" />
75+
76+
<Code code={`steps:
77+
- shallow_checkout:
78+
fetch_options: --depth 50 --no-tags
79+
keyscan_github: true
80+
path: .`} lang="yaml" title="Parameterized shallow checkout" />
81+
82+
<Code code={`steps:
83+
- checkout
84+
- run:
85+
name: Build application
86+
command: npm run build`} lang="yaml" title="Standard checkout (shallow: false)" />
87+
88+
## Best Practices
89+
90+
- Prefer shallow checkout for most jobs to reduce time and IO.
91+
- Increase `fetch_options` depth in jobs that need more history (e.g., changelog tooling).
92+
- Use `tag_fetch_options` when building from tags; disable tags (`--no-tags`) to reduce noise if unused.
93+
- Enable `keyscan` only for hosts you actually use (GitHub/GitLab/Bitbucket).
94+
- Use `path` when checking out into a subdirectory.
95+
96+
## Migration
97+
98+
If your configs include explicit `checkout` steps in job definitions:
99+
100+
- Remove manual `checkout` steps; cigen now inserts checkout automatically.
101+
- If you required full history, set `checkout.shallow: false` at the appropriate scope.
102+
- If you used custom clone or fetch options, move them under the `checkout` section.

docs/src/content/docs/configuration/overview.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ POSTGRES_PASSWORD: test
5454
# Job definitions
5555
5656
jobs:
57-
test:
58-
image: cimg/ruby:3.3
59-
services: [postgres]
60-
steps: - checkout - run: bundle exec rspec
57+
test:
58+
image: cimg/ruby:3.3
59+
services: [postgres]
60+
steps: [shallow_checkout, { run: bundle exec rspec }]
6161
6262
# Workflow definitions
6363
@@ -99,6 +99,10 @@ Cigen supports both single-file and multi-file configurations:
9999

100100
## Key Differences from Native CI Formats
101101

102+
### Checkout Defaults
103+
104+
By default, cigen performs a fast, shallow checkout via a built-in `shallow_checkout` command. You can override behavior globally or per job using the `checkout` section (see CircleCI provider docs for parameters). Set `shallow: false` to use the standard `checkout` step.
105+
102106
### Cleaner Step Syntax
103107

104108
<Aside type="tip">

0 commit comments

Comments
 (0)