.hearthforge-ci.toml
⎇
Raw
1# Steps run in file order, in one container, sharing /ci/build.
2# Alpine, so the published binary is the same static musl build the
3# Containerfile ships.
4
5image = "docker.io/rust:1.90-alpine3.22"
6work_dir = "/ci/build"
7clone_project_to = "/ci/build/project"
8
9# busybox ash, which does support `set -o pipefail`.
10shell = ["/bin/sh", "-c"]
11
12# CARGO_TARGET_DIR must stay outside clone_project_to: the checkout is
13# extracted over that directory, so a cache inside it would be overwritten.
14shell_setup = """
15set -euo pipefail
16export CARGO_TARGET_DIR=/ci/cache/target
17"""
18
19timeout = 5400
20memory_limit = "6g"
21
22# Caps are a safety valve against unbounded growth, not a budget: hitting one
23# costs a full rebuild. Sized roughly twice the working set. A local target
24# holding all three profiles measures 26G, of which debug is 22G.
25cache = [
26 { path = "/ci/cache/target", max_size = "20g" },
27 { path = "/usr/local/cargo/registry", max_size = "4g" },
28 { path = "/root/.bun/install/cache", max_size = "2g" },
29]
30
31[on]
32push = ["master"]
33tag = true
34
35# bun publishes no musl installer, so take the binary from the official image.
36# This mirrors the Containerfile's COPY --from. The -alpine tag is required:
37# the glibc build will not run here. bun also needs libstdc++, which setup
38# installs before anything executes it.
39[[copy]]
40image = "docker.io/oven/bun:1.4.0-alpine"
41from = "/usr/local/bin/bun"
42to = "/usr/local/bin"
43
44[variables]
45
46 [variables.TRUNK_VERSION]
47 default = "0.21.14"
48 description = "Trunk release that builds the wasm frontend. Matches the Containerfile."
49
50# ── toolchain ────────────────────────────────────────────────────────────────
51# binaryen supplies wasm-opt. Without it trunk downloads a glibc build that
52# cannot run on musl. just comes from apk here, so no install script.
53[[steps]]
54name = "setup"
55timeout = 900
56run_sh = """
57apk add --no-cache musl-dev binaryen just curl libstdc++ podman-remote
58
59# The official rust images use rustup's minimal profile, so rustfmt and
60# clippy are absent. `just lint` needs both.
61rustup component add rustfmt clippy
62rustup target add wasm32-unknown-unknown
63
64url="https://github.com/trunk-rs/trunk/releases/download/v${TRUNK_VERSION}/trunk-x86_64-unknown-linux-musl.tar.gz"
65curl -fsSL -o /tmp/trunk.tar.gz "$url"
66curl -fsSL "$url.sha256" | awk '{print $1 " /tmp/trunk.tar.gz"}' | sha256sum -c -
67tar xzf /tmp/trunk.tar.gz -C /usr/local/bin
68rm -f /tmp/trunk.tar.gz
69
70just --version && bun --version && trunk --version
71cargo fmt --version && cargo clippy --version
72"""
73
74# ── checks ───────────────────────────────────────────────────────────────────
75# Formatting and clippy findings are reported, not gated. The CI toolchain is
76# 1.90 and local machines run newer, so clippy disagrees across versions.
77[[steps]]
78name = "lint"
79run_sh = "cd project && just lint"
80warn_on_fail = true
81
82# `just test` covers server and api-types only, hence the extra web run.
83[[steps]]
84name = "test"
85run_sh = "cd project && just test && cargo test -p web"
86
87# ── build ────────────────────────────────────────────────────────────────────
88[[steps]]
89name = "build"
90timeout = 2400
91run_sh = "cd project && just build"
92publish_file = ["/ci/cache/target/release/filebrowser-ng"]
93
94# `just e2e` would rebuild the frontend. The build step already staged
95# server/dist, so run the embedded suite against it directly.
96[[steps]]
97name = "e2e"
98run_sh = "cd project && cargo test -p server --features embedded"
99
100# ── release ──────────────────────────────────────────────────────────────────
101[[steps]]
102name = "release"
103run_if = 'test -n "${CI_COMMIT_TAG}"'
104run_sh = """
105cd project
106install -Dm755 "${CARGO_TARGET_DIR}/release/filebrowser-ng" \
107 "dist/filebrowser-ng-${CI_COMMIT_TAG}-x86_64-linux-musl"
108"""
109publish_gzip = ["/ci/build/project/dist/"]
110
111# ── image ────────────────────────────────────────────────────────────────────
112# Packages the binary the build step made, so the image ships exactly what
113# e2e tested. The Containerfile's build stage is skipped via BIN_STAGE.
114# engine_socket hands this step the host engine, which is Podman on this
115# server (needs CI_ENGINE_SOCKET=1). REGISTRY_PASSWORD is a CI secret with the
116# admin password. CI_REGISTRY is "<host>/<repo>" on the built-in registry.
117# Tags: every run pushes the short sha and "edge"; a tag run also pushes the
118# tag and "latest".
119[[steps]]
120name = "image"
121engine_socket = true
122timeout = 900
123run_sh = """
124cd project
125mkdir -p ci-bin
126cp "${CARGO_TARGET_DIR}/release/filebrowser-ng" ci-bin/filebrowser-ng
127
128echo "$REGISTRY_PASSWORD" | podman-remote login "${CI_REGISTRY%%/*}" -u admin --password-stdin
129img="$CI_REGISTRY:$CI_COMMIT_SHORT_SHA"
130podman-remote build -f Containerfile -t "$img" --build-arg BIN_STAGE=prebuilt .
131podman-remote push "$img"
132
133if [ -n "${CI_COMMIT_TAG:-}" ]; then
134 tags="$CI_COMMIT_TAG latest"
135else
136 tags="edge"
137fi
138for t in $tags; do
139 podman-remote tag "$img" "$CI_REGISTRY:$t"
140 podman-remote push "$CI_REGISTRY:$t"
141done
142"""
143