Skip to content

Commit

Permalink
Use Cargo.lock for testing against MSRV instead of pinning
Browse files Browse the repository at this point in the history
Some newer versions of transitive dev-dependencies don't work with the
minimum supported Rust version (1.46.0), so I used to pin them in
`Cargo.toml` whenever the MSRV build would break (tedious work). The
disadvantage of that is that older versions of those deps are used even
on newer Rust versions.

The latest breakage is matklad/once_cell#201,
but instead of pinning that to an older version too, this instead
introduces a `Cargo.lock` file that is only used for the MSRV build.

So newer Rust versions will continue to test against latest
dependencies, while the MSRV build should continue to work with the
older versions. One disadvantage with this is that consumers will need
to figure out their own `Cargo.lock` with precise versions that work
with older Rust versions, but that is expected to be a small number -
especially because in this case they are all dev-dependencies anyway.
  • Loading branch information
robinst committed Sep 30, 2022
1 parent 3be62ab commit 1343064
Show file tree
Hide file tree
Showing 3 changed files with 629 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -36,6 +36,9 @@ jobs:
- 1.46.0 # MSRV (minimum supported Rust version)
- stable
- beta
include:
- rust: 1.46.0
msrv: true
steps:
- name: Checkout sources
uses: actions/checkout@v2
Expand All @@ -47,6 +50,13 @@ jobs:
profile: minimal
override: true

# See https://github.com/matklad/once_cell/issues/201
# To test locally, enable the lock file and then run:
# $ docker run --rm --user "$(id -u)":"$(id -g)" -v "$PWD":/usr/src/myapp -w /usr/src/myapp rust:1.46.0 cargo test
- name: Use Cargo.lock for MSRV
if: ${{ matrix.msrv }}
run: cp Cargo.lock.msrv Cargo.lock

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
Expand Down

0 comments on commit 1343064

Please sign in to comment.