Skip to content

feat(ci): eliminate duplicate E2E tests and slim nextest archive - #1874

Merged
josecelano merged 4 commits into
torrust:developfrom
josecelano:1854-container-test-gating
Jun 4, 2026
Merged

josecelano merged 4 commits into
torrust:developfrom
josecelano:1854-container-test-gating

Conversation

@josecelano

@josecelano josecelano commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

Closes #1854

Summary

Eliminates duplicated E2E test work between container.yaml and testing.yaml,
removes the unused debug CI matrix target, documents the test binary
landscape, and slims cargo nextest archive by extracting dev-only packages.

Changes

.github/workflows/container.yaml

  • Remove debug from test matrix — only release built in CI (saves ~40 min per trigger)
  • Replace docker image inspect step with four E2E test steps run immediately after
    docker build: e2e_tests_runner + qBittorrent E2E for sqlite3, mysql, postgresql
  • Add setup-toolchain, cache, and fetch steps so cargo run can invoke the E2E runners
  • Warm publish_development and publish_release cache from container-release scope to
    avoid redundant full rebuilds on the same commit
  • Add detailed comments explaining: unit test environment (tester uses rust:slim-trixie, not
    distroless), cache flow, and docker-e2e skip rationale

.github/workflows/testing.yaml

  • Add if: skip condition to docker-e2e job so it does not run when container.yaml already
    covers the same trigger (PRs targeting develop/main; pushes to develop/main/releases/**)
  • Add explanatory comment above the condition

docs/adrs/20260603000000_keep_unit_tests_inside_container_build.md (new)

  • ADR recording the decision to keep unit tests inside the Containerfile build
  • Includes environment comparison table (rust:slim-trixie vs distroless/cc-debian13),
    three-layer defence-in-depth strategy, and rejected alternative

docs/adrs/index.md

  • Add row for the new ADR

docs/issues/open/1854-1840-workflow-performance-container-test-gating/ISSUE.md

  • Add full Analysis Findings (T1–T6), Implementation Plan (T1–T14), and Acceptance Criteria (AC1–AC15)
  • All tasks T1–T14 and all ACs AC1–AC15 marked DONE

docs/issues/open/1854-1840-workflow-performance-container-test-gating/nextest-archive-analysis.md (new)

  • Records full binary landscape (47 targets), CI timing measurements, stripped binary sizes,
    cold-build timing, and resolved open questions

Containerfile

  • All four cargo nextest archive calls (debug/release cook-warmup + debug/release archive)
    now --exclude six packages: workspace-coupling, torrust-tracker-torrent-repository-benchmarking,
    torrust-tracker-client, torrust-tracker-contrib-bencode, torrust-tracker-e2e-tools,
    torrust-tracker-persistence-benchmark

packages/e2e-tools/ (new)

  • New torrust-tracker-e2e-tools crate extracted from src/bin/
  • Bins: e2e_tests_runner, profiling, qbittorrent_e2e_runner

packages/persistence-benchmark/ (new)

  • New torrust-tracker-persistence-benchmark crate extracted from packages/tracker-core/src/bin/
  • Bin: persistence_benchmark_runner with full persistence_benchmark module tree

packages/tracker-core/Cargo.toml

  • testcontainers moved from [dependencies] to [dev-dependencies] (only needed in tests)

project-words.txt

  • Added: alloca, artefacts, bitcode, objcopy

Status

  • T7–T10: done (matrix trimmed, cache warmed, E2E in container.yaml, docker-e2e skip)
  • T11: done (binary landscape documented in nextest-archive-analysis.md)
  • T12: done (torrust-tracker-client and torrust-tracker-contrib-bencode excluded)
  • T13: done (torrust-tracker-e2e-tools extracted and excluded)
  • T14: done (torrust-tracker-persistence-benchmark extracted and excluded; testcontainers to dev-deps)

@josecelano josecelano self-assigned this Jun 3, 2026
@codecov

codecov Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.83%. Comparing base (7a7165b) to head (2d1ce24).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1874      +/-   ##
===========================================
+ Coverage    77.81%   80.83%   +3.02%     
===========================================
  Files          382      368      -14     
  Lines        28637    27580    -1057     
  Branches     28637    27580    -1057     
===========================================
+ Hits         22284    22295      +11     
+ Misses        6049     4983    -1066     
+ Partials       304      302       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@josecelano

Copy link
Copy Markdown
Member Author

In my machine this command:

time cargo nextest archive --tests --workspace --all-features \
     --exclude workspace-coupling \
     --exclude torrust-tracker-torrent-repository-benchmarking \
     --archive-file /tmp/torrust-tracker-release.tar.zst --release 2>&1

takes:

image

… analysis

- Remove `debug` target from container.yaml test matrix (saves ~40 min per CI run)
- Replace docker-inspect step with four E2E test steps (e2e_tests_runner +
  qbittorrent sqlite3/mysql/postgresql) in container.yaml test job
- Add `if:` skip condition to testing.yaml docker-e2e job so it does not run
  when container.yaml already covers the same trigger (PRs to develop/main,
  pushes to develop/main/releases/**)
- Warm publish_development and publish_release caches from container-release
  scope to avoid redundant full rebuilds on the same commit
- Add detailed comments to container.yaml explaining unit test environment
  (rust:slim-trixie vs distroless), cache flow, and skip rationale
- Add ADR 20260603000000: keep unit tests inside the container build
- Update ADR index with new ADR entry
- Update issue torrust#1854 spec: add full analysis (T1–T14), implementation plan,
  acceptance criteria (AC1–AC15), and test binary landscape findings (T11–T14
  with three concrete optimization opportunities)

Closes part of torrust#1854 (T7–T10 done; T12–T14 tracked as follow-up).
…ackages

T12: add --exclude torrust-tracker-client and --exclude
torrust-tracker-contrib-bencode to all four cargo nextest archive
calls (debug/release cook-warmup and debug/release archive) in
Containerfile.

T13: create packages/e2e-tools/ (torrust-tracker-e2e-tools) and move
e2e_tests_runner, qbittorrent_e2e_runner, and profiling binaries out
of src/bin/ via git mv; add --exclude torrust-tracker-e2e-tools to
all four archive calls.

T14a: create packages/persistence-benchmark/
(torrust-tracker-persistence-benchmark) and move
persistence_benchmark_runner binary and full persistence_benchmark/
module tree out of tracker-core/src/bin/ via git mv; add --exclude
torrust-tracker-persistence-benchmark to all four archive calls.

T14b: move testcontainers from [dependencies] to [dev-dependencies]
in packages/tracker-core/Cargo.toml so it is no longer linked into
production binaries.

Docs: add nextest-archive-analysis.md (binary landscape analysis for
47 compiled targets); mark T11-T14 DONE and check AC12-AC15 in
ISSUE.md.

Misc: add alloca, artefacts, bitcode, objcopy to project-words.txt.

Closes tasks T12, T13, T14 of issue torrust#1854.
@josecelano
josecelano marked this pull request as ready for review June 4, 2026 07:11
@josecelano
josecelano requested a review from a team as a code owner June 4, 2026 07:11
Copilot AI review requested due to automatic review settings June 4, 2026 07:11
@josecelano
josecelano force-pushed the 1854-container-test-gating branch from 5a9ed4a to c47173f Compare June 4, 2026 07:13
@josecelano josecelano changed the title feat(ci): eliminate duplicate E2E tests and add container test gating feat(ci): eliminate duplicate E2E tests and slim nextest archive Jun 4, 2026

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.

Pull request overview

This PR reduces duplicated CI work by moving the Docker E2E execution into container.yaml, gating testing.yaml’s docker-e2e job when the container workflow already provides equivalent coverage, and documenting the policy/analysis in an ADR and issue spec.

Changes:

  • Consolidate E2E coverage: run the E2E runners in container.yaml right after building the image, and skip testing.yaml’s docker-e2e on overlapping triggers.
  • Simplify the container test matrix by removing the unused debug target and warming publish jobs’ BuildKit cache from the container-release scope.
  • Add ADR + issue-spec documentation capturing the rationale, environment differences, and follow-up optimization opportunities.

Reviewed changes

Copilot reviewed 13 out of 36 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/container.yaml Removes debug matrix target, adds toolchain/cache setup, runs E2E steps after docker build, and reuses container-release cache in publish jobs.
.github/workflows/testing.yaml Adds an if: guard to skip docker-e2e when container.yaml already runs equivalent E2E coverage for the same trigger.
docs/adrs/20260603000000_keep_unit_tests_inside_container_build.md New ADR documenting the decision to keep unit tests inside the container build and how E2E provides distroless runtime validation.
docs/adrs/index.md Registers the new ADR in the ADR index table.
docs/issues/open/1854-1840-workflow-performance-container-test-gating/ISSUE.md Expands analysis, plan, and acceptance criteria for the CI test-gating work and follow-ups.
project-words.txt Adds new spellcheck allowlist entries used by the new/updated documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…k extraction

persistence_benchmark_runner was moved from packages/tracker-core/ to
the new packages/persistence-benchmark/ package (T14a of issue torrust#1854).

Update all three benchmark jobs (SQLite3, MySQL, PostgreSQL) to use
-p torrust-tracker-persistence-benchmark instead of -p torrust-tracker-core.

Also extend the path filter to include packages/persistence-benchmark/**
so the workflow triggers on changes to the new package.

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.

Pull request overview

Copilot reviewed 14 out of 37 changed files in this pull request and generated 7 comments.

Comment thread project-words.txt Resolved
Comment thread .github/workflows/container.yaml Resolved
Comment thread .github/workflows/container.yaml Resolved
Comment thread .github/workflows/container.yaml Resolved
Comment thread .github/workflows/container.yaml Resolved
Comment thread Containerfile Resolved
Comment thread packages/e2e-tools/Cargo.toml Resolved
- Fix four 'cargo run --bin' invocations in container.yaml to include
  '-p torrust-tracker-e2e-tools' so Cargo resolves the binaries after
  they were extracted out of src/bin/ into the new e2e-tools package
- Wrap the long e2e_tests_runner run step with a YAML '>-' multiline
  scalar to stay within the 200-char yamllint line-length limit
- Remove duplicate 'bitcode' entry from project-words.txt and restore
  correct alphabetical order (binascii → binstall → bitcode)
- Correct Containerfile comment about torrust-tracker-contrib-bencode:
  it IS a production dependency; the package is excluded from nextest
  archive to avoid compiling its own tests/bins, not because it is unused
- Add packages/e2e-tools/README.md so Cargo.toml 'readme' field resolves
@josecelano

Copy link
Copy Markdown
Member Author

ACK 2d1ce24

@josecelano
josecelano merged commit d9ec549 into torrust:develop Jun 4, 2026
26 checks passed

@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 #1874 as its change stands at e170b9620 on the default branch.

What still runs: the Test (Docker) job builds only the release target (.github/workflows/container.yaml:76) and runs the four host-side E2E runners against torrust-tracker:local (.github/workflows/container.yaml:138-155); the docker-e2e job keeps the if: that skips it on the events the Container workflow covers (.github/workflows/testing.yaml:257-263); the runners and the persistence benchmark live in the packages/e2e-tools and packages/persistence-benchmark workspace members (Cargo.toml:172, Cargo.toml:177), and the benchmark workflow selects the new package and watches its path (.github/workflows/db-benchmarking.yaml:15, :21, :54, :81, :108). Three parts have changed since: f523e8d removed the publish jobs' read of the container-release cache scope, which any job holding a develop cache token could have written; 0b17ac8 replaced the six --exclude flags in the Containerfile with the default-members list (Cargo.toml:198-220); and a58ff98 added the -p torrust-tracker-e2e-tools that this change left out of the docker-e2e runner invocations, where Cargo had exited 101 at the workspace root before any E2E ran.

[Minor] The four E2E runner invocations are written twice, at .github/workflows/container.yaml:138-155 and .github/workflows/testing.yaml:314-331, and the if: at .github/workflows/testing.yaml:257-263 keeps the second copy off every pull request to develop or main, so no pull request's checks run it. A change to the runners' package, binary names or flags that updates only the first copy merges with every check passing and leaves the second broken until someone reads a branch-push run. That is what happened here: this change moved the binaries into torrust-tracker-e2e-tools and added -p in the Container workflow only, and docker-e2e failed before running any E2E from d9ec549 until a58ff98 (#2179). Smallest fix: move the four invocations into one composite action under .github/actions/ that takes the image tag as an input, and call it from both jobs, so the copy that pull requests exercise is the copy that branch pushes run.

[Minor] No workflow builds the debug target any more: the matrix at .github/workflows/container.yaml:76 holds only release, and no other workflow at e170b9620 names that target, while docs/containers.md:109 and docs/containers.md:119 tell users to build it. A change that breaks only the debug chain (the stages that start at Containerfile:95, :102, :149, :154, :171, :184, :199 and :278) passes every check and is first seen by a user following that page. Smallest fix: build --target debug on a schedule or on pushes to develop only, which keeps the pull-request time saving this change was after.

[Minor] Every automated dependency update still runs the Docker build and the four E2E runners twice. .github/dependabot.yaml:9 and :18 open daily updates against develop from branches in this repository. The push to such a branch runs docker-e2e, because the push half of the if: (.github/workflows/testing.yaml:260-263) exempts only develop, main and releases/, and the pull request it opens runs Test (Docker) (.github/workflows/container.yaml:39) with the same image and runners. Since other pull requests come from forks, these branches are the main same-repository source of the duplication this change set out to remove. Smallest fix: add startsWith(github.ref, 'refs/heads/dependabot/') to the push disjunction at .github/workflows/testing.yaml:261-263.

[Minor] Usage text and a benchmark script still call the moved binaries from the workspace root without -p, where Cargo exits 101 because torrust-tracker-e2e-tools is not a default member. contrib/dev-tools/workflow-benchmarks/run-testing-baseline.sh:121 runs under set -euo pipefail and so stops at its first E2E phase, and the examples at packages/e2e-tools/src/bin/qbittorrent_e2e_runner.rs:27, src/console/ci/e2e/runner.rs:6, :12, :18 and src/console/ci/qbittorrent_e2e/runner.rs:6 fail when copied. Smallest fix: add -p torrust-tracker-e2e-tools to those invocations, as a58ff98 did for the workflow.

[Nit] The if: at .github/workflows/testing.yaml:257-263 restates the Container workflow's triggers (.github/workflows/container.yaml:11-26) by hand, and the comment that names the link sits under the job (.github/workflows/container.yaml:60-63), not beside on:. The two agree at this tip. If a later edit drops main from .github/workflows/container.yaml:23, pull requests to main get no Docker E2E at all and no check says so. Smallest fix: a comment at .github/workflows/container.yaml:11 naming .github/workflows/testing.yaml:257 as the condition to change with it.

Checked and found sound: at this tip the skip condition matches the Container workflow's branch and path filters, including releases/**/* against the refs/heads/releases/ prefix and the identical paths-ignore lists; both runner binaries return their anyhow::Result from main, so a failed run fails its job; the two new manifests resolve against the versions of torrust-tracker, torrust-tracker-core, torrust-tracker-configuration and torrust-tracker-primitives at this tip, carry publish = false, and stay out of default-members, so they never enter the container test archives; and the benchmark workflow's new path filter and package selection.

This branch was previously deployed

1 inactive deployment
coverage — 2d1ce246 Deployed Jun 4, 2026 by josecelano via Generate Coverage Report #1359
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.

Evaluate test execution policy in container image build

3 participants