Skip to content

Commit a02d52a

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 a02d52a

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-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+
pin-dependencies-for-msrv:
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.pin-dependencies-for-msrv == 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

.github/workflows/ci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
disable_tests: true
8888
target: aarch64-apple-darwin
8989
toolchain: "1.59.0"
90+
pin-dependencies-for-msrv: true
9091

9192
msrv-arm-linux-androideabi:
9293
uses: ./.github/workflows/build.yaml
@@ -95,6 +96,7 @@ jobs:
9596
disable_tests: true
9697
target: arm-linux-androideabi
9798
toolchain: "1.59.0"
99+
pin-dependencies-for-msrv: true
98100

99101
msrv-x86_64-unknown-freebsd:
100102
uses: ./.github/workflows/build.yaml
@@ -103,6 +105,7 @@ jobs:
103105
disable_tests: true
104106
target: x86_64-unknown-freebsd
105107
toolchain: "1.59.0"
108+
pin-dependencies-for-msrv: true
106109

107110
msrv-x86_64-unknown-linux-gnu:
108111
uses: ./.github/workflows/build.yaml
@@ -112,6 +115,7 @@ jobs:
112115
extra_packages: libudev-dev
113116
target: x86_64-unknown-linux-gnu
114117
toolchain: "1.59.0"
118+
pin-dependencies-for-msrv: true
115119

116120
msrv-x86_64-unknown-linux-musl:
117121
uses: ./.github/workflows/build.yaml
@@ -121,6 +125,7 @@ jobs:
121125
extra_packages: gcc-aarch64-linux-gnu
122126
target: aarch64-unknown-linux-musl
123127
toolchain: "1.59.0"
128+
pin-dependencies-for-msrv: true
124129

125130
msrv-x86_64-pc-windows-msvc:
126131
uses: ./.github/workflows/build.yaml
@@ -130,6 +135,7 @@ jobs:
130135
runs_on: windows-2025
131136
target: x86_64-pc-windows-msvc
132137
toolchain: "1.59.0"
138+
pin-dependencies-for-msrv: true
133139

134140
msrv-x86_64-unknown-netbsd:
135141
uses: ./.github/workflows/build.yaml
@@ -138,6 +144,7 @@ jobs:
138144
disable_tests: true
139145
target: x86_64-unknown-netbsd
140146
toolchain: "1.59.0"
147+
pin-dependencies-for-msrv: true
141148

142149
# --------------------------------------------------------------------------
143150
# Semantic Versioning

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)