Skip to content

Commit aac1b02

Browse files
committed
add ci
1 parent cfb1d58 commit aac1b02

File tree

3 files changed

+260
-0
lines changed

3 files changed

+260
-0
lines changed

.github/dependabot.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Taken from https://github.com/jonhoo/rust-ci-conf/blob/main/.github/dependabot.yml
2+
3+
version: 2
4+
updates:
5+
- package-ecosystem: github-actions
6+
directory: /optd-persistent
7+
schedule:
8+
interval: daily
9+
- package-ecosystem: cargo
10+
directory: /optd-persistent
11+
schedule:
12+
interval: daily
13+
ignore:
14+
- dependency-name: "*"
15+
# patch and minor updates don't matter for libraries as consumers of this library build
16+
# with their own lockfile, rather than the version specified in this library's lockfile
17+
# remove this ignore rule if your package has binaries to ensure that the binaries are
18+
# built with the exact set of dependencies and those are up to date.
19+
update-types:
20+
- "version-update:semver-patch"
21+
- "version-update:semver-minor"

.github/workflows/check.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Taken from https://github.com/jonhoo/rust-ci-conf/blob/main/.github/workflows/check.yml
2+
3+
# This workflow runs whenever a PR is opened or updated, or a commit is pushed to main. It runs
4+
# several checks:
5+
# - fmt: checks that the code is formatted according to rustfmt
6+
# - clippy: checks that the code does not contain any clippy warnings
7+
# - doc: checks that the code can be documented without errors
8+
# - hack: check combinations of feature flags
9+
# - msrv: check that the msrv specified in the crate is correct
10+
permissions:
11+
contents: read
12+
# This configuration allows maintainers of this repo to create a branch and pull request based on
13+
# the new branch. Restricting the push trigger to the main branch ensures that the PR only gets
14+
# built once.
15+
on:
16+
push:
17+
branches: [main]
18+
pull_request:
19+
# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that
20+
# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
23+
cancel-in-progress: true
24+
name: check
25+
jobs:
26+
fmt:
27+
runs-on: ubuntu-latest
28+
name: stable / fmt
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
submodules: true
33+
- name: Install stable
34+
uses: dtolnay/rust-toolchain@stable
35+
with:
36+
components: rustfmt
37+
- name: cargo fmt --check
38+
run: cargo fmt --check
39+
clippy:
40+
runs-on: ubuntu-latest
41+
name: ${{ matrix.toolchain }} / clippy
42+
permissions:
43+
contents: read
44+
checks: write
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
# Get early warning of new lints which are regularly introduced in beta channels.
49+
toolchain: [stable, beta]
50+
steps:
51+
- uses: actions/checkout@v4
52+
with:
53+
submodules: true
54+
- name: Install ${{ matrix.toolchain }}
55+
uses: dtolnay/rust-toolchain@master
56+
with:
57+
toolchain: ${{ matrix.toolchain }}
58+
components: clippy
59+
- name: cargo clippy
60+
uses: giraffate/clippy-action@v1
61+
with:
62+
reporter: 'github-pr-check'
63+
github_token: ${{ secrets.GITHUB_TOKEN }}
64+
semver:
65+
runs-on: ubuntu-latest
66+
name: semver
67+
steps:
68+
- uses: actions/checkout@v4
69+
with:
70+
submodules: true
71+
- name: Install stable
72+
uses: dtolnay/rust-toolchain@stable
73+
with:
74+
components: rustfmt
75+
- name: cargo-semver-checks
76+
uses: obi1kenobi/cargo-semver-checks-action@v2
77+
doc:
78+
# run docs generation on nightly rather than stable. This enables features like
79+
# https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an
80+
# API be documented as only available in some specific platforms.
81+
runs-on: ubuntu-latest
82+
name: nightly / doc
83+
steps:
84+
- uses: actions/checkout@v4
85+
with:
86+
submodules: true
87+
- name: Install nightly
88+
uses: dtolnay/rust-toolchain@nightly
89+
- name: Install cargo-docs-rs
90+
uses: dtolnay/install@cargo-docs-rs
91+
- name: cargo docs-rs
92+
run: cargo docs-rs
93+
hack:
94+
# cargo-hack checks combinations of feature flags to ensure that features are all additive
95+
# which is required for feature unification
96+
runs-on: ubuntu-latest
97+
name: ubuntu / stable / features
98+
steps:
99+
- uses: actions/checkout@v4
100+
with:
101+
submodules: true
102+
- name: Install stable
103+
uses: dtolnay/rust-toolchain@stable
104+
- name: cargo install cargo-hack
105+
uses: taiki-e/install-action@cargo-hack
106+
# intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4
107+
# --feature-powerset runs for every combination of features
108+
- name: cargo hack
109+
run: cargo hack --feature-powerset check
110+
msrv:
111+
# check that we can build using the minimal rust version that is specified by this crate
112+
runs-on: ubuntu-latest
113+
# we use a matrix here just because env can't be used in job names
114+
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
115+
strategy:
116+
matrix:
117+
msrv: ["1.56.1"] # 2021 edition requires 1.56
118+
name: ubuntu / ${{ matrix.msrv }}
119+
steps:
120+
- uses: actions/checkout@v4
121+
with:
122+
submodules: true
123+
- name: Install ${{ matrix.msrv }}
124+
uses: dtolnay/rust-toolchain@master
125+
with:
126+
toolchain: ${{ matrix.msrv }}
127+
- name: cargo +${{ matrix.msrv }} check
128+
run: cargo check

