From 5bc26f7762769f21f3800162a3ba29c901c238c9 Mon Sep 17 00:00:00 2001 From: dsh Date: Tue, 10 Nov 2026 19:52:35 +0800 Subject: [PATCH] ci: the image carries the toolchain, not the job An apt-get per run is slow, depends on the Ubuntu mirrors (the flakiest hop on this network) and makes a run non-reproducible. ci/Dockerfile builds the image once -- cmake, g++, make, git -- and the runner label points at it (ubuntu-latest:docker://r8forge-ci:24.04). The workflow now only proves the toolchain is there and explains how to fix a bare image, instead of installing it. --- .gitea/workflows/ci.yml | 76 ++++++++++++++++++++++------------------- ci/Dockerfile | 32 +++++++++++++++++ 2 files changed, 72 insertions(+), 36 deletions(-) create mode 100644 ci/Dockerfile diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index c9d4ed3..97c983e 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -30,19 +30,20 @@ jobs: timeout-minutes: 20 steps: - uses: actions/checkout@v4 - # The runner image is a bare ubuntu: no cmake, no compiler. Install the - # toolchain the build needs (and print it, so the log shows what we got). + # The image is expected to carry the toolchain already (ci/Dockerfile); + # this step only proves it and says how to fix a bare image, instead of + # failing later with "cmake: command not found". - name: toolchain - env: - DEBIAN_FRONTEND: noninteractive run: | set -eu - SUDO="" - command -v sudo >/dev/null 2>&1 && SUDO=sudo - $SUDO apt-get update -qq - $SUDO apt-get install -y -qq --no-install-recommends cmake g++ make + for tool in cmake c++ make; do + if ! command -v "$tool" >/dev/null 2>&1; then + echo "this runner image has no $tool -- build ci/Dockerfile and point the runner label at it" >&2 + exit 1 + fi + done cmake --version | head -1 - g++ --version | head -1 + c++ --version | head -1 echo "cores: $(nproc)" - name: configure run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release @@ -65,19 +66,20 @@ jobs: cell: [8, 16, 32] steps: - uses: actions/checkout@v4 - # The runner image is a bare ubuntu: no cmake, no compiler. Install the - # toolchain the build needs (and print it, so the log shows what we got). + # The image is expected to carry the toolchain already (ci/Dockerfile); + # this step only proves it and says how to fix a bare image, instead of + # failing later with "cmake: command not found". - name: toolchain - env: - DEBIAN_FRONTEND: noninteractive run: | set -eu - SUDO="" - command -v sudo >/dev/null 2>&1 && SUDO=sudo - $SUDO apt-get update -qq - $SUDO apt-get install -y -qq --no-install-recommends cmake g++ make + for tool in cmake c++ make; do + if ! command -v "$tool" >/dev/null 2>&1; then + echo "this runner image has no $tool -- build ci/Dockerfile and point the runner label at it" >&2 + exit 1 + fi + done cmake --version | head -1 - g++ --version | head -1 + c++ --version | head -1 echo "cores: $(nproc)" - name: configure run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DR8FORGE_CELL_SIZE=${{ matrix.cell }} @@ -97,19 +99,20 @@ jobs: cell: [8, 11, 16, 24, 32] steps: - uses: actions/checkout@v4 - # The runner image is a bare ubuntu: no cmake, no compiler. Install the - # toolchain the build needs (and print it, so the log shows what we got). + # The image is expected to carry the toolchain already (ci/Dockerfile); + # this step only proves it and says how to fix a bare image, instead of + # failing later with "cmake: command not found". - name: toolchain - env: - DEBIAN_FRONTEND: noninteractive run: | set -eu - SUDO="" - command -v sudo >/dev/null 2>&1 && SUDO=sudo - $SUDO apt-get update -qq - $SUDO apt-get install -y -qq --no-install-recommends cmake g++ make + for tool in cmake c++ make; do + if ! command -v "$tool" >/dev/null 2>&1; then + echo "this runner image has no $tool -- build ci/Dockerfile and point the runner label at it" >&2 + exit 1 + fi + done cmake --version | head -1 - g++ --version | head -1 + c++ --version | head -1 echo "cores: $(nproc)" - name: configure run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DR8FORGE_CELL_SIZE=${{ matrix.cell }} @@ -128,19 +131,20 @@ jobs: timeout-minutes: 60 steps: - uses: actions/checkout@v4 - # The runner image is a bare ubuntu: no cmake, no compiler. Install the - # toolchain the build needs (and print it, so the log shows what we got). + # The image is expected to carry the toolchain already (ci/Dockerfile); + # this step only proves it and says how to fix a bare image, instead of + # failing later with "cmake: command not found". - name: toolchain - env: - DEBIAN_FRONTEND: noninteractive run: | set -eu - SUDO="" - command -v sudo >/dev/null 2>&1 && SUDO=sudo - $SUDO apt-get update -qq - $SUDO apt-get install -y -qq --no-install-recommends cmake g++ make + for tool in cmake c++ make; do + if ! command -v "$tool" >/dev/null 2>&1; then + echo "this runner image has no $tool -- build ci/Dockerfile and point the runner label at it" >&2 + exit 1 + fi + done cmake --version | head -1 - g++ --version | head -1 + c++ --version | head -1 echo "cores: $(nproc)" - name: configure run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100644 index 0000000..8f471bf --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,32 @@ +# The CI image. +# +# A job container should not install packages: an apt-get per run is slow, needs +# the Ubuntu mirrors (often the flakiest part of a Chinese network) and is not +# reproducible. Build this image once on the runner host and point the +# act_runner label at it, then no job ever touches the network for a toolchain: +# +# docker build -t r8forge-ci:24.04 ci +# +# # ~/.config/act_runner/config.yaml (or the labels in the runner's env) +# labels: +# - ubuntu-latest:docker://r8forge-ci:24.04 +# +# # restart act_runner, then check "Last Online Time" in the runner list +# +# Everything a job needs is here: cmake, a C++20 compiler, make. act_runner +# mounts its own node into the container, so the image does not need node. +FROM ubuntu:24.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq \ + && apt-get install -y -qq --no-install-recommends \ + cmake \ + g++ \ + make \ + git \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# A quick smoke of the toolchain, so a broken image fails at build time. +RUN cmake --version | head -1 && g++ --version | head -1