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
# This workflow will install Rust toolchain dependencies, build the workspace, run tests (including
# ignored tests), build docs, run clippy, run rustfmt, run benchmarks, and generate code coverage
# reports and upload them to Codecov. It runs on push and pull_requests, and on a nightly schedule.
#
# Some jobs and/or steps, e.g. ignored tests, benchmarks, and code coverage, are time consuming
# and/or depend on network and jolpica-f1 API availability. This can cause several issues if run
# on every CI job, including spurious failures, excessive API usage, and consuming a lot of the
# available GitHub Actions minutes. As such, these jobs and/or steps are skipped on push and PRs,
# and only run on schedules and locally via act. It is highly recommended that the full CI workflow
# be run locally before pushing changes, to catch any issues that the reduced workflow may miss.
#
# Many of the documentation tests are marked with ```no_run since they make requests to the jolpica
# API, and so have the same issues mentioned above, but we still want to check that they compile -
# doc tests marked with #[ignore] are not compile, unlike regular tests. Since Rust doesn't have a
# built-in way to run these tests, as it does with --ignored tests, the script `test_no_run_docs.sh`
# is provided as a workaround.
#
# Some jobs and/or steps are skipped when running locally with `act` - controlled via env.ACT and
# vars.ACT, because they may take too long or may undesirably upload codecov or performance reports.
# To force running these steps/jobs when running locally with `act`, several options are supported,
# which can be configured via `--var <OPTION_NAME>=true`. The supported options are:
# - `FORCE_CODECOV=true` will run the code coverage job, which uploads a report to Codecov.
# - `FORCE_RUN_BENCH=true` will run the benchmarks, which may upload perf reports to GitHub.
#
# Example local runs:
# `act --reuse`
# `act --reuse --var FORCE_CODECOV=true --artifact-server-path ./artifacts --secret-file .secrets`
name: CI
on:
push:
branches:
pull_request:
branches:
schedule:
# Weekly, at 00:00 on Sundays
- cron: "0 0 * * 0"
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Build
run: cargo build --workspace --all-features
- name: Test (non-ignored)
run: cargo test --workspace --all-features
- name: Test (ignored)
if: github.event_name == 'schedule' || vars.ACT == 'true'
run: cargo test --workspace --all-features -- --ignored --test-threads 1
- name: Test (doc no_run)
if: github.event_name == 'schedule' || vars.ACT == 'true'
run: ./scripts/test_no_run_docs.sh
build_docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- run: cargo doc --workspace --all-features --no-deps --document-private-items
- run: cargo doc --examples --no-deps
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy
- run: cargo clippy --workspace --all-features --no-deps
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt
- run: cargo fmt --all -- --check
code_coverage:
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || vars.FORCE_CODECOV == 'true'
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov
- name: Run cargo-llvm-cov
run: "cargo llvm-cov --codecov test --workspace --all-features -- \
--include-ignored --test-threads 1 > codecove_code_coverage.json"
- name: Archive codecove_code_coverage.json
uses: actions/upload-artifact@v4
with:
path: codecove_code_coverage.json
- name: Upload code coverage report to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
bench:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Build benchmarks
run: cargo bench --workspace --all-features --no-run
- name: Run benchmarks
if: github.event_name == 'schedule' || vars.FORCE_RUN_BENCH == 'true'
run: cargo bench --workspace --all-features