Repository navigation
267 lines (226 loc) · 8.92 KB
/
Copy pathtesting.yaml
File metadata and controls
267 lines (226 loc) · 8.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
name: Testing
# skill-link: update-github-workflow-actions
# adr: docs/adrs/20260612000000_adopt_sccache_for_ci_bare_builds.md
# This workflow includes sccache for bare CI builds outside Docker containers, replacing Swatinem/rust-cache.
# See ADR for evidence and rationale.
# Path policy: skip this workflow when every changed file is documentation.
# See .github/workflows/docs-lint.yaml for the lightweight docs-only workflow.
on:
push:
paths-ignore:
- "**/*.md"
- "project-words.txt"
pull_request:
paths-ignore:
- "**/*.md"
- "project-words.txt"
# issue: #2402
concurrency:
group: >-
${{ github.workflow }}-${{ github.event_name == 'pull_request' &&
format('pr-{0}', github.event.pull_request.number) || format('run-{0}', github.run_id) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CARGO_TERM_COLOR: always
jobs:
unit:
name: Unit (${{ matrix.toolchain }})
runs-on: ubuntu-latest
timeout-minutes: ${{ matrix.timeout_minutes }}
strategy:
matrix:
include:
- toolchain: nightly
components: rustfmt, clippy, llvm-tools-preview
timeout_minutes: 45
run_format: true
run_library_docs: true
- toolchain: stable
components: clippy, llvm-tools-preview
timeout_minutes: 90
run_format: false
run_library_docs: false
steps:
- id: checkout
name: Checkout Repository
uses: actions/checkout@v7.0.1
- id: setup
name: Setup Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
components: ${{ matrix.components }}
- id: node
name: Setup Node.js
uses: actions/setup-node@v7.1.0
with:
node-version: "20"
- id: sccache
name: Install sccache (GHA backend)
uses: mozilla-actions/sccache-action@v0.0.11
- id: enable-sccache
name: Enable sccache
run: |
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
echo "CARGO_INCREMENTAL=0" >> "$GITHUB_ENV"
- id: fetch
name: Download Dependencies
run: cargo fetch --verbose
- id: linter
name: Install Internal Linter
run: cargo install --locked torrust-linting@0.2.0 --bin linter
- id: tools
name: Install Tools
uses: taiki-e/install-action@v2.87.28
with:
tool: cargo-llvm-cov, cargo-nextest
- id: format
name: Run Formatting-Checks
if: ${{ matrix.run_format }}
run: cargo fmt --check
- id: lint
name: Run All Linters
run: linter all
- id: test-docs
name: Run Documentation Tests
run: cargo test --doc --workspace
# `cargo test --doc` does not resolve intra-doc links; this catches broken library links.
- id: library-docs
name: Build Library Documentation
if: ${{ matrix.run_library_docs }}
run: cargo doc --no-deps --lib --workspace --all-features
- id: test
name: Run Unit Tests
run: cargo test --tests --benches --examples --workspace --all-targets --all-features
documented-clippy-allows:
name: Documented Clippy Allows
runs-on: ubuntu-latest
timeout-minutes: 15
env:
BASE_REF: ${{ github.base_ref || 'develop' }}
steps:
- id: checkout
name: Checkout Repository
uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- id: setup
name: Setup Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- id: fetch-base
name: Fetch Base Branch
run: git fetch origin "$BASE_REF"
- id: check
name: Check Documented Clippy Allows
run: cargo run --quiet --package clippy-allow-reasons -- --base-ref "origin/$BASE_REF"
layer-bans:
name: Layer Boundary Bans
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- id: checkout
name: Checkout Repository
uses: actions/checkout@v7.0.1
- id: setup
name: Setup Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- id: deny
name: Install cargo-deny (v0.19.9)
run: cargo install --locked cargo-deny@0.19.9
- id: deny-check
name: Check layer boundary bans
run: cargo deny check bans
docker-e2e:
# Skip this job when container.yaml is also running for the same event — it builds
# the same image and runs the same E2E tests. container.yaml triggers on pushes to
# develop/main/releases and on PRs targeting develop/main.
# For feature branch pushes and PRs targeting other branches, container.yaml does not
# run, so this job provides the only E2E coverage. See issue #1854.
# The package flag is required because the E2E runner binaries are not in the root package.
#
# Runner: the self-hosted Hetzner runner in this repository, except for Dependabot PRs and
# pushes to Dependabot branches, which live in this repository and run without approval.
# See ADR 20260926142648_adopt_self_hosted_hetzner_runner_for_container_tests.md.
name: Docker E2E
runs-on: >-
${{
github.repository == 'torrust/torrust-tracker' &&
((github.event_name == 'pull_request' &&
github.event.pull_request.user.login != 'dependabot[bot]' &&
!startsWith(github.head_ref, 'dependabot/')) ||
(github.event_name == 'push' &&
!startsWith(github.ref, 'refs/heads/dependabot/'))) &&
fromJSON('["self-hosted", "torrust-hetzner"]') || 'ubuntu-latest'
}}
timeout-minutes: 90
if: >-
!(github.event_name == 'pull_request' &&
(github.base_ref == 'develop' || github.base_ref == 'main')) &&
!(github.event_name == 'push' &&
(github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/releases/')))
steps:
- id: checkout
name: Checkout Repository
uses: actions/checkout@v7.0.1
- id: setup
name: Setup Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- id: sccache
name: Install sccache (GHA backend)
if: runner.environment == 'github-hosted'
uses: mozilla-actions/sccache-action@v0.0.11
- id: enable-sccache
name: Enable sccache
if: runner.environment == 'github-hosted'
run: |
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
echo "CARGO_INCREMENTAL=0" >> "$GITHUB_ENV"
# `actions/checkout` cleans the workspace, so keep host-side Cargo builds outside it.
- id: persistent-target
name: Use Persistent Cargo Target Directory
if: runner.environment == 'self-hosted'
run: echo "CARGO_TARGET_DIR=$HOME/.cache/torrust-tracker/docker-e2e-target" >> "$GITHUB_ENV"
- id: fetch
name: Download Dependencies
run: cargo fetch --verbose
- id: setup-buildx
name: Setup Buildx
uses: docker/setup-buildx-action@v4.4.1
with:
driver: ${{ runner.environment == 'self-hosted' && 'docker' || 'docker-container' }}
- id: build-tracker-image
name: Build Tracker Image
uses: docker/build-push-action@v7.4.0
with:
file: ./Containerfile
push: false
load: true
target: release
tags: torrust-tracker:e2e-local
cache-from: ${{ runner.environment == 'github-hosted' && 'type=gha,scope=testing-docker-e2e' || '' }}
cache-to: ${{ runner.environment == 'github-hosted' && 'type=gha,scope=testing-docker-e2e,mode=max' || '' }}
- id: run-tracker-e2e-tests
name: Run E2E Tests
run: >-
cargo run -p torrust-tracker-e2e-tools --bin e2e_tests_runner
-- --config-toml-path "./share/default/config/tracker.e2e.container.sqlite3.toml"
--tracker-image "torrust-tracker:e2e-local" --skip-build
- id: run-qbittorrent-e2e-test-sqlite3
name: Run qBittorrent E2E Test (SQLite)
run: cargo run -p torrust-tracker-e2e-tools --bin qbittorrent_e2e_runner -- --tracker-image "torrust-tracker:e2e-local" --skip-build --db-driver sqlite3 --timeout-seconds 600
- id: run-qbittorrent-e2e-test-mysql
name: Run qBittorrent E2E Test (MySQL)
run: cargo run -p torrust-tracker-e2e-tools --bin qbittorrent_e2e_runner -- --tracker-image "torrust-tracker:e2e-local" --skip-build --db-driver mysql --timeout-seconds 600
- id: run-qbittorrent-e2e-test-postgresql
name: Run qBittorrent E2E Test (PostgreSQL)
run: cargo run -p torrust-tracker-e2e-tools --bin qbittorrent_e2e_runner -- --tracker-image "torrust-tracker:e2e-local" --skip-build --db-driver postgresql --timeout-seconds 600