From f311904bb566c8d167101d3e3c4c8d476a4ddb7d Mon Sep 17 00:00:00 2001 From: Agel Date: Tue, 24 Mar 2026 13:34:44 +0100 Subject: [PATCH] Try to switch to personal shell runner --- .gitlab-ci.yml | 64 +++++++++++++++++++++++++---------------- docker/Dockerfile.build | 15 ++++++++-- docker/entrypoint.sh | 19 ++++++++++++ 3 files changed, 71 insertions(+), 27 deletions(-) create mode 100644 docker/entrypoint.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 593d772..f677bee 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,18 @@ workflow: auto_cancel: on_new_commit: interruptible + rules: + - if: $FORCE_REBUILD_IMAGE == "true" + variables: + CI_PIPELINE_TYPE: image-rebuild + - changes: + - docker/Dockerfile.build + - scripts/mingw-w64-toolchain.cmake + - scripts/install-deps-ubuntu.sh + variables: + CI_PIPELINE_TYPE: image-rebuild + - variables: + CI_PIPELINE_TYPE: normal stages: - build @@ -9,9 +21,9 @@ stages: - wiki variables: - DOCKER_IMAGE: "${CI_REGISTRY_IMAGE}/build-env:latest" + GIT_CLEAN_FLAGS: -fdx -# ── Build the custom Docker image (only when Dockerfile changes) ─────────────── +# ── Build the runner image and push to registry ──────────────────────────────── build-docker: stage: build image: docker:27 @@ -19,6 +31,7 @@ build-docker: - docker:27-dind variables: DOCKER_TLS_CERTDIR: "/certs" + DOCKER_IMAGE: "${CI_REGISTRY_IMAGE}/build-env:latest" before_script: - docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}" script: @@ -28,20 +41,12 @@ build-docker: -f docker/Dockerfile.build . - docker push "${DOCKER_IMAGE}" rules: - - changes: - - docker/Dockerfile.build - - scripts/mingw-w64-toolchain.cmake - - scripts/install-deps-ubuntu.sh - - if: $FORCE_REBUILD_IMAGE == "true" + - if: $CI_PIPELINE_TYPE == "image-rebuild" # ── Linux native build ───────────────────────────────────────────────────────── build-linux: interruptible: true stage: build - image: "${DOCKER_IMAGE}" - needs: - - job: build-docker - optional: true script: - cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="${QT_LINUX_DIR}" @@ -52,15 +57,15 @@ build-linux: - build-linux/asteria-qt expire_in: 1 day when: on_success + rules: + - if: $CI_PIPELINE_TYPE == "image-rebuild" + when: never + - when: on_success # ── Windows cross-compile build (MinGW-w64) ─────────────────────────────────── build-windows: interruptible: true stage: build - image: "${DOCKER_IMAGE}" - needs: - - job: build-docker - optional: true script: - PKG_CONFIG_PATH="${MINGW_SYSROOT}/lib/pkgconfig" cmake -B build-windows -G Ninja -DCMAKE_BUILD_TYPE=Release @@ -75,26 +80,29 @@ build-windows: - build-windows/asteria-qt.exe expire_in: 1 day when: on_success + rules: + - if: $CI_PIPELINE_TYPE == "image-rebuild" + when: never + - when: on_success # ── Linux tests ──────────────────────────────────────────────────────────────── test-linux: interruptible: true stage: test - image: "${DOCKER_IMAGE}" - needs: - - job: build-docker - optional: true script: - cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="${QT_LINUX_DIR}" - cmake --build build-linux - QT_QPA_PLATFORM=offscreen ctest --test-dir build-linux --output-on-failure + rules: + - if: $CI_PIPELINE_TYPE == "image-rebuild" + when: never + - when: on_success # ── Package Linux as AppImage ───────────────────────────────────────────── package-linux: interruptible: true stage: package - image: "${DOCKER_IMAGE}" needs: - build-linux - test-linux @@ -107,12 +115,15 @@ package-linux: - dist/*.AppImage expire_in: 1 day when: on_success + rules: + - if: $CI_PIPELINE_TYPE == "image-rebuild" + when: never + - when: on_success # ── Package Windows as portable zip ────────────────────────────────────────── package-windows: interruptible: true stage: package - image: "${DOCKER_IMAGE}" needs: - build-windows script: @@ -124,16 +135,17 @@ package-windows: - asteria-qt-windows/ expire_in: 1 day when: on_success + rules: + - if: $CI_PIPELINE_TYPE == "image-rebuild" + when: never + - when: on_success # ── Update wiki with latest dev build links ──────────────────────────────────── update-wiki: stage: wiki - image: alpine:latest needs: - package-linux - package-windows - before_script: - - apk add --no-cache curl jq script: - | if [ -z "${GITLAB_TOKEN}" ]; then @@ -170,11 +182,13 @@ update-wiki: --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \ --header "Content-Type: application/json" \ --data "$(jq -n --arg c "${UPDATED}" '{content:$c}')" \ - "${WIKI_URL}" + "${WIKI_URL}" else echo "ERROR: GitLab API returned HTTP ${HTTP_CODE}" cat /tmp/wiki.json exit 1 fi rules: + - if: $CI_PIPELINE_TYPE == "image-rebuild" + when: never - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH diff --git a/docker/Dockerfile.build b/docker/Dockerfile.build index 620b445..6435157 100644 --- a/docker/Dockerfile.build +++ b/docker/Dockerfile.build @@ -119,7 +119,18 @@ RUN wget -q https://github.com/AppImage/appimagetool/releases/download/continuou # ── file utility (needed by linuxdeploy for ELF detection) ────────────────── RUN apt-get update -qq && \ - apt-get install -y --no-install-recommends file patchelf zip && \ + apt-get install -y --no-install-recommends file patchelf zip curl jq && \ rm -rf /var/lib/apt/lists/* -WORKDIR /build +# ── gitlab-runner (shell executor) ─────────────────────────────────────────── +RUN wget -q https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 \ + -O /usr/local/bin/gitlab-runner && \ + chmod +x /usr/local/bin/gitlab-runner && \ + mkdir -p /etc/gitlab-runner /builds && \ + chmod 777 /builds + +COPY docker/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] +CMD [] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 0000000..e63d5f6 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e + +# Auto-register if no config exists and env vars are provided +if [ ! -f /etc/gitlab-runner/config.toml ] && \ + [ -n "${CI_SERVER_URL}" ] && [ -n "${REGISTRATION_TOKEN}" ]; then + gitlab-runner register \ + --non-interactive \ + --url "${CI_SERVER_URL}" \ + --registration-token "${REGISTRATION_TOKEN}" \ + --executor shell \ + --shell bash \ + --description "${RUNNER_NAME:-asteria-qt-runner}" \ + --tag-list "${RUNNER_TAGS:-}" \ + --run-untagged="${RUNNER_RUN_UNTAGGED:-true}" \ + --locked="${RUNNER_LOCKED:-false}" +fi + +exec gitlab-runner run --working-directory=/builds