forked from vhaudiquet/rhema-together
The manifest pointed at `../rhema`, so a build needed that checkout beside the repository. CI cloned it in two jobs and the Dockerfile cloned a tag and rewrote the paths. The committed lock had drifted to 0.5.1 entries after the framework bumped to 0.5.2, so the first cargo command in a clean tree rewrote it. All twelve crates are on crates.io at 0.5.2, so the manifest names that version and the lock pins it. The clone steps, the `RHEMA_REF` argument, and the path rewrite are gone from the workflows and the image. Moving the framework now means `cargo update` on the `rhema-*` packages.
217 lines
7.4 KiB
YAML
217 lines
7.4 KiB
YAML
name: ci
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
OWNER: vhaudiquet
|
|
|
|
jobs:
|
|
checks:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: https://gitea.com/actions/checkout@v4
|
|
|
|
- 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
|
|
|
|
- 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 -t rhema-together:ci .
|
|
|
|
- name: Smoke test
|
|
run: |
|
|
docker rm -f rhema-together-ci || true
|
|
trap 'docker rm -f rhema-together-ci || true' EXIT
|
|
|
|
# The job runs in a container with the host Docker socket. A
|
|
# published port binds the host loopback, which the job cannot
|
|
# reach. Run the app in the job's network namespace instead.
|
|
job_container="$(hostname)"
|
|
if ! docker inspect "$job_container" >/dev/null 2>&1; then
|
|
job_container="$(docker ps --filter 'name=GITEA-ACTIONS-TASK' --format '{{.ID}}' | head -n1)"
|
|
fi
|
|
if [ -n "$job_container" ] && [ "$(docker inspect -f '{{.HostConfig.NetworkMode}}' "$job_container")" != "host" ]; then
|
|
network="container:${job_container}"
|
|
else
|
|
network="host"
|
|
fi
|
|
|
|
docker run -d --name rhema-together-ci --network "$network" \
|
|
-e TOGETHER_LISTEN=127.0.0.1:18000 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
|
|
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"
|