Continuous Integration
Status: 🟢 The build, test, and dependency commands used here work today. Steps using ⚪ planned commands are marked.
Kargo suits CI well: one binary, no daemon, no wrapper, and caches that are ordinary directories you can restore.
GitHub Actions
name: CI
on:
pull_request:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Kargo
run: cargo install --git https://github.com/dejanradmanovic/kargo kargo-cli
- name: Cache Kargo directories
uses: actions/cache@v4
with:
path: |
~/.kargo/toolchains
~/.kargo/cache
~/.kargo/build-cache
key: kargo-${{ runner.os }}-${{ hashFiles('Kargo.lock') }}
restore-keys: kargo-${{ runner.os }}-
- run: kargo build --release
- run: kargo test
- run: kargo audit --fail-on high
The cache key is the important line. Keying on Kargo.lock means a dependency
change invalidates the artifact cache, while restore-keys still gives you the
previous cache as a starting point rather than a cold download of everything.
| Directory | Holds | Worth caching |
|---|---|---|
~/.kargo/toolchains | Kotlin compilers | Yes — hundreds of MB per version |
~/.kargo/cache | Maven artifacts | Yes — shared by every checkout |
~/.kargo/build-cache | Compiled output | Yes — the big win on repeat builds |
build/ | This build's output | No |
Install once, if you can
cargo install compiles Kargo from source on every run, which is slow. Download
the prebuilt binary
instead — one request, no toolchain, and the checksum comes with it:
- name: Install Kargo
run: |
base=https://github.com/dejanradmanovic/kargo/releases/download/v0.2.0
asset=kargo-x86_64-unknown-linux-gnu.tar.gz
curl -fsSLO "$base/$asset"
curl -fsSLO "$base/sha256sums.txt"
sha256sum --ignore-missing --check sha256sums.txt
tar xzf "$asset"
install -Dm755 kargo /usr/local/bin/kargo
Pin the version rather than using latest/download, so a release cannot change
what your pipeline runs. The alternatives, if no binary fits your platform: a
container image with Kargo preinstalled, or cargo install with the Cargo
registry and target directory cached.
- uses: Swatinem/rust-cache@v2 # caches the cargo install build
- run: cargo install --git https://github.com/dejanradmanovic/kargo kargo-cli
Splitting the pipeline
Fast checks first, so an obvious failure does not wait behind a full build:
jobs:
quick:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: kargo fmt --check # ⚪ planned
- run: kargo lint # ⚪ planned
- run: kargo check
test:
needs: quick
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: kargo test
kargo check in the quick job is deliberate: it catches compile errors in a
fraction of a full build.
Multiplatform matrices
Native targets need matching hosts:
strategy:
matrix:
include:
- os: ubuntu-latest
target: jvm
- os: ubuntu-latest
target: js
- os: macos-latest
target: ios-simulator-arm64
- os: windows-latest
target: mingw-x64
steps:
- run: kargo build --target ${{ matrix.target }}
Apple targets require macOS. Nothing cross-compiles to iOS.
Reproducible CI builds
- run: kargo fetch
- run: kargo build --release --offline
kargo fetch downloads everything in the lockfile; --offline then makes the
build fail rather than reach the network. If it passes, the build genuinely
depended only on what the lockfile named — the honest test of reproducibility,
and the configuration to use for a release build.
Test reports
Status: ⚪
--reportand--coverageare planned.
- run: kargo test --report junit --coverage
- uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: build/reports/
- uses: codecov/codecov-action@v6
with:
files: build/reports/coverage/coverage.xml
if: always() matters — you want the report from the run that failed.
Scheduled audits
on:
schedule:
- cron: "0 6 * * 1" # Mondays, 06:00 UTC
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: kargo audit --fail-on high
New advisories land against versions you already depend on, with no commit to trigger a PR build. Without a scheduled run, you learn about them from someone else. See Auditing Dependencies.
Release workflow
Status: ⚪
publishandpackageare planned.
on:
push:
tags: ["v*"]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: kargo test
- run: kargo build --release
- run: kargo package --release
- run: kargo publish
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
Secrets come from the environment, never a committed .kargo.env — see
Secrets.
GitLab CI
variables:
KARGO_HOME: "$CI_PROJECT_DIR/.kargo-home"
cache:
key:
files: [Kargo.lock]
paths:
- .kargo-home/cache
- .kargo-home/build-cache
- .kargo-home/toolchains
build:
image: rust:latest
before_script:
- cargo install --git https://github.com/dejanradmanovic/kargo kargo-cli
script:
- kargo build --release
- kargo test
GitLab only caches paths inside the project directory, hence KARGO_HOME.
Docker
FROM rust:1.91 AS kargo
RUN cargo install --git https://github.com/dejanradmanovic/kargo kargo-cli
FROM eclipse-temurin:25-jdk AS build
COPY --from=kargo /usr/local/cargo/bin/kargo /usr/local/bin/kargo
WORKDIR /src
COPY Kargo.toml Kargo.lock ./
RUN kargo fetch
COPY src ./src
RUN kargo build --release
FROM eclipse-temurin:25-jre
COPY --from=build /src/build/jvm/release/output/*.jar /app/app.jar
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
Copying the manifest and lockfile before the sources is the standard layering trick: dependencies are re-fetched only when they actually change.
Keeping the test jars out of the image
A release image has no use for the dev-dependencies, and a plain kargo fetch
downloads them anyway. --skip-dev resolves the whole graph — the lockfile is
written whole either way — but downloads only what the build will open:
COPY Kargo.toml Kargo.lock ./
RUN kargo fetch --skip-dev
COPY src ./src
RUN kargo build --release
A stage that runs the tests adds the other half on top of that layer, without re-downloading what the build layer already has:
FROM build AS test
RUN kargo fetch --dev-only
RUN kargo test
The two flags are the halves of one choice, so they cannot be combined. Neither
changes Kargo.lock: a partial fetch never writes a partial lockfile.
kargo build needs no equivalent flag: it never downloads the
dev-dependencies, whether or not the cache already has them.