diff --git a/.forge/ci.toml b/.forge/ci.toml new file mode 100644 index 0000000..4048753 --- /dev/null +++ b/.forge/ci.toml @@ -0,0 +1,49 @@ +# CI for iz. Format: forge's docs/ci.md. +# +# The workflow has no branch condition, so the job also runs for pull requests. +# One job does everything, so its steps run one at a time. A tag push matching "v*" publishes a +# release with the binary and SHA256SUMS, only when the job succeeded. + +name = "build" + +[on] +push = ["main"] +pull_request = true +manual = true +tags = ["v*"] + +[jobs.build] +image = "docker.io/library/rust:1" +# Build parallelism comes from the runner (CARGO_BUILD_JOBS follows its CPU limit). Drops debuginfo. +# CARGO_HOME in the workspace puts the downloaded crates in the cache, so a run downloads only new ones. +# That places turso_core's source inside this repo, and its build.rs then watches our .git/HEAD, which +# is new in every job, so it would rebuild on every run. With SOURCE_DATE_EPOCH set it skips git. +env = { CARGO_PROFILE_DEV_DEBUG = "0", CARGO_PROFILE_TEST_DEBUG = "0", CARGO_HOME = "/workspace/.cargo-home", SOURCE_DATE_EPOCH = "0" } +# Tests run first, so a failure shows before the slow LTO release build. +# The groups are the job's steps on the run page, and `exec 2>&1` keeps a marker in order with cargo's +# stderr, which the runner reads from a separate pipe. +# IZ_BUILD_SHA is what /healthz reports. safe.directory is needed because the checkout may be owned +# by another uid inside the sandbox; without git it falls back to "dev". +run = """ +exec 2>&1 +echo "::group::Tests" +cargo test --workspace +echo "::endgroup::" +echo "::group::Release build" +IZ_BUILD_SHA=$(git -c safe.directory=/workspace rev-parse --short=12 HEAD 2>/dev/null || echo dev) +export IZ_BUILD_SHA +echo "IZ_BUILD_SHA=$IZ_BUILD_SHA" +cargo build --release -p iz-web +echo "::endgroup::" +echo "::group::Package" +ARCH=$(uname -m) +cp target/release/iz iz-$ARCH-linux +sha256sum iz-$ARCH-linux > SHA256SUMS +echo "::endgroup::" +""" +artifacts = ["iz-*-linux", "SHA256SUMS"] +cache = ["target", ".cargo-home"] +timeout_minutes = 120 + +[release] +assets = ["build:iz-*-linux", "build:SHA256SUMS"]