From 51b7a5e80b9c530e222f42b2e62ad79dcdffb15f Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Sat, 28 Nov 2026 11:41:11 +0100 Subject: [PATCH] ci: publish the image and chart from CI Build and test the server, client, and chart on every push. Main pushes publish the rolling image and a timestamped chart whose appVersion is the commit; v* tags publish exact and stable image tags. --- .gitea/workflows/ci.yml | 213 +++++++++++++++++++++++++++ .gitea/workflows/release.yaml | 95 ++++++++++++ README.md | 5 + deploy/helm/rhema-together/README.md | 21 +++ 4 files changed, 334 insertions(+) create mode 100644 .gitea/workflows/ci.yml create mode 100644 .gitea/workflows/release.yaml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..e110fbf --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,213 @@ +name: ci + +on: + push: + pull_request: + +permissions: + contents: read + packages: write + +env: + CARGO_TERM_COLOR: always + OWNER: vhaudiquet + RHEMA_REF: v0.5.1 + +jobs: + checks: + runs-on: ubuntu-latest + steps: + - uses: https://gitea.com/actions/checkout@v4 + + # The server consumes the framework by path. The image pins the + # same tag; the checks need a checkout at the same place. + - name: Clone the Rhema framework + run: git clone --depth 1 --branch "$RHEMA_REF" https://github.com/vhaudiquet/rhema.git ../rhema + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install native build dependencies + run: sudo apt-get update && sudo apt-get install -y cmake pkg-config libssl-dev + + - name: Format + run: cargo fmt --all -- --check + + - name: Clippy (warnings are errors) + run: cargo clippy --all-targets -- -D warnings + + test: + runs-on: ubuntu-latest + steps: + - uses: https://gitea.com/actions/checkout@v4 + + - name: Clone the Rhema framework + run: git clone --depth 1 --branch "$RHEMA_REF" https://github.com/vhaudiquet/rhema.git ../rhema + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install native build dependencies + run: sudo apt-get update && sudo apt-get install -y cmake pkg-config libssl-dev + + - name: Test + run: cargo test + + # The chart: lint it, render every supported shape, validate the + # result against the Kubernetes schemas, and prove the single-replica + # guard is a render failure rather than a comment. + chart: + runs-on: ubuntu-latest + steps: + - uses: https://gitea.com/actions/checkout@v4 + + - name: Install helm and kubeconform + run: | + curl -fsSL https://get.helm.sh/helm-v3.16.4-linux-amd64.tar.gz \ + | tar -xz -C /tmp + sudo install /tmp/linux-amd64/helm /usr/local/bin/helm + curl -fsSL https://github.com/yannh/kubeconform/releases/download/v0.6.7/kubeconform-linux-amd64.tar.gz \ + | tar -xz kubeconform + sudo install kubeconform /usr/local/bin/kubeconform + + - name: Lint + run: helm lint deploy/helm/rhema-together --strict + + - name: Render and validate + run: | + check() { + helm template test "$@" | kubeconform -strict -summary + } + check deploy/helm/rhema-together + check deploy/helm/rhema-together --set persistence.enabled=false + check deploy/helm/rhema-together --set persistence.existingClaim=together-data + check deploy/helm/rhema-together --set ingress.enabled=true + check deploy/helm/rhema-together --set app.previewOrigin="" + + # One SQLite file and in-process preview tunnels: two writers + # are the failure the chart must refuse to render. + if helm template test deploy/helm/rhema-together \ + --set replicaCount=2 > /dev/null 2>&1; then + echo "replicaCount 2 must not render"; exit 1 + fi + + # The public origin is required: invite links and cookies are + # built from it, and an empty origin points every link at "". + if helm template test deploy/helm/rhema-together \ + --set app.publicUrl= > /dev/null 2>&1; then + echo "an empty app.publicUrl must not render"; exit 1 + fi + + web: + runs-on: ubuntu-latest + steps: + - uses: https://gitea.com/actions/checkout@v4 + + - name: Set up Node and pnpm + run: | + curl -fsSL https://nodejs.org/dist/v22.22.1/node-v22.22.1-linux-x64.tar.xz \ + | sudo tar -xJ -C /usr/local --strip-components=1 + corepack enable + corepack prepare pnpm@11.22.0 --activate + node --version + pnpm --version + + - name: Install dependencies + working-directory: web + run: pnpm install --frozen-lockfile + + - name: Typecheck + working-directory: web + run: pnpm typecheck + + - name: Build + working-directory: web + run: pnpm build + + # The image: build it, then prove the binary starts and serves the + # bootstrap route as UID 10001 with the data volume in place. + docker: + runs-on: ubuntu-latest + steps: + - uses: https://gitea.com/actions/checkout@v4 + + - name: Build image + run: docker build --build-arg RHEMA_REF="$RHEMA_REF" -t rhema-together:ci . + + - name: Smoke test + run: | + docker rm -f rhema-together-ci || true + trap 'docker rm -f rhema-together-ci || true' EXIT + docker run -d --name rhema-together-ci \ + -p 127.0.0.1:18000:7800 rhema-together:ci + ok=0 + for i in $(seq 1 30); do + if curl -fsS http://127.0.0.1:18000/api/bootstrap > /tmp/bootstrap.json; then + ok=1; break + fi + sleep 1 + done + if [ "$ok" != 1 ]; then + docker logs rhema-together-ci + exit 1 + fi + grep -q '"needs_setup"' /tmp/bootstrap.json + docker rm -f rhema-together-ci + + # The edge channel: a main push that passed everything above ships + # the rolling image and a chart whose appVersion is this commit. The + # chart's default image tag follows appVersion, so the image exists + # before the chart lands. + publish-edge-image: + if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main' + needs: [checks, test, chart, web, docker] + runs-on: ubuntu-latest + steps: + - uses: https://gitea.com/actions/checkout@v4 + + - name: Log in to the container registry + uses: docker/login-action@v3 + with: + registry: https://git.vhaudiquet.fr + username: ${{ gitea.actor }} + password: ${{ secrets.PACKAGES_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile + push: true + build-args: | + RHEMA_REF=${{ env.RHEMA_REF }} + tags: | + git.vhaudiquet.fr/${{ env.OWNER }}/rhema-together:latest + git.vhaudiquet.fr/${{ env.OWNER }}/rhema-together:${{ gitea.sha }} + + publish-edge-chart: + if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main' + needs: publish-edge-image + runs-on: ubuntu-latest + steps: + - uses: https://gitea.com/actions/checkout@v4 + + - name: Install Helm + uses: azure/setup-helm@v5 + + - name: Stamp the chart with the edge version and commit + run: | + BASE_VERSION=$(grep '^version:' deploy/helm/rhema-together/Chart.yaml | awk '{print $2}') + TIMESTAMP=$(date -u +"%Y%m%d-%H%M%S") + sed -i "s/^version:.*/version: \"${BASE_VERSION}-${TIMESTAMP}\"/" deploy/helm/rhema-together/Chart.yaml + sed -i "s/^appVersion:.*/appVersion: \"${{ gitea.sha }}\"/" deploy/helm/rhema-together/Chart.yaml + + - name: Lint and package + run: | + helm lint deploy/helm/rhema-together --strict + helm package deploy/helm/rhema-together + + - name: Push the chart to the Gitea Helm registry + run: | + TOKEN=$(echo -n "${{ secrets.PACKAGES_TOKEN }}" | tr -d '\n') + curl --fail --user "${{ gitea.actor }}:${TOKEN}" \ + -X POST \ + --upload-file rhema-together-*.tgz \ + "https://git.vhaudiquet.fr/api/packages/${{ env.OWNER }}/helm/api/charts" diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..7c6c36b --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,95 @@ +# The release channel: a v* tag ships the exact-version image, the +# rolling stable pin, and the exact-version chart. A tag with a +# pre-release suffix publishes nothing. Edge publishing on every main +# push lives in ci.yml. +name: release + +on: + push: + tags: + - "v*" + +permissions: + contents: read + packages: write + +env: + REGISTRY: git.vhaudiquet.fr + OWNER: vhaudiquet + RHEMA_REF: v0.5.1 + +jobs: + verify-tag: + # The binary and the chart both take their version from the + # manifest, not the tag. A mismatch must fail before anything ships. + runs-on: ubuntu-latest + steps: + - uses: https://gitea.com/actions/checkout@v4 + + - name: Check the tag matches the package version + run: | + crate_version="$(grep -m1 '^version =' Cargo.toml | awk -F'"' '{print $2}')" + tag_version="${GITHUB_REF_NAME#v}" + if [ "$crate_version" != "$tag_version" ]; then + echo "tag $GITHUB_REF_NAME does not match package version $crate_version" >&2 + exit 1 + fi + + publish-release-image: + if: ${{ !contains(gitea.ref_name, '-') }} + needs: verify-tag + runs-on: ubuntu-latest + steps: + - uses: https://gitea.com/actions/checkout@v4 + + - name: Log in to the container registry + uses: docker/login-action@v3 + with: + registry: https://git.vhaudiquet.fr + username: ${{ gitea.actor }} + password: ${{ secrets.PACKAGES_TOKEN }} + + - name: Compute the release version + id: ver + run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile + push: true + build-args: | + RHEMA_REF=${{ env.RHEMA_REF }} + tags: | + git.vhaudiquet.fr/${{ env.OWNER }}/rhema-together:${{ steps.ver.outputs.version }} + git.vhaudiquet.fr/${{ env.OWNER }}/rhema-together:stable + git.vhaudiquet.fr/${{ env.OWNER }}/rhema-together:${{ gitea.sha }} + + publish-release-chart: + if: ${{ !contains(gitea.ref_name, '-') }} + needs: publish-release-image + runs-on: ubuntu-latest + steps: + - uses: https://gitea.com/actions/checkout@v4 + + - name: Install Helm + uses: azure/setup-helm@v5 + + - name: Stamp the chart with the release version and commit + run: | + sed -i "s/^version:.*/version: \"${GITHUB_REF_NAME#v}\"/" deploy/helm/rhema-together/Chart.yaml + sed -i "s/^appVersion:.*/appVersion: \"${{ gitea.sha }}\"/" deploy/helm/rhema-together/Chart.yaml + + - name: Lint and package + run: | + helm lint deploy/helm/rhema-together --strict + helm package deploy/helm/rhema-together + + - name: Push the chart to the Gitea Helm registry + run: | + TOKEN=$(echo -n "${{ secrets.PACKAGES_TOKEN }}" | tr -d '\n') + curl --fail --user "${{ gitea.actor }}:${TOKEN}" \ + -X POST \ + --upload-file rhema-together-*.tgz \ + "https://git.vhaudiquet.fr/api/packages/${{ env.OWNER }}/helm/api/charts" diff --git a/README.md b/README.md index 991a15a..3b8c9ce 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,11 @@ deployment, service, ingress, and persistent volume. It also documents the wildcard DNS, wildcard TLS certificate, proxy buffering, and body size the app needs. Read that README before exposing the service. +CI publishes the image and chart to the home Gitea registry on every +push to `main`; a `v*` tag publishes the exact version. The chart +repository is +`https://git.vhaudiquet.fr/api/packages/vhaudiquet/helm`. + The preview host is a signed subdomain, so the ingress must route all of `*.preview.` to the same service. The app does not issue certificates. diff --git a/deploy/helm/rhema-together/README.md b/deploy/helm/rhema-together/README.md index 35b6855..89591d9 100644 --- a/deploy/helm/rhema-together/README.md +++ b/deploy/helm/rhema-together/README.md @@ -4,6 +4,27 @@ This chart runs one rhema-together pod with a persistent volume for the SQLite database and the master key. The pod serves the API, the built client, the terminal WebSocket, the event stream, and the preview proxy. +## Published artifacts + +CI publishes on every push to `main`: + +- image `git.vhaudiquet.fr/vhaudiquet/rhema-together:latest` and + `:`; +- chart `rhema-together` versioned `0.1.0-`, with + `appVersion` set to that commit. The image tag defaults to + `appVersion`, so a chart deploys the image built from the same + commit. + +A `v*` tag publishes the exact version and a `stable` image tag, plus +the exact-version chart. The chart repository is: + +```sh +helm repo add vhaudiquet https://git.vhaudiquet.fr/api/packages/vhaudiquet/helm +helm repo update +helm upgrade --install together vhaudiquet/rhema-together \ + --namespace together --create-namespace -f my-values.yaml +``` + ## Build the image ```sh