Skip to content

Commit

Permalink
[WIP] Syn MSRV
Browse files Browse the repository at this point in the history
  • Loading branch information
joshlf committed Jul 2, 2024
1 parent 7f3f2c0 commit f9ca7b5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 49 deletions.
54 changes: 10 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ jobs:
path: |
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}

# See comment in `Cargo.lock.ci` for why we do this.
- name: Copy `Cargo.lock.ci` to `Cargo.lock`
run: |
set -eo pipefail
cp Cargo.lock.ci Cargo.lock
- name: Configure environment variables
run: |
Expand Down Expand Up @@ -318,49 +324,6 @@ jobs:
diff <(./generate-readme.sh) README.md
exit $?
check_msrv:
needs: generate_cache
runs-on: ubuntu-latest
name: Check MSRVs match
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: |
~/.cargo/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}

# Make sure that the MSRV in zerocopy's and zerocopy-derive's `Cargo.toml`
# files are the same. In CI, we test with a single MSRV (the one indicated
# in zerocopy's `Cargo.toml`), so it's important that:
# - zerocopy-derive's MSRV is not lower than zerocopy's (we don't test with
# a lower MSRV in CI, so we couldn't guarantee that zerocopy-derive
# actually built and ran on a lower MSRV)
# - zerocopy-derive's MSRV is not higher than zerocopy's (this would mean
# that compiling zerocopy with the `derive` feature enabled would fail
# on its own published MSRV)
- name: Check MSRVs match
run: |
set -eo pipefail
# Usage: msrv <crate-name>
function msrv {
cargo metadata --format-version 1 | jq -r ".packages[] | select(.name == \"$1\").rust_version"
}
ver_zerocopy=$(msrv zerocopy)
ver_zerocopy_derive=$(msrv zerocopy-derive)
if [[ "$ver_zerocopy" == "$ver_zerocopy_derive" ]]; then
echo "Same MSRV ($ver_zerocopy) found for zerocopy and zerocopy-derive." | tee -a $GITHUB_STEP_SUMMARY
exit 0
else
echo "Different MSRVs found for zerocopy ($ver_zerocopy) and zerocopy-derive ($ver_zerocopy_derive)." \
| tee -a $GITHUB_STEP_SUMMARY >&2
exit 1
fi
check_versions:
needs: generate_cache
runs-on: ubuntu-latest
Expand Down Expand Up @@ -454,6 +417,9 @@ jobs:

- name: Populate cache
run: |
# See comment in `Cargo.lock.ci` for why we do this.
cp Cargo.lock.ci Cargo.lock
# Ensure all dependencies are downloaded - both for our crates and for
# tools we use in CI. We don't care about these tools succeeding for
# two reasons: First, this entire job is best-effort since it's just a
Expand Down Expand Up @@ -484,7 +450,7 @@ jobs:
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
if: failure()
runs-on: ubuntu-latest
needs: [build_test, kani, check_fmt, check_readme, check_msrv, check_versions, generate_cache]
needs: [build_test, kani, check_fmt, check_readme, check_versions, generate_cache]
steps:
- name: Mark the job as failed
run: exit 1
16 changes: 16 additions & 0 deletions Cargo.lock.ci

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions POLICIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,17 @@ documented guarantees do not hold.

## MSRV

Our minimum supported Rust version (MSRV) is encoded in our `Cargo.toml` file.
We consider an increase in MSRV to be a semver-breaking change, and will only
increase our MSRV during semver-breaking version changes (e.g., 0.1 -> 0.2, 1.0
-> 2.0, etc).
Without the `derive` feature enabled, zerocopy's minimum supported Rust version
(MSRV) is encoded the `package.rust-version` field in its `Cargo.toml` file. For
zerocopy, we consider an increase in MSRV to be a semver-breaking change, and
will only increase our MSRV during semver-breaking version changes (e.g., 0.1 ->
0.2, 1.0 -> 2.0, etc).

For zerocopy with the `derive` feature enabled, and for the zerocopy-derive
crate, we inherit the MSRV of our sole external dependency, syn. As of this
writing (2024-07-02), syn does *not* consider MSRV increases to be
semver-breaking changes. Thus, using the `derive` feature may result in the
effective MSRV increasing within a semver version train.

## Yanking

Expand Down
1 change: 0 additions & 1 deletion zerocopy-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ authors = ["Joshua Liebow-Feeser <[email protected]>"]
description = "Custom derive for traits from the zerocopy crate"
license = "BSD-2-Clause OR Apache-2.0 OR MIT"
repository = "https://github.com/google/zerocopy"
rust-version = "1.60.0"

# We prefer to include tests when publishing to crates.io so that Crater [1] can
# detect regressions in our test suite. These two tests are excessively large,
Expand Down

0 comments on commit f9ca7b5

Please sign in to comment.