Skip to content

Commit e3813c2

Browse files
authored
Merge pull request #337 from jonhoo/bump-ci
Bump CI
2 parents 75464f9 + a4476dc commit e3813c2

File tree

6 files changed

+141
-19
lines changed

6 files changed

+141
-19
lines changed

.github/DOCS.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Github config and workflows
2+
3+
In this folder there is configuration for codecoverage, dependabot, and ci
4+
workflows that check the library more deeply than the default configurations.
5+
6+
This folder can be or was merged using a --allow-unrelated-histories merge
7+
strategy from <https://github.com/jonhoo/rust-ci-conf/> which provides a
8+
reasonably sensible base for writing your own ci on. By using this strategy
9+
the history of the CI repo is included in your repo, and future updates to
10+
the CI can be merged later.
11+
12+
To perform this merge run:
13+
14+
```shell
15+
git remote add ci https://github.com/jonhoo/rust-ci-conf.git
16+
git fetch ci
17+
git merge --allow-unrelated-histories ci/main
18+
```
19+
20+
An overview of the files in this project is available at:
21+
<https://www.youtube.com/watch?v=xUH-4y92jPg&t=491s>, which contains some
22+
rationale for decisions and runs through an example of solving minimal version
23+
and OpenSSL issues.

.github/codecov.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ ignore:
1818
# Make comments less noisy
1919
comment:
2020
layout: "files"
21-
require_changes: yes
21+
require_changes: true

.github/dependabot.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ updates:
1010
interval: daily
1111
ignore:
1212
- dependency-name: "*"
13-
# patch and minor updates don't matter for libraries
14-
# remove this ignore rule if your package has binaries
13+
# patch and minor updates don't matter for libraries as consumers of this library build
14+
# with their own lockfile, rather than the version specified in this library's lockfile
15+
# remove this ignore rule if your package has binaries to ensure that the binaries are
16+
# built with the exact set of dependencies and those are up to date.
1517
update-types:
1618
- "version-update:semver-patch"
1719
- "version-update:semver-minor"

.github/workflows/check.yml

+40-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1+
# This workflow runs whenever a PR is opened or updated, or a commit is pushed to main. It runs
2+
# several checks:
3+
# - fmt: checks that the code is formatted according to rustfmt
4+
# - clippy: checks that the code does not contain any clippy warnings
5+
# - doc: checks that the code can be documented without errors
6+
# - hack: check combinations of feature flags
7+
# - msrv: check that the msrv specified in the crate is correct
18
permissions:
29
contents: read
10+
# This configuration allows maintainers of this repo to create a branch and pull request based on
11+
# the new branch. Restricting the push trigger to the main branch ensures that the PR only gets
12+
# built once.
313
on:
414
push:
515
branches: [main]
616
pull_request:
7-
# Spend CI time only on latest ref: https://github.com/jonhoo/rust-ci-conf/pull/5
17+
# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that
18+
# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5
819
concurrency:
920
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1021
cancel-in-progress: true
@@ -32,6 +43,7 @@ jobs:
3243
strategy:
3344
fail-fast: false
3445
matrix:
46+
# Get early warning of new lints which are regularly introduced in beta channels.
3547
toolchain: [stable, beta]
3648
steps:
3749
- uses: actions/checkout@v4
@@ -43,10 +55,27 @@ jobs:
4355
toolchain: ${{ matrix.toolchain }}
4456
components: clippy
4557
- name: cargo clippy
46-
uses: actions-rs/clippy-check@v1
58+
uses: giraffate/clippy-action@v1
4759
with:
48-
token: ${{ secrets.GITHUB_TOKEN }}
60+
reporter: 'github-pr-check'
61+
github_token: ${{ secrets.GITHUB_TOKEN }}
62+
semver:
63+
runs-on: ubuntu-latest
64+
name: semver
65+
steps:
66+
- uses: actions/checkout@v4
67+
with:
68+
submodules: true
69+
- name: Install stable
70+
uses: dtolnay/rust-toolchain@stable
71+
with:
72+
components: rustfmt
73+
- name: cargo-semver-checks
74+
uses: obi1kenobi/cargo-semver-checks-action@v2
4975
doc:
76+
# run docs generation on nightly rather than stable. This enables features like
77+
# https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an
78+
# API be documented as only available in some specific platforms.
5079
runs-on: ubuntu-latest
5180
name: nightly / doc
5281
steps:
@@ -55,11 +84,13 @@ jobs:
5584
submodules: true
5685
- name: Install nightly
5786
uses: dtolnay/rust-toolchain@nightly
58-
- name: cargo doc
59-
run: cargo doc --no-deps --all-features
60-
env:
61-
RUSTDOCFLAGS: --cfg docsrs
87+
- name: Install cargo-docs-rs
88+
uses: dtolnay/install@cargo-docs-rs
89+
- name: cargo docs-rs
90+
run: cargo docs-rs
6291
hack:
92+
# cargo-hack checks combinations of feature flags to ensure that features are all additive
93+
# which is required for feature unification
6394
runs-on: ubuntu-latest
6495
name: ubuntu / stable / features
6596
steps:
@@ -71,9 +102,11 @@ jobs:
71102
- name: cargo install cargo-hack
72103
uses: taiki-e/install-action@cargo-hack
73104
# intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4
105+
# --feature-powerset runs for every combination of features
74106
- name: cargo hack
75107
run: cargo hack --feature-powerset check
76108
msrv:
109+
# check that we can build using the minimal rust version that is specified by this crate
77110
runs-on: ubuntu-latest
78111
# we use a matrix here just because env can't be used in job names
79112
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability

