1
+ # This is the main CI workflow that runs the test suite on all pushes to main and all pull requests.
2
+ # It runs the following jobs:
3
+ # - required: runs the test suite on ubuntu with stable and beta rust toolchains
4
+ # - minimal: runs the test suite with the minimal versions of the dependencies that satisfy the
5
+ # requirements of this crate, and its dependencies
6
+ # - os-check: runs the test suite on mac and windows
7
+ # - coverage: runs the test suite and collects coverage information
8
+ # See check.yml for information about how the concurrency cancellation and workflow triggering works
1
9
permissions :
2
10
contents : read
3
11
on :
4
12
push :
5
13
branches : [main]
6
14
pull_request :
7
- # Spend CI time only on latest ref: https://github.com/jonhoo/rust-ci-conf/pull/5
8
15
concurrency :
9
16
group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
10
17
cancel-in-progress : true
15
22
name : ubuntu / ${{ matrix.toolchain }}
16
23
strategy :
17
24
matrix :
25
+ # run on stable and beta to ensure that tests won't break on the next version of the rust
26
+ # toolchain
18
27
toolchain : [stable, beta]
19
28
steps :
20
29
- uses : actions/checkout@v4
25
34
with :
26
35
toolchain : ${{ matrix.toolchain }}
27
36
- name : cargo generate-lockfile
37
+ # enable this ci template to run regardless of whether the lockfile is checked in or not
28
38
if : hashFiles('Cargo.lock') == ''
29
39
run : cargo generate-lockfile
30
40
# https://twitter.com/jonhoo/status/1571290371124260865
34
44
- name : cargo test --doc
35
45
run : cargo test --locked --all-features --doc
36
46
minimal :
47
+ # This action chooses the oldest version of the dependencies permitted by Cargo.toml to ensure
48
+ # that this crate is compatible with the minimal version that this crate and its dependencies
49
+ # require. This will pickup issues where this create relies on functionality that was introduced
50
+ # later than the actual version specified (e.g., when we choose just a major version, but a
51
+ # method was added after this version).
52
+ #
53
+ # This particular check can be difficult to get to succeed as often transitive dependencies may
54
+ # be incorrectly specified (e.g., a dependency specifies 1.0 but really requires 1.1.5). There
55
+ # is an alternative flag available -Zdirect-minimal-versions that uses the minimal versions for
56
+ # direct dependencies of this crate, while selecting the maximal versions for the transitive
57
+ # dependencies. Alternatively, you can add a line in your Cargo.toml to artificially increase
58
+ # the minimal dependency, which you do with e.g.:
59
+ # ```toml
60
+ # # for minimal-versions
61
+ # [target.'cfg(any())'.dependencies]
62
+ # openssl = { version = "0.10.55", optional = true } # needed to allow foo to build with -Zminimal-versions
63
+ # ```
64
+ # The optional = true is necessary in case that dependency isn't otherwise transitively required
65
+ # by your library, and the target bit is so that this dependency edge never actually affects
66
+ # Cargo build order. See also
67
+ # https://github.com/jonhoo/fantoccini/blob/fde336472b712bc7ebf5b4e772023a7ba71b2262/Cargo.toml#L47-L49.
68
+ # This action is run on ubuntu with the stable toolchain, as it is not expected to fail
37
69
runs-on : ubuntu-latest
38
70
name : ubuntu / stable / minimal-versions
39
71
steps :
@@ -51,15 +83,16 @@ jobs:
51
83
- name : cargo test
52
84
run : cargo test --locked --all-features --all-targets
53
85
os-check :
86
+ # run cargo test on mac and windows
54
87
runs-on : ${{ matrix.os }}
55
88
name : ${{ matrix.os }} / stable
56
89
strategy :
57
90
fail-fast : false
58
91
matrix :
59
92
os : [macos-latest, windows-latest]
60
93
steps :
61
- # if your project needs OpenSSL, uncommment this to fix Windows builds.
62
- # it's commented out by default as tthe install command takes 5-10m.
94
+ # if your project needs OpenSSL, uncomment this to fix Windows builds.
95
+ # it's commented out by default as the install command takes 5-10m.
63
96
# - run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
64
97
# if: runner.os == 'Windows'
65
98
# - run: vcpkg install openssl:x64-windows-static-md
@@ -75,6 +108,27 @@ jobs:
75
108
- name : cargo test
76
109
run : cargo test --locked --all-features --all-targets
77
110
coverage :
111
+ # use llvm-cov to build and collect coverage and outputs in a format that
112
+ # is compatible with codecov.io
113
+ #
114
+ # note that codecov as of v4 requires that CODECOV_TOKEN from
115
+ #
116
+ # https://app.codecov.io/gh/<user or org>/<project>/settings
117
+ #
118
+ # is set in two places on your repo:
119
+ #
120
+ # - https://github.com/jonhoo/guardian/settings/secrets/actions
121
+ # - https://github.com/jonhoo/guardian/settings/secrets/dependabot
122
+ #
123
+ # (the former is needed for codecov uploads to work with Dependabot PRs)
124
+ #
125
+ # PRs coming from forks of your repo will not have access to the token, but
126
+ # for those, codecov allows uploading coverage reports without a token.
127
+ # it's all a little weird and inconvenient. see
128
+ #
129
+ # https://github.com/codecov/feedback/issues/112
130
+ #
131
+ # for lots of more discussion
78
132
runs-on : ubuntu-latest
79
133
name : ubuntu / stable / coverage
80
134
steps :
@@ -92,7 +146,11 @@ jobs:
92
146
run : cargo generate-lockfile
93
147
- name : cargo llvm-cov
94
148
run : cargo llvm-cov --locked --all-features --lcov --output-path lcov.info
149
+ - name : Record Rust version
150
+ run : echo "RUST=$(rustc --version)" >> "$GITHUB_ENV"
95
151
- name : Upload to codecov.io
96
- uses : codecov/codecov-action@v3
152
+ uses : codecov/codecov-action@v5
97
153
with :
98
154
fail_ci_if_error : true
155
+ token : ${{ secrets.CODECOV_TOKEN }}
156
+ env_vars : OS,RUST
0 commit comments