diff options
| author | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 19:56:09 +0300 |
|---|---|---|
| committer | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 19:56:09 +0300 |
| commit | 7fb132859fda54aa96bc9dd46d302b343eeb5a02 (patch) | |
| tree | b43ae77d7451fb470a260c03349a1caf2846c5e5 /neozip/arch/s390/self-hosted-builder | |
| parent | b1e34e861b5d732afe828d58aad2c638135061fd (diff) | |
| parent | c2712b8a345191f6ed79558c089777df94590087 (diff) | |
| download | Project-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.tar.gz Project-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.zip | |
Add 'neozip/' from commit 'c2712b8a345191f6ed79558c089777df94590087'
git-subtree-dir: neozip
git-subtree-mainline: b1e34e861b5d732afe828d58aad2c638135061fd
git-subtree-split: c2712b8a345191f6ed79558c089777df94590087
Diffstat (limited to 'neozip/arch/s390/self-hosted-builder')
5 files changed, 209 insertions, 0 deletions
diff --git a/neozip/arch/s390/self-hosted-builder/actions-runner b/neozip/arch/s390/self-hosted-builder/actions-runner new file mode 100755 index 0000000000..aabc802547 --- /dev/null +++ b/neozip/arch/s390/self-hosted-builder/actions-runner @@ -0,0 +1,62 @@ +#!/bin/bash + +# +# Ephemeral runner startup script. +# +# Expects the following environment variables: +# +# - REPO=<owner> +# - PAT_TOKEN=<github_pat_***> +# + +set -e -u + +# Validate required environment variables +if [ -z "${REPO:-}" ] || [ -z "${PAT_TOKEN:-}" ]; then + echo "Error: REPO and/or PAT_TOKEN environment variables not found" + exit 1 +fi + +# Check the cached registration token. +TOKEN_FILE=registration-token.json +if [ -f $TOKEN_FILE ]; then + set +e + EXPIRES=$(jq --raw-output .expires_at "$TOKEN_FILE" 2>/dev/null) + STATUS=$? + set -e +else + STATUS=1 + EXPIRES="" +fi + +if [[ $STATUS -ne 0 || -z "$EXPIRES" || "$EXPIRES" == "null" || $(date +%s) -ge $(date -d "$EXPIRES" +%s) ]]; then + # Refresh the cached registration token. + curl \ + -sS \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $PAT_TOKEN" \ + "https://api.github.com/repos/$REPO/actions/runners/registration-token" \ + -o "$TOKEN_FILE" +fi + +REG_TOKEN=$(jq --raw-output .token "$TOKEN_FILE") +if [ $REG_TOKEN = "null" ]; then + echo "Failed to get registration token" + exit 1 +fi + +# (Re-)register the runner. +./config.sh remove --token "$REG_TOKEN" || true +set -x +./config.sh \ + --url "https://github.com/$REPO" \ + --token "$REG_TOKEN" \ + --unattended \ + --disableupdate \ + --replace \ + --labels z15 \ + --ephemeral + +# Run one job. +./run.sh diff --git a/neozip/arch/s390/self-hosted-builder/actions-runner-rebuild.sh b/neozip/arch/s390/self-hosted-builder/actions-runner-rebuild.sh new file mode 100644 index 0000000000..7fded31785 --- /dev/null +++ b/neozip/arch/s390/self-hosted-builder/actions-runner-rebuild.sh @@ -0,0 +1,52 @@ +#!/usr/bin/bash +set -ex + +TMPDIR="$(mktemp -d)" + +if [ -f actions-runner.Dockerfile ]; then + MODE=1 + cp actions-runner.Dockerfile actions-runner entrypoint $TMPDIR + cd $TMPDIR +else + MODE=2 + cd $TMPDIR + wget https://raw.githubusercontent.com/zlib-ng/zlib-ng/refs/heads/develop/arch/s390/self-hosted-builder/actions-runner.Dockerfile + wget https://raw.githubusercontent.com/zlib-ng/zlib-ng/refs/heads/develop/arch/s390/self-hosted-builder/actions-runner + wget https://raw.githubusercontent.com/zlib-ng/zlib-ng/refs/heads/develop/arch/s390/self-hosted-builder/entrypoint +fi + +# Stop service +systemctl stop actions-runner || true + +# Delete old container +podman container rm gaplib-actions-runner || true + +# Delete old image +podman image rm localhost/zlib-ng/actions-runner || true + +# Prune all unused podman data +podman system prune -f || true + +# Build new image +podman build --squash -f actions-runner.Dockerfile --tag zlib-ng/actions-runner . 2>&1 | tee /var/log/actions-runner-build.log + +# Create new container +podman create --replace --name=gaplib-actions-runner --env-file=/etc/actions-runner --init \ + zlib-ng/actions-runner 2>&1 | tee -a /var/log/actions-runner-build.log + +# Start service +systemctl start actions-runner || true + +# Cleanup +podman image prune -af || true + +# Clean up tempfile +if [ "$MODE" == "2" ] ; then + cd $TMPDIR + rm actions-runner.Dockerfile + rm actions-runner + rm entrypoint + cd .. + rmdir $TMPDIR + echo "Deleted tempfiles." +fi diff --git a/neozip/arch/s390/self-hosted-builder/actions-runner.Dockerfile b/neozip/arch/s390/self-hosted-builder/actions-runner.Dockerfile new file mode 100644 index 0000000000..7210caaebe --- /dev/null +++ b/neozip/arch/s390/self-hosted-builder/actions-runner.Dockerfile @@ -0,0 +1,47 @@ +# Self-Hosted IBM Z Github Actions Runner. + +FROM almalinux:10 + +RUN dnf update -y -q && \ + dnf install -y -q --enablerepo=crb wget git which sudo jq sed \ + cmake make automake autoconf m4 libtool ninja-build \ + python3-pip python3-devel python3-lxml \ + gcc gcc-c++ clang llvm-toolset glibc-all-langpacks langpacks-en \ + glibc-static libstdc++-static libstdc++-devel libxslt-devel libxml2-devel + +RUN dnf install -y -q dotnet-sdk-8.0 && \ + echo "Using SDK - `dotnet --version`" + +RUN cd /tmp && \ + git clone -q https://github.com/actions/runner && \ + cd runner && \ + git checkout $(git tag --sort=-v:refname | grep '^v[0-9]' | head -n1) && \ + git log -n 1 && \ + wget https://raw.githubusercontent.com/IBM/action-runner-image-pz/refs/heads/main/patches/runner-sdk8-s390x.patch -O runner-sdk8-s390x.patch && \ + git apply --whitespace=nowarn runner-sdk8-s390x.patch && \ + + sed -i'' -e /version/s/8......\"$/$8.0.100\"/ src/global.json + +RUN cd /tmp/runner/src && \ + ./dev.sh layout && \ + ./dev.sh package && \ + rm -rf /root/.dotnet /root/.nuget + +RUN useradd -c "Action Runner" -m actions-runner && \ + usermod -L actions-runner + +RUN tar -xf /tmp/runner/_package/*.tar.gz -C /home/actions-runner && \ + chown -R actions-runner:actions-runner /home/actions-runner + +# Cleanup +RUN rm -rf /tmp/runner /var/cache/dnf/* /tmp/runner.patch /tmp/global.json && \ + dnf clean all + +USER actions-runner + +# Scripts. +COPY --chmod=555 entrypoint /usr/bin/ +COPY --chmod=555 actions-runner /usr/bin/ +WORKDIR /home/actions-runner +ENTRYPOINT ["/usr/bin/entrypoint"] +CMD ["/usr/bin/actions-runner"] diff --git a/neozip/arch/s390/self-hosted-builder/actions-runner.service b/neozip/arch/s390/self-hosted-builder/actions-runner.service new file mode 100644 index 0000000000..79560cde18 --- /dev/null +++ b/neozip/arch/s390/self-hosted-builder/actions-runner.service @@ -0,0 +1,18 @@ +[Unit] +Description=Podman container: Gaplib Github Actions Runner +Wants=network-online.target +After=network-online.target +StartLimitIntervalSec=1 +RequiresMountsFor=/run/user/1001/containers + +[Service] +Environment=PODMAN_SYSTEMD_UNIT=%n +Restart=always +TimeoutStopSec=61 +ExecStart=/usr/bin/podman start gaplib-actions-runner +ExecStop=/usr/bin/podman stop -t 30 gaplib-actions-runner +ExecStopPost=/usr/bin/podman stop -t 10 gaplib-actions-runner +Type=forking + +[Install] +WantedBy=default.target diff --git a/neozip/arch/s390/self-hosted-builder/entrypoint b/neozip/arch/s390/self-hosted-builder/entrypoint new file mode 100755 index 0000000000..eb8772becf --- /dev/null +++ b/neozip/arch/s390/self-hosted-builder/entrypoint @@ -0,0 +1,30 @@ +#!/bin/bash + +# +# Container entrypoint that waits for all spawned processes. +# + +set -e -u + +# Create a FIFO and start reading from its read end. +tempdir=$(mktemp -d "/tmp/done.XXXXXXXXXX") +trap 'rm -r "$tempdir"' EXIT +done="$tempdir/pipe" +mkfifo "$done" +cat "$done" & waiter=$! + +# Start the workload. Its descendants will inherit the FIFO's write end. +status=0 +if [ "$#" -eq 0 ]; then + bash 9>"$done" || status=$? +else + "$@" 9>"$done" || status=$? +fi + +# When the workload and all of its descendants exit, the FIFO's write end will +# be closed and `cat "$done"` will exit. Wait until it happens. This is needed +# in order to handle SelfUpdater, which the workload may start in background +# before exiting. +wait "$waiter" + +exit "$status" |