.github/workflows/scheduled.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Run scheduled (rolling) jobs on a nightly basis, as your crate may break independently of any
2+
# given PR. E.g., updates to rust nightly and updates to this crates dependencies. See check.yml for
3+
# information about how the concurrency cancellation and workflow triggering works
14
permissions:
25
contents: read
36
on:
@@ -6,7 +9,6 @@ on:
69
pull_request:
710
schedule:
811
- cron: '7 7 * * *'
9-
# Spend CI time only on latest ref: https://github.com/jonhoo/rust-ci-conf/pull/5
1012
concurrency:
1113
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1214
cancel-in-progress: true
@@ -29,12 +31,16 @@ jobs:
2931
run: cargo test --locked --all-features --all-targets
3032
# https://twitter.com/alcuadrado/status/1571291687837732873
3133
update:
34+
# This action checks that updating the dependencies of this crate to the latest available that
35+
# satisfy the versions in Cargo.toml does not break this crate. This is important as consumers
36+
# of this crate will generally use the latest available crates. This is subject to the standard
37+
# Cargo semver rules (i.e cargo does not update to a new major version unless explicitly told
38+
# to).
3239
runs-on: ubuntu-latest
3340
name: ubuntu / beta / updated
34-
# There's no point running this if no Cargo.lock was checked in in the
35-
# first place, since we'd just redo what happened in the regular test job.
36-
# Unfortunately, hashFiles only works in if on steps, so we reepeat it.
37-
# if: hashFiles('Cargo.lock') != ''
41+
# There's no point running this if no Cargo.lock was checked in in the first place, since we'd
42+
# just redo what happened in the regular test job. Unfortunately, hashFiles only works in if on
43+
# steps, so we repeat it.
3844
steps:
3945
- uses: actions/checkout@v4
4046
with:

.github/workflows/test.yml

+62-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
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
19
permissions:
210
contents: read
311
on:
412
push:
513
branches: [main]
614
pull_request:
7-
# Spend CI time only on latest ref: https://github.com/jonhoo/rust-ci-conf/pull/5
815
concurrency:
916
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1017
cancel-in-progress: true
@@ -15,6 +22,8 @@ jobs:
1522
name: ubuntu / ${{ matrix.toolchain }}
1623
strategy:
1724
matrix:
25+
# run on stable and beta to ensure that tests won't break on the next version of the rust
26+
# toolchain
1827
toolchain: [stable, beta]
1928
steps:
2029
- uses: actions/checkout@v4
@@ -25,6 +34,7 @@ jobs:
2534
with:
2635
toolchain: ${{ matrix.toolchain }}
2736
- name: cargo generate-lockfile
37+
# enable this ci template to run regardless of whether the lockfile is checked in or not
2838
if: hashFiles('Cargo.lock') == ''
2939
run: cargo generate-lockfile
3040
# https://twitter.com/jonhoo/status/1571290371124260865
@@ -34,6 +44,28 @@ jobs:
3444
- name: cargo test --doc
3545
run: cargo test --locked --all-features --doc
3646
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
3769
runs-on: ubuntu-latest
3870
name: ubuntu / stable / minimal-versions
3971
steps:
@@ -51,15 +83,16 @@ jobs:
5183
- name: cargo test
5284
run: cargo test --locked --all-features --all-targets
5385
os-check:
86+
# run cargo test on mac and windows
5487
runs-on: ${{ matrix.os }}
5588
name: ${{ matrix.os }} / stable
5689
strategy:
5790
fail-fast: false
5891
matrix:
5992
os: [macos-latest, windows-latest]
6093
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.
6396
# - run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
6497
# if: runner.os == 'Windows'
6598
# - run: vcpkg install openssl:x64-windows-static-md
@@ -75,6 +108,27 @@ jobs:
75108
- name: cargo test
76109
run: cargo test --locked --all-features --all-targets
77110
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
78132
runs-on: ubuntu-latest
79133
name: ubuntu / stable / coverage
80134
steps:
@@ -92,7 +146,11 @@ jobs:
92146
run: cargo generate-lockfile
93147
- name: cargo llvm-cov
94148
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"
95151
- name: Upload to codecov.io
96-
uses: codecov/codecov-action@v3
152+
uses: codecov/codecov-action@v5
97153
with:
98154
fail_ci_if_error: true
155+
token: ${{ secrets.CODECOV_TOKEN }}
156+
env_vars: OS,RUST

0 commit comments

Comments
 (0)