Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Run direct-minimal-versions tests on a weekly basis
Browse files Browse the repository at this point in the history
My understanding is that it's okay that we don't use these minimal
versions directly in our normal/committed Cargo.lock file, because we
may want to pick up more recent compatible versions that have addressed
security issues or improved performance, etc. That said, we still
want to periodically test the minimal versions to ensure that our own
project still compiles and runs as expected. This will help to increase
compatibility across the whole Rust ecosystem when there are shared
dependencies and someone is using our library.

I've also abstracted out the CUE _testRust steps here, so they can be
shared.

See:
- rust-lang/cargo#11688
- https://doc.rust-lang.org/beta/cargo/reference/unstable.html#minimal-versions
- https://users.rust-lang.org/t/psa-please-specify-precise-dependency-versions-in-cargo-toml/71277
- https://twitter.com/jonhoo/status/1571290371124260865
- cue-lang/cue#860
  • Loading branch information
elasticdog committed May 7, 2023
1 parent 9c912b0 commit 79af197
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 14 deletions.
14 changes: 1 addition & 13 deletions .github/cue/rust.cue
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,7 @@ rust: _#useMergeQueue & {
_#checkoutCode,
_#installRust,
_#cacheRust & {with: "shared-key": "stable-${{ matrix.platform }}"},
_#installTool & {with: tool: "cargo-nextest"},
{
name: "Compile tests"
run: "cargo test --locked --no-run"
},
{
name: "Run tests"
run: "cargo nextest run --locked"
},
{
name: "Run doctests"
run: "cargo test --locked --doc"
},
for step in _testRust {step},
]
}

Expand Down
44 changes: 44 additions & 0 deletions .github/cue/scheduled.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package workflows

scheduled: {
name: "scheduled"

on: {
// Run every Monday at 7:45am UTC.
schedule: [{cron: "45 7 * * 1"}]

// Allow manually running this workflow.
workflow_dispatch: null
}

concurrency: {
group: "${{ github.workflow }}-${{ github.ref }}"
"cancel-in-progress": true
}

env: {
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: "always"
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
}

jobs: direct_minimal_versions: {
name: "direct-minimal-versions / stable"
"runs-on": defaultRunner
steps: [
_#checkoutCode & {with: ref: defaultBranch},
_#installRust,
_#installRust & {with: toolchain: "nightly"},
{
name: "Default to stable Rust"
run: "rustup default stable"
},
{
name: "Resolve minimal dependency versions instead of maximum"
run: "cargo +nightly update -Z direct-minimal-versions"
},
for step in _testRust {step},
]
}
}
16 changes: 16 additions & 0 deletions .github/cue/shared-steps.cue
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,19 @@ _#prettier: _#step & {
uses: "creyD/prettier_action@31355f8eef017f8aeba2e0bc09d8502b13dbbad1"
with: prettier_version: "2.8.8"
}

_testRust: [
_#installTool & {with: tool: "cargo-nextest"},
_#step & {
name: "Compile tests"
run: "cargo test --locked --no-run"
},
_#step & {
name: "Run tests"
run: "cargo nextest run --locked --all-targets --all-features"
},
_#step & {
name: "Run doctests"
run: "cargo test --locked --doc"
},
]
1 change: 1 addition & 0 deletions .github/cue/workflows.cue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ workflows: [
{workflow: githubPages},
{workflow: preloadCaches},
{workflow: rust},
{workflow: scheduled},
{workflow: wordsmith},
]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ jobs:
- name: Compile tests
run: cargo test --locked --no-run
- name: Run tests
run: cargo nextest run --locked
run: cargo nextest run --locked --all-targets --all-features
- name: Run doctests
run: cargo test --locked --doc
check_msrv:
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This file is generated by .github/cue/ci_tool.cue; DO NOT EDIT!

name: scheduled
"on":
schedule:
- cron: 45 7 * * 1
workflow_dispatch: null
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
jobs:
direct_minimal_versions:
name: direct-minimal-versions / stable
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with:
ref: main
- name: Install stable Rust toolchain
uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d
with:
toolchain: stable
- name: Install nightly Rust toolchain
uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d
with:
toolchain: nightly
- name: Default to stable Rust
run: rustup default stable
- name: Resolve minimal dependency versions instead of maximum
run: cargo +nightly update -Z direct-minimal-versions
- name: Install cargo-nextest
uses: taiki-e/install-action@a775aaf2e8ed709f76ee019cb77e39fc50613631
with:
tool: cargo-nextest
- name: Compile tests
run: cargo test --locked --no-run
- name: Run tests
run: cargo nextest run --locked --all-targets --all-features
- name: Run doctests
run: cargo test --locked --doc

0 comments on commit 79af197

Please sign in to comment.