Repository navigation
165 lines (146 loc) · 5.27 KB
/
Copy pathnightly-rust-coverage.yml
File metadata and controls
165 lines (146 loc) · 5.27 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
name: Nightly Rust coverage
on:
schedule:
- cron: "17 19 * * *"
workflow_dispatch:
concurrency:
group: nightly-rust-coverage
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_INCREMENTAL: "0"
CARGO_LLVM_COV_VERSION: "0.8.7"
CARGO_PROFILE_DEV_DEBUG: "0"
CARGO_PROFILE_TEST_DEBUG: "0"
CARGO_TERM_COLOR: always
jobs:
plan:
name: Plan Rust coverage shards
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
submodules: false
- name: Build coverage matrix from the CI shard inventory
id: matrix
run: python3 .github/scripts/nightly_rust_coverage.py
rust:
name: Rust coverage (${{ matrix.name }})
needs: plan
runs-on: ubuntu-24.04
timeout-minutes: 30
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
max-parallel: 4
matrix: ${{ fromJSON(needs.plan.outputs.matrix) }}
env:
CARGO_TARGET_DIR: target/nightly-rust-coverage
COVERAGE_ALL_FEATURES: ${{ matrix.all_features }}
COVERAGE_FEATURES: ${{ matrix.features }}
COVERAGE_PACKAGES: ${{ matrix.packages }}
# The platform shard's --all-features build enables the dispatch and
# activation PostgreSQL tests, which fail rather than skip without their
# disposable database. The other shards start the service and leave it
# unused, so this definition stays identical to platform-coverage in
# ci.yml, which .github/scripts/test_ci_changes.py holds.
services:
postgres:
image: docker.io/library/postgres:17.11@sha256:67f41722b7a8cbdb868a44a4995c846eddfdc2973bccb291ce937dce88ad5675
env:
POSTGRES_DB: dispatch
POSTGRES_USER: dispatch
POSTGRES_PASSWORD: dispatch_test
options: >-
--health-cmd "pg_isready -U dispatch -d dispatch"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432/tcp
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0
persist-credentials: false
submodules: false
- name: Cache Cargo registry
uses: Swatinem/rust-cache@c8037a86dde8214a8310e9f54a8fc61ab362aa31 # v2
with:
shared-key: workspace-registry
cache-targets: false
save-if: false
- name: Install pinned coverage tool
uses: taiki-e/install-action@1e29709c0ec63babbe8f266397a465f29a825f91 # v2.87.31
with:
tool: cargo-llvm-cov@${{ env.CARGO_LLVM_COV_VERSION }}
- name: Run shard with coverage
shell: bash
env:
DISPATCH_TEST_DATABASE_URL: postgresql://dispatch:dispatch_test@localhost:${{ job.services.postgres.ports['5432'] }}/dispatch
ACTIVATION_TEST_DATABASE_URL: postgresql://dispatch:dispatch_test@localhost:${{ job.services.postgres.ports['5432'] }}/dispatch
run: |
set -euo pipefail
read -r -a packages <<< "${COVERAGE_PACKAGES}"
package_args=()
for package in "${packages[@]}"; do
package_args+=(-p "${package}")
done
feature_args=()
if [[ "${COVERAGE_ALL_FEATURES}" == "true" ]]; then
feature_args+=(--all-features)
elif [[ -n "${COVERAGE_FEATURES}" ]]; then
feature_args+=(--features "${COVERAGE_FEATURES//[[:space:]]/}")
fi
cargo llvm-cov clean --workspace
cargo llvm-cov --locked \
"${package_args[@]}" \
"${feature_args[@]}" \
--no-report
- name: Export shard coverage
shell: bash
run: |
set -euo pipefail
read -r -a packages <<< "${COVERAGE_PACKAGES}"
package_args=()
for package in "${packages[@]}"; do
package_args+=(-p "${package}")
done
coverage_dir="${CARGO_TARGET_DIR}/coverage"
mkdir -p "${coverage_dir}"
cargo llvm-cov report --locked "${package_args[@]}"
cargo llvm-cov report --locked \
"${package_args[@]}" \
--lcov \
--output-path "${coverage_dir}/${{ matrix.name }}.lcov"
- name: Upload shard coverage artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: nightly-rust-${{ matrix.name }}-coverage
path: target/nightly-rust-coverage/coverage/${{ matrix.name }}.lcov
if-no-files-found: error
retention-days: 7
- name: Upload shard coverage to Codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
disable_search: true
fail_ci_if_error: true
files: target/nightly-rust-coverage/coverage/${{ matrix.name }}.lcov
flags: ${{ matrix.flag }}
name: nightly-${{ matrix.name }}
plugins: noop
use_oidc: true
version: v11.3.1
- name: Report disk usage
if: always()
run: |
df -h /
du -sh "${CARGO_TARGET_DIR}" 2>/dev/null || true