Skip to content

Commit 2a82569

Browse files
committed
Just pin dependencies for MSRV builds in CI
Pinning dependencies via Cargo.toml caused annoyance for many users building with up-to-date Rust versions as this affects the entire project being build and not just serialport. The build.yaml for GitHub Actions can serve as a guide on how to pin dependencies in your project if MSRV is an issue. The dependency libc was originally introduced just for pinning it as a subdependency but gets used in tests meanwhile.
1 parent 0eaadde commit 2a82569

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

.github/workflows/build.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ on:
1818
toolchain:
1919
default: stable
2020
type: string
21+
pinned-dependencies:
22+
default: false
23+
type: boolean
2124
continue-on-error:
2225
default: false
2326
type: boolean
@@ -82,6 +85,18 @@ jobs:
8285
- name: Build | rust-cache
8386
uses: Swatinem/rust-cache@v2
8487

88+
# Pin some dependencies (for building with MSRV 1.59.0) just here in CI
89+
# and not via Cargo.toml. The latter would enforce them to all users
90+
# and not just the ones who want to build with an old Rust release. See
91+
# issue https://github.com/serialport/serialport-rs/issues/324.
92+
- name: Build | pin certain dependencies
93+
if: ${{ inputs.pinned_dependencies == true }}
94+
run: |
95+
cargo update --precise 0.10.0 core-foundation
96+
cargo update --precise 0.2.163 libc
97+
cargo update --precise 1.0.101 proc-macro2
98+
cargo update --precise 1.0.22 unicode-ident
99+
85100
- name: Build | build library (default features)
86101
run: cargo build --target=${{ inputs.target }}
87102

Cargo.toml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ libudev = { version = "0.3.0", optional = true }
2323
unescaper = "0.1.3"
2424

2525
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
26-
# TODO: Remove pinning this dependency when we are bumping our MSRV.
27-
core-foundation = "=0.10.0"
26+
core-foundation = "0.10.0"
2827
core-foundation-sys = "0.8.4"
2928
io-kit-sys = "0.4.0"
3029
mach2 = "0.4.1"
@@ -49,23 +48,11 @@ cfg-if = "1.0.0"
4948
scopeguard = "1.1"
5049
serde = { version = "1.0", features = ["derive"], optional = true }
5150

52-
# TODO: Remove pinning this subdependency when we are bumping our MSRV.
53-
quote = ">=1, <=1.0.40"
54-
5551
[dev-dependencies]
5652
assert_hex = "0.4.1"
5753
clap = { version = "3.1.6", features = ["derive"] }
5854
envconfig = "0.10.0"
59-
# TODES Remove pinning this subdependency (of clap) when we are bumping our
60-
# MSRV (libc raised its MSRV with a patch release 0.2.167 from 1.19.0 to
61-
# 1.63.0). Trick the resolver into picking a compatible release of libc by
62-
# adding it as a direct dependency meanwhile.
63-
libc = ">=0.2.0, <=0.2.163"
64-
# TODO: Remove pinning this subdependency of clap when we are bumping our MSRV.
65-
# (There has been an incompatible change with the MSRV of os_str_bytes with
66-
# 6.6.0) Until then we are tricking the dependency resolver into using a
67-
# compatible version by adding it as a direct dependency here.
68-
os_str_bytes = ">=6.0, <6.6.0"
55+
libc = "0.2.163"
6956
quickcheck = "1.0.3"
7057
quickcheck_macros = "1.0.0"
7158
rstest = { version = "0.12.0", default-features = false }

0 commit comments

Comments
 (0)