diff --git a/.github/scripts/release-rpm-smoke.py b/.github/scripts/release-rpm-smoke.py new file mode 100644 index 0000000000..f82b70675a --- /dev/null +++ b/.github/scripts/release-rpm-smoke.py @@ -0,0 +1,65 @@ +"""Check a real installed release RPM and exercise the GUI control channel.""" + +import json +import os +from pathlib import Path +import socket +import subprocess +import time + +results = Path("/results") +requirements = (results / "rpm-requires.txt").read_text() +for capability in ( + "libc.so.6()(64bit)", + "libm.so.6(GLIBC_2.35)(64bit)", + "libgcc_s.so.1()(64bit)", + "libxkbcommon.so.0()(64bit)", + "(libvulkan.so.1()(64bit) or libEGL.so.1()(64bit))", +): + if capability not in requirements.splitlines(): + raise RuntimeError(f"Missing RPM requirement: {capability}") + +version = subprocess.check_output(["vectorcraft-cli", "--version"], text=True) +(results / "cli-version.txt").write_text(version) +# Original fixture authored for this package smoke test; no external artwork. +fixture = results / "original-smoke.svg" +fixture.write_text('' + '' + '') +env = dict(os.environ, VECTORCRAFT_NO_PREFS="1", XDG_RUNTIME_DIR="/tmp/vectorcraft-runtime") +Path(env["XDG_RUNTIME_DIR"]).mkdir(mode=0o700, exist_ok=True) +with (results / "gui.log").open("w") as log: + app = subprocess.Popen([ + "vectorcraft", "--control", "32180", "--automation-read-root", str(results), + "--automation-write-root", str(results), str(fixture), + ], stdout=log, stderr=subprocess.STDOUT, env=env) + try: + deadline = time.monotonic() + 90 + while True: + if app.poll() is not None: + raise RuntimeError(f"GUI exited during startup: {app.returncode}") + try: + channel = socket.create_connection(("127.0.0.1", 32180), timeout=5) + break + except OSError: + if time.monotonic() >= deadline: + raise RuntimeError("GUI control channel did not become ready") from None + time.sleep(1) + channel.settimeout(30) + with channel, channel.makefile("rwb") as stream: + for request_id, method, params in ( + (1, "ui.inspect", {}), + ): + stream.write((json.dumps(dict(id=request_id, method=method, params=params)) + "\n").encode()) + stream.flush() + response = json.loads(stream.readline()) + (results / f"{method}.json").write_text(json.dumps(response, indent=2)) + if response.get("id") != request_id or response.get("ok") is not True: + raise RuntimeError(f"GUI request failed: {method}") + finally: + app.terminate() + try: + app.wait(timeout=10) + except subprocess.TimeoutExpired: + app.kill() + app.wait() diff --git a/.github/workflows/release-rpm-smoke.yml b/.github/workflows/release-rpm-smoke.yml new file mode 100644 index 0000000000..440da7429d --- /dev/null +++ b/.github/workflows/release-rpm-smoke.yml @@ -0,0 +1,86 @@ +name: Release RPM smoke + +on: + workflow_dispatch: + inputs: + run-id: + description: Release workflow run containing the RPM artifacts (empty selects latest release branch run) + type: string + default: "" + pull_request: + paths: + - .github/workflows/release-rpm-smoke.yml + - .github/scripts/release-rpm-smoke.py + +permissions: + contents: read + actions: read + +jobs: + smoke: + timeout-minutes: 25 + strategy: + fail-fast: false + matrix: + platform: + - {arch: x86_64, runner: ubuntu-24.04} + - {arch: aarch64, runner: ubuntu-24.04-arm} + distro: [fedora, rocky, opensuse] + runs-on: ${{ matrix.platform.runner }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + persist-credentials: false + - name: Download the release packages + env: + GH_TOKEN: ${{ github.token }} + RUN_ID: ${{ inputs.run-id }} + ARCH: ${{ matrix.platform.arch }} + run: | + if [ -z "$RUN_ID" ]; then + RUN_ID=$(gh run list --workflow release.yml --branch release --limit 1 --json databaseId --jq '.[0].databaseId') + fi + [[ "$RUN_ID" =~ ^[0-9]+$ ]] + mkdir -p packages results + gh run view "$RUN_ID" --json headSha,url > results/source.json + gh run download "$RUN_ID" --name "release-linux-$ARCH" --dir packages + sha256sum packages/*.rpm > results/rpm-sha256.txt + - name: Install and start the RPM on the target distribution + env: + DISTRO: ${{ matrix.distro }} + run: | + sudo apt-get update -qq + sudo apt-get install -y xvfb + Xvfb :99 -screen 0 1440x900x24 -ac -nolisten tcp > results/xvfb.log 2>&1 & + for attempt in {1..20}; do + [ -S /tmp/.X11-unix/X99 ] && break + sleep 1 + done + case "$DISTRO" in + fedora) image=fedora:latest ;; + rocky) image=rockylinux:10 ;; + opensuse) image=opensuse/tumbleweed:latest ;; + esac + docker pull "$image" + docker image inspect "$image" --format '{{json .RepoDigests}}' > results/container-digest.json + docker run --rm --name rpm-smoke -e DISTRO -e DISPLAY=:99 -e LIBGL_ALWAYS_SOFTWARE=1 \ + -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v "$PWD/packages:/packages:ro" \ + -v "$PWD/results:/results" -v "$PWD/.github/scripts:/checks:ro" "$image" bash -euc ' + cat /etc/os-release > /results/os-release.txt + if [ "$DISTRO" = opensuse ]; then + zypper --non-interactive refresh + zypper --non-interactive install python3 Mesa-dri Mesa-libEGL1 libX11-6 libXcursor1 libXi6 libXrandr2 libxkbcommon0 + zypper --non-interactive --no-gpg-checks install /packages/*.rpm + else + dnf -y install python3 mesa-dri-drivers mesa-libEGL libX11 libXcursor libXi libXrandr libxkbcommon + dnf -y --nogpgcheck install /packages/*.rpm + fi + rpm -qp --requires /packages/*.rpm > /results/rpm-requires.txt + python3 /checks/release-rpm-smoke.py + ' + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 + if: always() + with: + name: rpm-smoke-${{ matrix.distro }}-${{ matrix.platform.arch }} + path: results/ + if-no-files-found: error