@@ -338,13 +338,27 @@ impl CircleCIGenerator {
338338 . insert ( "setup" . to_string ( ) , setup_workflow) ;
339339
340340 // Build setup job
341- // Choose setup runtime image: prefer configured one,
342- // else default to docspringcom/cigen:latest
341+ // Choose setup runtime image based on configuration:
342+ // 1. If runtime_image is explicitly set, use it
343+ // 2. If compile_cigen is true, use Rust image for compilation
344+ // 3. Otherwise default to docspringcom/cigen:latest (has cigen pre-installed + openssh-client)
345+ let compile_cigen = config
346+ . setup_options
347+ . as_ref ( )
348+ . and_then ( |o| o. compile_cigen )
349+ . unwrap_or ( false ) ;
350+
343351 let setup_image = config
344352 . setup_options
345353 . as_ref ( )
346354 . and_then ( |o| o. runtime_image . clone ( ) )
347- . unwrap_or_else ( || "docspringcom/cigen:latest" . to_string ( ) ) ;
355+ . unwrap_or_else ( || {
356+ if compile_cigen {
357+ "cimg/rust:1.75" . to_string ( )
358+ } else {
359+ "docspringcom/cigen:latest" . to_string ( )
360+ }
361+ } ) ;
348362
349363 let mut setup_job = cc:: CircleCIJob {
350364 executor : None ,
@@ -388,6 +402,31 @@ impl CircleCIGenerator {
388402 setup_job. steps . push ( cc:: CircleCIStep :: new ( checkout_step) ) ;
389403 }
390404
405+ // Optional cigen compilation from source for testing cigen changes on CI
406+ if compile_cigen {
407+ // Checkout cigen repository
408+ let checkout_cigen_cmd = r#"set -euo pipefail
409+ echo "Checking out cigen from GitHub..."
410+ git clone --depth 1 https://github.com/DocSpring/cigen.git /tmp/cigen
411+ cd /tmp/cigen"# ;
412+ setup_job. steps . push ( cc:: CircleCIStep :: new ( run_step (
413+ "Checkout cigen repository" ,
414+ checkout_cigen_cmd,
415+ ) ) ) ;
416+
417+ // Compile cigen from source
418+ let compile_cigen_cmd = r#"set -euo pipefail
419+ cd /tmp/cigen
420+ echo "Compiling cigen from source..."
421+ cargo build --release
422+ echo "Cigen compiled successfully"
423+ echo "export PATH=\"/tmp/cigen/target/release:\$PATH\"" >> $BASH_ENV"# ;
424+ setup_job. steps . push ( cc:: CircleCIStep :: new ( run_step (
425+ "Compile cigen from source" ,
426+ compile_cigen_cmd,
427+ ) ) ) ;
428+ }
429+
391430 // Optional self-check to ensure entrypoint is up to date
392431 if let Some ( opts) = & config. setup_options
393432 && let Some ( sc) = & opts. self_check
0 commit comments