Skip to content

Commit 70da1ab

Browse files
committed
docs: Add documentation based on the youtube video
1 parent 6332a3a commit 70da1ab

File tree

9 files changed

+128
-12
lines changed

9 files changed

+128
-12
lines changed

.github/DOCS.md

Lines changed: 23 additions & 0 deletions
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/README.md

Lines changed: 23 additions & 0 deletions
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
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 20 additions & 1 deletion
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@v3
@@ -47,6 +59,9 @@ jobs:
4759
with:
4860
token: ${{ secrets.GITHUB_TOKEN }}
4961
doc:
62+
# run docs generation on nightly rather than stable. This enables features like
63+
# https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an
64+
# API be documented as only available in some specific platforms.
5065
runs-on: ubuntu-latest
5166
name: nightly / doc
5267
steps:
@@ -60,6 +75,8 @@ jobs:
6075
env:
6176
RUSTDOCFLAGS: --cfg docsrs
6277
hack:
78+
# cargo-hack checks combinations of feature flags to ensure that features are all additive
79+
# which is required for feature unification
6380
runs-on: ubuntu-latest
6481
name: ubuntu / stable / features
6582
steps:
@@ -71,9 +88,11 @@ jobs:
7188
- name: cargo install cargo-hack
7289
uses: taiki-e/install-action@cargo-hack
7390
# intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4
91+
# --feature-powerset runs for every combination of features
7492
- name: cargo hack
7593
run: cargo hack --feature-powerset check
7694
msrv:
95+
# check that we can build using the minimal rust version that is specified by this crate
7796
runs-on: ubuntu-latest
7897
# we use a matrix here just because env can't be used in job names
7998
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability

.github/workflows/nostd.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
# This workflow checks whether the library is able to run without the std library (e.g., embedded).
2+
# This entire file should be removed if this crate does not support no-std See check.yml for
3+
# information about how the concurrency cancelation and workflow triggering works
14
permissions:
25
contents: read
36
on:
47
push:
58
branches: [main]
69
pull_request:
7-
# Spend CI time only on latest ref: https://github.com/jonhoo/rust-ci-conf/pull/5
810
concurrency:
911
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1012
cancel-in-progress: true

.github/workflows/safety.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
# This workflow runs checks for unsafe code. In crates that don't have any unsafe code, this can be
2+
# removed. Runs:
3+
# - miri - detects undefined behavior and memory leaks
4+
# - address santizer - detects memory errors
5+
# - leak sanitizer - detects memory leaks
6+
# - loom - Permutation testing for concurrent code https://crates.io/crates/loom
7+
# See check.yml for information about how the concurrency cancelation and workflow triggering works
18
permissions:
29
contents: read
310
on:
411
push:
512
branches: [main]
613
pull_request:
7-
# Spend CI time only on latest ref: https://github.com/jonhoo/rust-ci-conf/pull/5
814
concurrency:
915
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1016
cancel-in-progress: true

.github/workflows/scheduled.yml

Lines changed: 11 additions & 5 deletions
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 cancelation 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. if: hashFiles('Cargo.lock') != ''
3844
steps:
3945
- uses: actions/checkout@v3
4046
with:

.github/workflows/test.yml

Lines changed: 36 additions & 1 deletion
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 cancelation 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@v3
@@ -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 -Zminimal-direct that uses the minimal versions for direct
56+
# 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,6 +83,7 @@ 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:
@@ -69,6 +102,8 @@ jobs:
69102
- name: cargo test
70103
run: cargo test --locked --all-features --all-targets
71104
coverage:
105+
# use llvm-cov to build and collect coverage and outputs in a format that is compatible with
106+
# codecov.io
72107
runs-on: ubuntu-latest
73108
name: ubuntu / stable / coverage
74109
steps:

0 commit comments

Comments
 (0)