#!/bin/sh # Start a throwaway Radicale (a small CalDAV server) for the live tracker suite (Gitea #156). # # start-radicale.sh # # Radicale runs as a background process, not a service container: the jobs that call this # already run inside a job container, and a process on 127.0.0.1 needs no network wiring. # Appends the CHEMENU_LIVE_CALDAV_* variables to $GITHUB_ENV, so the pytest step that follows # runs the CalDAV half of the live suite - with CHEMENU_LIVE_REQUIRE=caldav set by the # workflow, so a server that did not come up fails the run instead of skipping it. set -eu python="$1" work="$2" mkdir -p "$work" printf 'ci:ci-live-secret\n' > "$work/users" cat > "$work/config" < "$work/radicale.log" 2>&1 & # The readiness probe uses the same Python, not curl: ci.yml's job image has no curl. ready=' import base64, sys, urllib.request req = urllib.request.Request("http://127.0.0.1:5232/ci/", method="PROPFIND", headers={"Depth": "0", "Authorization": "Basic " + base64.b64encode(b"ci:ci-live-secret").decode()}) try: urllib.request.urlopen(req, timeout=2) except Exception: sys.exit(1) ' i=0 until "$python" -c "$ready"; do i=$((i + 1)) if [ "$i" -gt 30 ]; then echo "radicale did not come up:" >&2 cat "$work/radicale.log" >&2 exit 1 fi sleep 1 done version="$("$python" -m radicale --version 2>/dev/null | tail -n 1)" { echo "CHEMENU_LIVE_CALDAV_URL=http://127.0.0.1:5232/ci/" echo "CHEMENU_LIVE_CALDAV_USER=ci" echo "CHEMENU_LIVE_CALDAV_PASSWORD=ci-live-secret" echo "CHEMENU_LIVE_CALDAV_VERSION=radicale $version" } >> "${GITHUB_ENV:?start-radicale.sh runs inside a workflow step}" echo "radicale $version is up"