.github/workflows/test.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Taken from https://github.com/jonhoo/rust-ci-conf/blob/main/.github/workflows/test.yml
2+
3+
# This is the main CI workflow that runs the test suite on all pushes to main and all pull requests.
4+
# It runs the following jobs:
5+
# - required: runs the test suite on ubuntu with stable and beta rust toolchains
6+
# - minimal: runs the test suite with the minimal versions of the dependencies that satisfy the
7+
# requirements of this crate, and its dependencies
8+
# - os-check: runs the test suite on mac and windows
9+
# - coverage: runs the test suite and collects coverage information
10+
# See check.yml for information about how the concurrency cancellation and workflow triggering works
11+
permissions:
12+
contents: read
13+
on:
14+
push:
15+
branches: [main]
16+
pull_request:
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
19+
cancel-in-progress: true
20+
name: test
21+
jobs:
22+
required:
23+
runs-on: ubuntu-latest
24+
name: ubuntu / ${{ matrix.toolchain }}
25+
strategy:
26+
matrix:
27+
# run on stable and beta to ensure that tests won't break on the next version of the rust
28+
# toolchain
29+
toolchain: [stable, beta]
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
submodules: true
34+
- name: Install ${{ matrix.toolchain }}
35+
uses: dtolnay/rust-toolchain@master
36+
with:
37+
toolchain: ${{ matrix.toolchain }}
38+
- name: cargo generate-lockfile
39+
# enable this ci template to run regardless of whether the lockfile is checked in or not
40+
if: hashFiles('Cargo.lock') == ''
41+
run: cargo generate-lockfile
42+
# https://twitter.com/jonhoo/status/1571290371124260865
43+
- name: cargo test --locked
44+
run: cargo test --locked --all-features --all-targets
45+
# https://github.com/rust-lang/cargo/issues/6669
46+
- name: cargo test --doc
47+
run: cargo test --locked --all-features --doc
48+
minimal:
49+
# This action chooses the oldest version of the dependencies permitted by Cargo.toml to ensure
50+
# that this crate is compatible with the minimal version that this crate and its dependencies
51+
# require. This will pickup issues where this create relies on functionality that was introduced
52+
# later than the actual version specified (e.g., when we choose just a major version, but a
53+
# method was added after this version).
54+
#
55+
# This particular check can be difficult to get to succeed as often transitive dependencies may
56+
# be incorrectly specified (e.g., a dependency specifies 1.0 but really requires 1.1.5). There
57+
# is an alternative flag available -Zdirect-minimal-versions that uses the minimal versions for
58+
# direct dependencies of this crate, while selecting the maximal versions for the transitive
59+
# dependencies. Alternatively, you can add a line in your Cargo.toml to artificially increase
60+
# the minimal dependency, which you do with e.g.:
61+
# ```toml
62+
# # for minimal-versions
63+
# [target.'cfg(any())'.dependencies]
64+
# openssl = { version = "0.10.55", optional = true } # needed to allow foo to build with -Zminimal-versions
65+
# ```
66+
# The optional = true is necessary in case that dependency isn't otherwise transitively required
67+
# by your library, and the target bit is so that this dependency edge never actually affects
68+
# Cargo build order. See also
69+
# https://github.com/jonhoo/fantoccini/blob/fde336472b712bc7ebf5b4e772023a7ba71b2262/Cargo.toml#L47-L49.
70+
# This action is run on ubuntu with the stable toolchain, as it is not expected to fail
71+
runs-on: ubuntu-latest
72+
name: ubuntu / stable / minimal-versions
73+
steps:
74+
- uses: actions/checkout@v4
75+
with:
76+
submodules: true
77+
- name: Install stable
78+
uses: dtolnay/rust-toolchain@stable
79+
- name: Install nightly for -Zminimal-versions
80+
uses: dtolnay/rust-toolchain@nightly
81+
- name: rustup default stable
82+
run: rustup default stable
83+
- name: cargo update -Zminimal-versions
84+
run: cargo +nightly update -Zminimal-versions
85+
- name: cargo test
86+
run: cargo test --locked --all-features --all-targets
87+
os-check:
88+
# run cargo test on mac and windows
89+
runs-on: ${{ matrix.os }}
90+
name: ${{ matrix.os }} / stable
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
os: [macos-latest, windows-latest]
95+
steps:
96+
# if your project needs OpenSSL, uncomment this to fix Windows builds.
97+
# it's commented out by default as the install command takes 5-10m.
98+
# - run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
99+
# if: runner.os == 'Windows'
100+
# - run: vcpkg install openssl:x64-windows-static-md
101+
# if: runner.os == 'Windows'
102+
- uses: actions/checkout@v4
103+
with:
104+
submodules: true
105+
- name: Install stable
106+
uses: dtolnay/rust-toolchain@stable
107+
- name: cargo generate-lockfile
108+
if: hashFiles('Cargo.lock') == ''
109+
run: cargo generate-lockfile
110+
- name: cargo test
111+
run: cargo test --locked --all-features --all-targets

0 commit comments

Comments
 (0)