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
name: Code Coverage Report.
on:
push:
branches:
- main
- 'feature/**'
- 'fix/**'
- 'release/**'
pull_request:
branches:
- main
- 'release/**'
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
# Network reliability configurations
RUSTUP_MAX_RETRIES: 3
CARGO_NET_RETRY: 3
CARGO_NET_GIT_FETCH_WITH_CLI: true
RUSTUP_DIST_SERVER: https://static.rust-lang.org
RUSTUP_UPDATE_ROOT: https://static.rust-lang.org/rustup
jobs:
code_coverage_report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
# Network diagnostics
- name: Network diagnostics
run: |
echo "Testing network connectivity..."
ping -c 3 static.rust-lang.org || echo "Ping failed, but continuing..."
curl -I https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256 || echo "Curl failed, but continuing..."
# Robust Rust installation with retry strategy
- name: Install Rust with retry
uses: nick-fields/retry@v4
with:
timeout_minutes: 10
max_attempts: 3
retry_wait_seconds: 30
command: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --component rustfmt --component clippy --profile minimal
source ~/.cargo/env
# Fallback Rust installation
- name: Fallback Rust installation
if: failure()
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
# Verify Rust installation
- name: Verify Rust installation
run: |
source ~/.cargo/env || true
rustc --version
cargo --version
rustfmt --version
clippy-driver --version
- name: Cache Rust dependencies
uses: actions/cache@v6
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y make libfontconfig1-dev pkg-config
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# INSTALL TARPALUIN FOR CODE COVERAGE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# The version requirement makes cargo replace an older binary restored
# from the ~/.cargo/bin cache; < 0.37.5 cannot read Rust 1.99+ coverage data.
- name: Install Tarpaulin.
run: cargo install cargo-tarpaulin --locked --version '>=0.37.5'
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# GENERATE CODE COVERAGE REPORT
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- name: Generate code coverage report.
run: cargo tarpaulin --color Always --engine llvm --verbose --tests --all-targets --all-features --workspace --timeout 600 --out Xml
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# UPLOAD CODE COVERAGE REPORT TO CODECOV.IO
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- name: Upload coverage reports to Codecov.io
uses: codecov/codecov-action@v7
with:
# Best-effort upload: Dependabot PRs cannot access secrets, so the
# upload would otherwise fail with "Token required because branch
# is protected". Pushes to main still succeed because the token is
# available there.
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~