From 22add73b3a13e2ec230385517607e0aad829c7d7 Mon Sep 17 00:00:00 2001 From: Aaron Bull Schaefer Date: Fri, 5 May 2023 15:30:24 -0700 Subject: [PATCH] Run direct-minimal-versions tests on a weekly basis 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: - https://github.com/rust-lang/cargo/pull/11688 - https://users.rust-lang.org/t/psa-please-specify-precise-dependency-versions-in-cargo-toml/71277 - https://twitter.com/jonhoo/status/1571290371124260865 - https://github.com/cue-lang/cue/discussions/860 --- .github/cue/rust.cue | 14 +--------- .github/cue/scheduled.cue | 44 +++++++++++++++++++++++++++++++ .github/cue/shared-steps.cue | 16 ++++++++++++ .github/cue/workflows.cue | 1 + .github/workflows/rust.yml | 2 +- .github/workflows/scheduled.yml | 46 +++++++++++++++++++++++++++++++++ 6 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 .github/cue/scheduled.cue create mode 100644 .github/workflows/scheduled.yml diff --git a/.github/cue/rust.cue b/.github/cue/rust.cue index da50a71..800b72a 100644 --- a/.github/cue/rust.cue +++ b/.github/cue/rust.cue @@ -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}, ] } diff --git a/.github/cue/scheduled.cue b/.github/cue/scheduled.cue new file mode 100644 index 0000000..0f42985 --- /dev/null +++ b/.github/cue/scheduled.cue @@ -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 -Zdirect-minimal-versions" + }, + for step in _testRust {step}, + ] + } +} diff --git a/.github/cue/shared-steps.cue b/.github/cue/shared-steps.cue index f5acc75..4ca070d 100644 --- a/.github/cue/shared-steps.cue +++ b/.github/cue/shared-steps.cue @@ -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" + }, +] diff --git a/.github/cue/workflows.cue b/.github/cue/workflows.cue index aef98f3..533d43b 100644 --- a/.github/cue/workflows.cue +++ b/.github/cue/workflows.cue @@ -14,6 +14,7 @@ workflows: [ {workflow: githubPages}, {workflow: preloadCaches}, {workflow: rust}, + {workflow: scheduled}, {workflow: wordsmith}, ] diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cdfabcf..75fb55d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -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: diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml new file mode 100644 index 0000000..3d98b90 --- /dev/null +++ b/.github/workflows/scheduled.yml @@ -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 -Zdirect-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