Skip to content

CI Integration

Terminology: This specification uses RFC 2119 keywords (MUST, SHOULD, MAY, etc.) to indicate requirement levels.

This document describes Structyl's CI/CD integration features.

Overview

Structyl provides a local CI simulation command that replicates what a CI system would do. This enables developers to validate their changes locally before pushing.

The structyl ci Command

bash
structyl ci [--docker]
structyl ci:release [--docker]

Behavior

The ci command executes the following steps for each target:

  1. clean - Remove build artifacts
  2. restore - Install dependencies
  3. check - Static analysis
  4. build - Compilation
  5. test - Run tests

For ci:release, step 4 uses build:release instead of build.

Variants

CommandDescription
ciRun CI pipeline with default (debug) builds
ci:releaseRun CI pipeline with release/optimized builds

Flags

FlagDescription
--dockerRun all builds in Docker containers

Exit Behavior

  • Exits with code 0 if all steps succeed
  • Exits with code 1 on first failure (fail-fast behavior)

Build Pipeline Steps

The CI pipeline follows this execution order for each target:

clean → restore → check → build → test

For ci:release mode:

clean → restore → check → build:release → test

Targets are processed in dependency order, respecting depends_on declarations.

Custom Pipelines

The default CI steps can be overridden using the ci configuration section in .structyl/config.json. See configuration.md#ci for custom pipeline definitions including step dependencies and continue_on_error behavior.

Custom Pipeline Schema

json
{
  "ci": {
    "steps": [
      {
        "name": "Check",
        "target": "all",
        "command": "check",
        "depends_on": [],
        "continue_on_error": false
      }
    ]
  }
}
FieldRequiredTypeDescription
nameYesstringStep name for display and references
targetYesstringTarget name or "all"
commandYesstringCommand to execute
flagsNostring[]Additional command flags
depends_onNostring[]Step names that must complete first
continue_on_errorNobooleanContinue pipeline if step fails (default: false)

continue_on_error semantics:

When a step with continue_on_error: true fails:

  • Execution continues to subsequent steps
  • The failure is logged as a warning
  • The step does NOT contribute to the final exit code

The final exit code is 0 only if all steps without continue_on_error: true succeed.

Parallel Execution Limitation

When STRUCTYL_PARALLEL > 1, Structyl does not guarantee that targets in depends_on complete before the dependent target starts. See targets.md#known-limitation-parallel-execution-and-dependencies for details and workarounds.

Artifact Collection

After successful builds, artifacts are collected:

artifacts/
├── cs/              # NuGet packages (.nupkg)
├── go/              # Go module
├── kt/              # JAR files
├── py/              # Python wheels/sdist
├── r/               # R package (.tar.gz)
├── rs/              # Rust crate (.crate)
├── ts/              # npm tarball (.tgz)
├── pdf/             # PDF documentation
└── web/             # Static website files

Structyl does not generate CI configuration files. Instead, use your CI system's native configuration and call Structyl commands.

GitHub Actions Example

yaml
name: Build

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: "1.24"

      - name: Install Structyl
        run: go install github.com/AndreyAkinshin/structyl/cmd/structyl@latest

      - name: Run CI build
        run: structyl ci --docker

      - name: Upload artifacts
        uses: actions/upload-artifact@v4
        with:
          name: build-artifacts
          path: artifacts/

GitLab CI Example

yaml
build:
  image: golang:1.24
  services:
    - docker:dind
  script:
    - go install github.com/AndreyAkinshin/structyl/cmd/structyl@latest
    - structyl ci --docker
  artifacts:
    paths:
      - artifacts/

Local Development Workflow

bash
# Quick validation (tests only)
structyl test

# Full CI simulation
structyl ci

# Full CI with Docker (matches CI environment)
structyl ci --docker

# Release build
structyl ci:release --docker

Environment Variables

VariableDescription
STRUCTYL_DOCKERSet to 1 to enable Docker mode by default
CIStandard CI environment variable (affects some target behaviors)

Notes

  • The ci command is reproducible: running it multiple times on unchanged source produces semantically equivalent artifacts. Byte-level identity is not guaranteed—file timestamps, build IDs, and other non-functional metadata may differ. It is not strictly idempotent since build steps modify state (compile outputs, generated files)
  • Docker mode ensures reproducible builds across different host environments
  • Artifact paths follow ecosystem conventions for each language

© 2026 Andrey Akinshin MIT