Skip to content

Commit dcdf5c9

Browse files
committed
add basic ci
This commit adds basic CI to this repository, where workflows are rooted in the `optd-persistent` directory. Everything here is mostly taken from https://github.com/jonhoo/rust-ci-conf with some major removals and modifications for things we don't need.
1 parent a2ad0ea commit dcdf5c9

File tree

3 files changed

+253
-0
lines changed

3 files changed

+253
-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: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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+
defaults:
25+
run:
26+
working-directory: ./optd-persistent
27+
name: check
28+
jobs:
29+
fmt:
30+
runs-on: ubuntu-latest
31+
name: stable / fmt
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
submodules: true
36+
- name: Install stable
37+
uses: dtolnay/rust-toolchain@stable
38+
with:
39+
components: rustfmt
40+
- name: cargo fmt --check
41+
run: cargo fmt --check
42+
clippy:
43+
runs-on: ubuntu-latest
44+
name: ${{ matrix.toolchain }} / clippy
45+
permissions:
46+
contents: read
47+
checks: write
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
# Get early warning of new lints which are regularly introduced in beta channels.
52+
toolchain: [stable, beta]
53+
steps:
54+
- uses: actions/checkout@v4
55+
with:
56+
submodules: true
57+
- name: Install ${{ matrix.toolchain }}
58+
uses: dtolnay/rust-toolchain@master
59+
with:
60+
toolchain: ${{ matrix.toolchain }}
61+
components: clippy
62+
- name: cargo clippy
63+
uses: giraffate/clippy-action@v1
64+
with:
65+
reporter: 'github-pr-check'
66+
github_token: ${{ secrets.GITHUB_TOKEN }}
67+
doc:
68+
# run docs generation on nightly rather than stable. This enables features like
69+
# https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an
70+
# API be documented as only available in some specific platforms.
71+
runs-on: ubuntu-latest
72+
name: nightly / doc
73+
steps:
74+
- uses: actions/checkout@v4
75+
with:
76+
submodules: true
77+
- name: Install nightly
78+
uses: dtolnay/rust-toolchain@nightly
79+
- name: Install cargo-docs-rs
80+
uses: dtolnay/install@cargo-docs-rs
81+
- name: cargo docs-rs
82+
run: cargo docs-rs
83+
hack:
84+
# cargo-hack checks combinations of feature flags to ensure that features are all additive
85+
# which is required for feature unification
86+
runs-on: ubuntu-latest
87+
name: ubuntu / stable / features
88+
steps:
89+
- uses: actions/checkout@v4
90+
with:
91+
submodules: true
92+
- name: Install stable
93+
uses: dtolnay/rust-toolchain@stable
94+
- name: cargo install cargo-hack
95+
uses: taiki-e/install-action@cargo-hack
96+
# intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4
97+
# --feature-powerset runs for every combination of features
98+
- name: cargo hack
99+
run: cargo hack --feature-powerset check
100+
msrv:
101+
# check that we can build using the minimal rust version that is specified by this crate
102+
runs-on: ubuntu-latest
103+
# we use a matrix here just because env can't be used in job names
104+
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
105+
strategy:
106+
matrix:
107+
msrv: ["1.81.0"] # Start with first version that supports error_in_core
108+
name: ubuntu / ${{ matrix.msrv }}
109+
steps:
110+
- uses: actions/checkout@v4
111+
with:
112+
submodules: true
113+
- name: Install ${{ matrix.msrv }}
114+
uses: dtolnay/rust-toolchain@master
115+
with:
116+
toolchain: ${{ matrix.msrv }}
117+
- name: cargo +${{ matrix.msrv }} check
118+
run: cargo check

.github/workflows/test.yml

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

0 commit comments

Comments
 (0)