Forge workflow: tests, release build, tagged releases with SHA256SUMS
Browse files at this commit93dee0c3e4d845fdef3c4656d2242794398d03e9Parent: 1d69844All checks have passed
Show checks
ci/buildSucceededDetails
- ci
- forge workflow: tests, release build, tagged releases with SHA256SUMS
1 changed file +49 -0
- .forge/ci.toml +49 -0
.forge/ci.tomladded+49 -0
| @@ -0,0 +1,49 @@ | |||
| 1 | +# CI for im. Format: forge's docs/ci.md. | ||
| 2 | +# | ||
| 3 | +# The workflow has no branch condition, so the job also runs for pull requests. | ||
| 4 | +# One job does everything, so its steps run one at a time. A tag push matching "v*" publishes a | ||
| 5 | +# release with the binary and SHA256SUMS, only when the job succeeded. | ||
| 6 | + | ||
| 7 | +name = "build" | ||
| 8 | + | ||
| 9 | +[on] | ||
| 10 | +push = ["main"] | ||
| 11 | +pull_request = true | ||
| 12 | +manual = true | ||
| 13 | +tags = ["v*"] | ||
| 14 | + | ||
| 15 | +[jobs.build] | ||
| 16 | +image = "docker.io/library/rust:1" | ||
| 17 | +# Build parallelism comes from the runner (CARGO_BUILD_JOBS follows its CPU limit). Drops debuginfo. | ||
| 18 | +# CARGO_HOME in the workspace puts the downloaded crates in the cache, so a run downloads only new ones. | ||
| 19 | +# That places turso_core's source inside this repo, and its build.rs then watches our .git/HEAD, which | ||
| 20 | +# is new in every job, so it would rebuild on every run. With SOURCE_DATE_EPOCH set it skips git. | ||
| 21 | +env = { CARGO_PROFILE_DEV_DEBUG = "0", CARGO_PROFILE_TEST_DEBUG = "0", CARGO_HOME = "/workspace/.cargo-home", SOURCE_DATE_EPOCH = "0" } | ||
| 22 | +# Tests run first, so a failure shows before the slow LTO release build. | ||
| 23 | +# The groups are the job's steps on the run page, and `exec 2>&1` keeps a marker in order with cargo's | ||
| 24 | +# stderr, which the runner reads from a separate pipe. | ||
| 25 | +# IM_BUILD_SHA is what /healthz reports. safe.directory is needed because the checkout may be owned | ||
| 26 | +# by another uid inside the sandbox; without git it falls back to "dev". | ||
| 27 | +run = """ | ||
| 28 | +exec 2>&1 | ||
| 29 | +echo "::group::Tests" | ||
| 30 | +cargo test --workspace | ||
| 31 | +echo "::endgroup::" | ||
| 32 | +echo "::group::Release build" | ||
| 33 | +IM_BUILD_SHA=$(git -c safe.directory=/workspace rev-parse --short=12 HEAD 2>/dev/null || echo dev) | ||
| 34 | +export IM_BUILD_SHA | ||
| 35 | +echo "IM_BUILD_SHA=$IM_BUILD_SHA" | ||
| 36 | +cargo build --release -p im-web | ||
| 37 | +echo "::endgroup::" | ||
| 38 | +echo "::group::Package" | ||
| 39 | +ARCH=$(uname -m) | ||
| 40 | +cp target/release/im im-$ARCH-linux | ||
| 41 | +sha256sum im-$ARCH-linux > SHA256SUMS | ||
| 42 | +echo "::endgroup::" | ||
| 43 | +""" | ||
| 44 | +artifacts = ["im-*-linux", "SHA256SUMS"] | ||
| 45 | +cache = ["target", ".cargo-home"] | ||
| 46 | +timeout_minutes = 120 | ||
| 47 | + | ||
| 48 | +[release] | ||
| 49 | +assets = ["build:im-*-linux", "build:SHA256SUMS"] | ||