Skip to content

ci(container): [#2323] run the container test job on the Hetzner runner - #2352

Merged
josecelano merged 14 commits into
torrust:developfrom
josecelano:2323-1840-hetzner-self-hosted-ci-runner
Sep 27, 2026
Merged

josecelano merged 14 commits into
torrust:developfrom
josecelano:2323-1840-hetzner-self-hosted-ci-runner

Conversation

@josecelano

@josecelano josecelano commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Implementation PR for #2323 (EPIC #1840): run the container.yaml Test (Docker) job, and the testing.yaml docker-e2e job, on the persistent self-hosted Hetzner runner torrust-runner-01, under the controls agreed in the spec (#2335).

Result so far: this PR's Test (Docker) job runs on the Hetzner runner in 14 min 31 s (partly warm) and 2 min 15 s (fully warm), against the 37-minute baseline median.

What is included

  • T4, ADR docs/adrs/20260926142648_adopt_self_hosted_hetzner_runner_for_container_tests.md: cost rationale, the 2026-09-24 rejection and 2026-09-25 reversal with the contribution data, the six controls the decision depends on, runner layout, cache strategy, offline handling, revisit conditions, and alternatives. Registered in docs/adrs/index.md.
  • Spec alignment in docs/issues/open/2323-1840-hetzner-self-hosted-ci-runner/ISSUE.md: the seven open questions answered, docker-e2e added as T5(f), offline alerting replaced by queued-check visibility plus a manual fallback (AC4, M5), task and acceptance status, and the progress log.
  • T5, workflow change set:
    • container.yaml test runs on [self-hosted, torrust-hetzner] for PRs targeting develop and pushes to develop in torrust/torrust-tracker. Dependabot PRs (selected by PR author, not github.actor), PRs to main, pushes to main and releases/**, and runs in forks stay on ubuntu-latest.
    • On the self-hosted runner, jobs use the default docker Buildx driver (local layers and cache mounts), keep host-side Cargo builds in a persistent CARGO_TARGET_DIR outside the cleaned workspace, and write no GitHub Actions cache (no type=gha, rust-cache, or sccache).
    • publish_development and publish_release import and export no GitHub Actions cache, because a job holding a develop cache token could write any scope they read.
    • testing.yaml docker-e2e follows the same rules and also keeps pushes to dependabot/ branches on ubuntu-latest, because those branches live in this repository and trigger it without approval.
  • T6, first validation (manual-verification-evidence.md, V1): the first run on the runner was killed by an out-of-memory condition (8 parallel rustc on 16 GB without swap), which also stopped the runner service. Fixed with a 16 GB swap file and a Restart=on-failure drop-in; the re-run passed.
  • T7, timings (benchmark-results.md): partly warm and fully warm runs on the same commit, with host cache and disk usage.
  • T8, guide docs/self-hosted-runner.md, listed in docs/index.md: which jobs use the runner, the security rules, the setup from an empty server to a registered runner, and operations (status checks, offline recovery and fallback, cache cleanup, agent updates, server rebuild).
  • Server setup log (runner-server-setup.md, steps 9 to 12): libssl-dev, the daily Docker prune timer, swap, and the restart drop-in. The two setup logs keep the history and point to the guide for the current procedure.

Validation

  • ./contrib/dev-tools/git/hooks/pre-commit.sh passed for every commit (includes linter all, cargo machete, and doc tests).
  • actionlint (official container image) reports no expression or type errors in the two changed workflows; its shellcheck notes are the same 10 that develop already has.
  • Hosted evidence: Container run 36298632207 on this PR, attempts 2 and 3, both on torrust-runner-01; the Docker E2E job was skipped as expected for a PR to develop.

After merge

These scenarios can only be verified after the merge or with later PRs, so this PR does not close #2323:

  • M2 and M3: the first develop push runs test on the runner, and the publish job builds with no GitHub Actions cache.
  • M4 and M6: timing of a PR that changes application code.
  • M7: a Dependabot PR runs on ubuntu-latest, also after a maintainer updates it from develop.
  • M5: the offline-runner scenario, at a quiet time.

A final docs PR records that evidence and closes #2323.

Related to #2323

@josecelano josecelano self-assigned this Sep 27, 2026
josecelano added a commit to josecelano/torrust-tracker that referenced this pull request Sep 27, 2026
Add manual-verification-evidence.md with V1 (M1): PR torrust#2352's Test (Docker) job ran on torrust-runner-01 and passed in 14 min 31 s after the out-of-memory fix, with attempt 1's failure and remediation recorded. Point the spec at PR torrust#2352, mark T6 in progress and M1 done, and make T8 a standalone setup-and-operations guide at docs/self-hosted-runner.md (AC6).
@josecelano
josecelano force-pushed the 2323-1840-hetzner-self-hosted-ci-runner branch from 5025e02 to a7f403a Compare September 27, 2026 09:45
@josecelano
josecelano marked this pull request as ready for review September 27, 2026 09:45
@josecelano
josecelano requested a review from a team as a code owner September 27, 2026 09:45
Copilot AI lite review requested due to automatic review settings September 27, 2026 09:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 3 Medium severity · 1 Low severity

Open (4)
What changed in this PR

Moves container-related CI workloads onto a persistent self-hosted Hetzner runner (under documented security/operational controls) and adds the supporting ADR/spec/docs and benchmark evidence.

Changes:

  • Route container.yaml Test (Docker) and testing.yaml Docker E2E to the Hetzner self-hosted runner under specific trust/routing rules (Dependabot/forks/main/release protections preserved).
  • Stop using GHA caches on self-hosted runs; add persistent host-side Cargo target dirs and adjust Buildx driver selection.
  • Add ADR + operational guide + evidence/benchmarks/spec updates documenting security controls, setup, and validation.
File Description
docs/​self-hosted-runner.md New maintainer guide for provisioning and operating the Hetzner runner (security rules, setup steps, operations).
docs/​issues/​open/​2323-1840-hetzner-self-hosted-ci-runner/​runner-server-setup.md Extends historical setup log with swap/prune details and points readers to the new guide.
docs/​issues/​open/​2323-1840-hetzner-self-hosted-ci-runner/​runner-agent-installation.md Clarifies historical vs current procedure and links to the new guide.
docs/​issues/​open/​2323-1840-hetzner-self-hosted-ci-runner/​manual-verification-evidence.md Adds real-run verification evidence and remediation notes.
docs/​issues/​open/​2323-1840-hetzner-self-hosted-ci-runner/​benchmark-results.md Adds post-change timing measurements on the self-hosted runner.
docs/​issues/​open/​2323-1840-hetzner-self-hosted-ci-runner/​ISSUE.md Updates spec alignment, task/AC statuses, and records answered open questions.
docs/​index.md Registers the new self-hosted runner guide in the docs index.
docs/​adrs/​index.md Registers the new ADR in the ADR index.
docs/​adrs/​20260926142648_adopt_self_hosted_hetzner_runner_for_container_tests.md New ADR capturing decision, controls, and consequences for the self-hosted runner.
.github/​workflows/​testing.yaml Routes Docker E2E to self-hosted runner (with exceptions) + disables caches on self-hosted.
.github/​workflows/​container.yaml Routes Test (Docker) to self-hosted runner for develop traffic + disables caches on self-hosted/publish.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/container.yaml Resolved
Comment thread .github/workflows/testing.yaml Resolved
Comment thread docs/self-hosted-runner.md Resolved
Comment thread .github/workflows/testing.yaml Resolved
Record the torrust#2323 decision to run the container test and Docker E2E jobs on one persistent Hetzner runner: cost rationale from the T1 baseline, the 2026-09-24 rejection and the 2026-09-25 reversal with the contribution data behind it, the six controls it depends on (external-contributor approval, required 2FA, Dependabot by PR author and main/releases on GitHub-hosted runners, cache-free publish builds, regular rebuild), runner layout, cache strategy, offline handling without automatic fallback, revisit conditions, and alternatives.
Mark T4 done and AC5 met by the approved ADR, record the maintainer's answers to the seven open questions, add the docker-e2e move as T5(f) and to AC1, and replace offline alerting with queued-check visibility plus a manual fallback in the Deadline passage, T8, AC4, M5, and the single-point-of-failure risk. Point the spec at the implementation branch.
Implement torrust#2323 T5 as one change set, per ADR 20260926142648:

- container.yaml test: runs on [self-hosted, torrust-hetzner] for PRs targeting develop and pushes to develop in torrust/torrust-tracker; Dependabot PRs (by PR author), PRs to main, pushes to main and releases/**, and runs in forks stay on ubuntu-latest.
- On the self-hosted runner the jobs use the default docker Buildx driver (local layers and cache mounts), a persistent CARGO_TARGET_DIR outside the cleaned workspace, and write no GHA cache (no type=gha, rust-cache, or sccache).
- publish_development and publish_release import and export no GHA cache, because a job holding a develop cache token could write any scope they read.
- testing.yaml docker-e2e: same runner and cache rules; also excludes pushes to dependabot/ branches, which live in this repository and run without approval.
Implementing T5 showed that pushes to dependabot/ branches trigger testing.yaml in this repository without approval, so docker-e2e must keep them off the self-hosted runner as well. Record the rule in the ADR's Dependabot control and in T5(f).
The E2E tools compile on the host and depend on openssl-sys without vendored OpenSSL, so the runner host needs the system headers. Record the installation in the server setup log.
T5(b) keeps Docker layers and BuildKit cache mounts on the runner host, so a daily root systemd timer now caps the build cache at 120 GB and removes stale containers, images, and anonymous volumes. Record the unit files, the commands, and the verified first run in the server setup log.
The first self-hosted Test (Docker) run was cancelled by a global out-of-memory kill during the workspace compile (8 parallel rustc on 16 GB without swap), which also left the runner service failed. Record the diagnosis and the fix (16 GB swap file, Restart=on-failure drop-in) as setup step 12, log it in the spec, and move step 11 after step 10, where the previous commit misplaced it.
Add manual-verification-evidence.md with V1 (M1): PR torrust#2352's Test (Docker) job ran on torrust-runner-01 and passed in 14 min 31 s after the out-of-memory fix, with attempt 1's failure and remediation recorded. Point the spec at PR torrust#2352, mark T6 in progress and M1 done, and make T8 a standalone setup-and-operations guide at docs/self-hosted-runner.md (AC6).
Add the first T7 measurements from Container run 36298632207 on torrust-runner-01: 14 min 31 s for the partly warm attempt after the out-of-memory fix and 2 min 15 s fully warm on the same commit, against the 37-minute baseline median, with the host's cache and disk usage. The application-code-change case (M4) is still to be measured.
Add docs/self-hosted-runner.md (torrust#2323 T8): which jobs use the runner, the security rules the ADR depends on, the setup of a new runner from an empty Hetzner server to a registered runner, and operations (status checks, offline recovery and fallback, cache cleanup, agent updates, server rebuild, a second instance). List it in docs/index.md, point the two setup logs at it as the current procedure, and mark T8 and AC6 done.
…hecks

Container run 36310358131 built PR torrust#2352 after a rebase onto Rust changes: Test (Docker) took 12 min 3 s on torrust-runner-01, with the third-party layers cached and the workspace compile at 561 s, and the PR checks finished in 17 min 49 s end to end against 32 to 46 min in the baseline. Record queue time, the transfer note, and scenarios A and G (the testing.yaml unit jobs are now the critical path), add evidence V4, and mark T7, M4, M6, and AC2 done.
The docker-e2e runs-on expression applied the PR-author check to every event and relied on github.event.pull_request being null on pushes. Branch explicitly: pull_request events exclude Dependabot by PR author and head branch, push events exclude dependabot/ branches, and any other event stays on ubuntu-latest. Behavior is unchanged for the two events testing.yaml triggers on.
@josecelano
josecelano force-pushed the 2323-1840-hetzner-self-hosted-ci-runner branch from a7f403a to 4f22e84 Compare September 27, 2026 18:06
Record the four Copilot findings on PR torrust#2352 with their dispositions, reply URLs, and Processing Log, validated with validate-audit-record.py.
Record the prescribed supersession replies for F1 to F3 and their resolved GitHub review threads.
@josecelano

Copy link
Copy Markdown
Member Author

ACK 57053de

@josecelano
josecelano merged commit 432d4e6 into torrust:develop Sep 27, 2026
20 checks passed
josecelano added a commit to josecelano/torrust-tracker that referenced this pull request Sep 28, 2026
Record the successful self-hosted test and GitHub-hosted development-image publish after PR torrust#2352 merged.
josecelano added a commit to josecelano/torrust-tracker that referenced this pull request Sep 28, 2026
Record the successful self-hosted test and GitHub-hosted development-image publish after PR torrust#2352 merged.
josecelano added a commit that referenced this pull request Sep 28, 2026
70299b3 docs(pr-reviews): add PR #2355 review audit (Jose Celano)
798f4ae docs(issues): complete #2323 workflow evidence (Jose Celano)
4abf5d9 docs(issues): record #2323 develop-run verification (Jose Celano)

Pull request description:

  ## Summary
  - Record the successful post-merge Container workflow for PR #2352.
  - Document the self-hosted test runner and GitHub-hosted development-image publish evidence.
  - Mark T6 and manual scenarios M2/M3 complete; leave the offline and untrusted-routing scenarios pending.

  ## Files
  - `docs/issues/open/2323-1840-hetzner-self-hosted-ci-runner/ISSUE.md`
  - `docs/issues/open/2323-1840-hetzner-self-hosted-ci-runner/manual-verification-evidence.md`

  ## Validation
  - `TORRUST_GIT_HOOKS_LOG_DIR=.tmp ./contrib/dev-tools/git/hooks/pre-commit.sh`

  Related to #2323

ACKs for top commit:
  josecelano:
    ACK 70299b3

Tree-SHA512: eea016f5639a7c2e61342afb84613f832bed0419c97c0874fb238e95d16083195a4c0a95aa7e3ffa9bc959c9158e66cb0ed5831097a1f1b62fbd0566eede32e6

@da2ce7 da2ce7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a post-merge review of #2352 as it stands at f72f93c5c on the default branch.

What still runs: the Test (Docker) job of .github/workflows/container.yaml selects the torrust-hetzner self-hosted runner for pull requests targeting develop that Dependabot did not open, and for pushes to develop (.github/workflows/container.yaml:65-72). The Docker E2E job of .github/workflows/testing.yaml selects it for the other pull requests and pushes of this repository, except Dependabot's (.github/workflows/testing.yaml:246-263). On that runner both jobs use the docker Buildx driver, keep host-side Cargo output in a persistent CARGO_TARGET_DIR, and import and export no GitHub Actions cache; the publish jobs stay on ubuntu-latest. Later commits added a concurrency group and moved the compile-cache setup into .github/actions/enable-sccache, without changing the runner selection.

[Minor] The ADR keeps GitHub Actions cache out of the publish builds because a cache scope is a key name, not a producer identity, and entries written in the develop scope can be restored from every branch (docs/adrs/20260926142648_adopt_self_hosted_hetzner_runner_for_container_tests.md:82-86). Since #2352, the develop push run of Test (Docker) executes on the self-hosted runner (.github/workflows/container.yaml:65-72) and, like every job, receives a cache token for that scope. The same reasoning therefore applies to other hosted jobs that restore cache from that scope while holding a secret or preparing an agent session, but the control does not name them. Generate Coverage Report runs on develop pushes in the coverage environment with CODECOV_TOKEN and compiles through the sccache GitHub Actions backend (.github/workflows/coverage.yaml:18, :38-44, :63). The agent setup job restores Swatinem/rust-cache (.github/workflows/copilot-setup-steps.yml:40). The hosted Test (Docker) runs of main and releases/** pushes restore rust-cache and type=gha cache (.github/workflows/container.yaml:105-108, :129). Today these jobs rely on maintainers approving a run on the self-hosted runner only after reviewing its full diff (docs/self-hosted-runner.md:123-125). Extending the control is hardening: the bound stated at :89 of the ADR would then hold by construction, not by that review alone. Smallest fix: widen the fifth control to every hosted job that holds a secret, prepares an agent session or gates a release. Drop the shared cache from the coverage and agent setup jobs, and restore the test job's cache only on pull_request events.

[Minor] Docker E2E selects the self-hosted runner for more traffic than the ADR's fourth control describes. This is a hardening and documentation gap, not a defect in the tests. The control says only develop traffic uses the runner (docs/adrs/20260926142648_adopt_self_hosted_hetzner_runner_for_container_tests.md:79-81), and the guide says to keep main, releases/** and publishing off it (docs/self-hosted-runner.md:127). However, testing.yaml runs on every push with no branch filter (.github/workflows/testing.yaml:10-13), and the job's if: excludes only develop, main and releases/ events (.github/workflows/testing.yaml:257-263). The runner is therefore also selected for the staging/main and staging/develop pushes of the release procedure (docs/release-process/tracker.md:37, :109), for tag pushes, including the release tag (docs/release-process/tracker.md:90), and for pull requests that target a releases/v* or staging/* branch. The guide's routing table (docs/self-hosted-runner.md:28) names branches only, and the description of #2352 said this job follows the same rules as the container job. Smallest fix: in the push arm of the runs-on expression, require startsWith(github.ref, 'refs/heads/') and exclude refs/heads/staging/; in the pull-request arm, exclude releases/ and staging/ bases. Otherwise, state the job's actual scope in the ADR and the guide.

[Minor] Neither .github/workflows/container.yaml nor .github/workflows/testing.yaml declares permissions:, so the token of the jobs that can run on the self-hosted runner takes the repository's default permission. That default is recorded as read-only (docs/issues/closed/2323-1840-hetzner-self-hosted-ci-runner/self-hosted-runner-security-research.md:30), but it is neither one of the ADR's controls (docs/adrs/20260926142648_adopt_self_hosted_hetzner_runner_for_container_tests.md:67-87) nor one of the settings the guide asks maintainers to keep (docs/self-hosted-runner.md:126). If that repository-wide setting changes later, the token of these jobs widens without any change to either workflow. This is a hardening item: nothing is wrong while the setting stays read-only. Smallest fix: add permissions: contents: read to the test job (.github/workflows/container.yaml:39) and the docker-e2e job (.github/workflows/testing.yaml:234), as the least-privilege rule in .github/workflows/AGENTS.md:15 asks.

[Nit] The pull-request arm of the container job (.github/workflows/container.yaml:68-69) checks only the pull request's author, while Docker E2E also excludes dependabot/ head branches (.github/workflows/testing.yaml:251). The ADR's third control keeps Dependabot changes on GitHub-hosted runners (docs/adrs/20260926142648_adopt_self_hosted_hetzner_runner_for_container_tests.md:73-78), but a pull request to develop that a maintainer opens from a Dependabot branch selects the self-hosted runner. This is hardening, to make the two expressions agree. Smallest fix: add !startsWith(github.head_ref, 'dependabot/') to that arm.

[Nit] The ADR says disk growth is bounded by scheduled pruning (docs/adrs/20260926142648_adopt_self_hosted_hetzner_runner_for_container_tests.md:106-107), but the daily prune does not cover the host-side Cargo target directories that #2352 introduced (.github/workflows/container.yaml:114, .github/workflows/testing.yaml:290). The guide says so, records 23 GiB after 30 days, and leaves deletion as a manual last resort (docs/self-hosted-runner.md:425-430), so the directories grow until the server is rebuilt. This is operational hardening. Smallest fix: let the daily prune remove ~runner/.cache/torrust-tracker/*-target above a size cap while the runner is idle, or correct the ADR's sentence.

Checked and found sound:

  • Both runs-on expressions resolve to the self-hosted label set or to ubuntu-latest as described, and a run in a fork's own repository stays on ubuntu-latest.
  • Dependabot pull requests are selected by author, which a maintainer's branch update does not change.
  • Pull requests to main and pushes to main and releases/** keep Test (Docker) on ubuntu-latest.
  • The empty cache-from and cache-to turn cache use off on the self-hosted runner.
  • The publish jobs run on ubuntu-latest, build from their own checkout, and take only the test result through needs:.
  • The context job reads only event data.
  • No job that can select the self-hosted runner references a secret or an environment.

This branch was previously deployed

1 inactive deployment
coverage — 57053dec Deployed Sep 27, 2026 by josecelano via Generate Coverage Report #2337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Free Github Runner Bottleneck delays

3 participants