From a48adc85c61521d027de7732bffd94ab397b24f8 Mon Sep 17 00:00:00 2001 From: dsh Date: Tue, 10 Nov 2026 19:56:14 +0800 Subject: [PATCH] ci: install the toolchain again, from a domestic mirror Back to apt-get per run, but archive.ubuntu.com is the slowest hop here: the step rewrites sources.list (jammy and older) or the deb822 .sources (noble and newer) to TUNA before updating, then installs cmake/g++/make. APT_MIRROR is a knob -- aliyun and ustc are one edit away. ci/Dockerfile stays as the option for a runner that would rather bake the toolchain in. --- .gitea/workflows/ci.yml | 104 ++++++++++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 36 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 97c983e..ed9d31b 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -30,20 +30,28 @@ jobs: timeout-minutes: 20 steps: - uses: actions/checkout@v4 - # 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". + # The runner image is a bare ubuntu, so the toolchain is installed per run. + # Point apt at a domestic mirror first -- archive.ubuntu.com is the slowest + # hop on this network. Swap APT_MIRROR for mirrors.aliyun.com/ubuntu or + # mirrors.ustc.edu.cn/ubuntu if TUNA is unhappy. - name: toolchain + env: + DEBIAN_FRONTEND: noninteractive + APT_MIRROR: https://mirrors.tuna.tsinghua.edu.cn/ubuntu run: | set -eu - 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 + SUDO="" + command -v sudo >/dev/null 2>&1 && SUDO=sudo + # jammy and older keep sources.list; noble and newer use the deb822 + # .sources format, so rewrite whatever exists. + for f in /etc/apt/sources.list /etc/apt/sources.list.d/*.sources; do + [ -f "$f" ] || continue + $SUDO sed -i -E "s#https?://(archive|security|ports)\.ubuntu\.com/ubuntu#${APT_MIRROR}#g" "$f" done + $SUDO apt-get update -qq + $SUDO apt-get install -y -qq --no-install-recommends cmake g++ make cmake --version | head -1 - c++ --version | head -1 + g++ --version | head -1 echo "cores: $(nproc)" - name: configure run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release @@ -66,20 +74,28 @@ jobs: cell: [8, 16, 32] steps: - uses: actions/checkout@v4 - # 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". + # The runner image is a bare ubuntu, so the toolchain is installed per run. + # Point apt at a domestic mirror first -- archive.ubuntu.com is the slowest + # hop on this network. Swap APT_MIRROR for mirrors.aliyun.com/ubuntu or + # mirrors.ustc.edu.cn/ubuntu if TUNA is unhappy. - name: toolchain + env: + DEBIAN_FRONTEND: noninteractive + APT_MIRROR: https://mirrors.tuna.tsinghua.edu.cn/ubuntu run: | set -eu - 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 + SUDO="" + command -v sudo >/dev/null 2>&1 && SUDO=sudo + # jammy and older keep sources.list; noble and newer use the deb822 + # .sources format, so rewrite whatever exists. + for f in /etc/apt/sources.list /etc/apt/sources.list.d/*.sources; do + [ -f "$f" ] || continue + $SUDO sed -i -E "s#https?://(archive|security|ports)\.ubuntu\.com/ubuntu#${APT_MIRROR}#g" "$f" done + $SUDO apt-get update -qq + $SUDO apt-get install -y -qq --no-install-recommends cmake g++ make cmake --version | head -1 - c++ --version | head -1 + g++ --version | head -1 echo "cores: $(nproc)" - name: configure run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DR8FORGE_CELL_SIZE=${{ matrix.cell }} @@ -99,20 +115,28 @@ jobs: cell: [8, 11, 16, 24, 32] steps: - uses: actions/checkout@v4 - # 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". + # The runner image is a bare ubuntu, so the toolchain is installed per run. + # Point apt at a domestic mirror first -- archive.ubuntu.com is the slowest + # hop on this network. Swap APT_MIRROR for mirrors.aliyun.com/ubuntu or + # mirrors.ustc.edu.cn/ubuntu if TUNA is unhappy. - name: toolchain + env: + DEBIAN_FRONTEND: noninteractive + APT_MIRROR: https://mirrors.tuna.tsinghua.edu.cn/ubuntu run: | set -eu - 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 + SUDO="" + command -v sudo >/dev/null 2>&1 && SUDO=sudo + # jammy and older keep sources.list; noble and newer use the deb822 + # .sources format, so rewrite whatever exists. + for f in /etc/apt/sources.list /etc/apt/sources.list.d/*.sources; do + [ -f "$f" ] || continue + $SUDO sed -i -E "s#https?://(archive|security|ports)\.ubuntu\.com/ubuntu#${APT_MIRROR}#g" "$f" done + $SUDO apt-get update -qq + $SUDO apt-get install -y -qq --no-install-recommends cmake g++ make cmake --version | head -1 - c++ --version | head -1 + g++ --version | head -1 echo "cores: $(nproc)" - name: configure run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DR8FORGE_CELL_SIZE=${{ matrix.cell }} @@ -131,20 +155,28 @@ jobs: timeout-minutes: 60 steps: - uses: actions/checkout@v4 - # 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". + # The runner image is a bare ubuntu, so the toolchain is installed per run. + # Point apt at a domestic mirror first -- archive.ubuntu.com is the slowest + # hop on this network. Swap APT_MIRROR for mirrors.aliyun.com/ubuntu or + # mirrors.ustc.edu.cn/ubuntu if TUNA is unhappy. - name: toolchain + env: + DEBIAN_FRONTEND: noninteractive + APT_MIRROR: https://mirrors.tuna.tsinghua.edu.cn/ubuntu run: | set -eu - 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 + SUDO="" + command -v sudo >/dev/null 2>&1 && SUDO=sudo + # jammy and older keep sources.list; noble and newer use the deb822 + # .sources format, so rewrite whatever exists. + for f in /etc/apt/sources.list /etc/apt/sources.list.d/*.sources; do + [ -f "$f" ] || continue + $SUDO sed -i -E "s#https?://(archive|security|ports)\.ubuntu\.com/ubuntu#${APT_MIRROR}#g" "$f" done + $SUDO apt-get update -qq + $SUDO apt-get install -y -qq --no-install-recommends cmake g++ make cmake --version | head -1 - c++ --version | head -1 + g++ --version | head -1 echo "cores: $(nproc)" - name: configure run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release