Skip to content

Commit 14a5dcb

Browse files
asomersSteveLauC
andauthored
Fix CI by relaxing our MSRV constraint (#2689)
* Fix CI by relaxing our MSRV constraint Recently a transitive dev-dependency published a new version that is incompatible with Nix's MSRV, causing CI to break. That's annoying, because there's really no reason why a crate's dev-dependencies ought to respect the MSRV. Fix Nix's CI by: * Running all tests with stable Rust (or nightly, for certain targets) * Adding an additional set of CI checks to ensure that the crate will compile with MSRV, on all of the major operating systems, but don't try to compile its tests. * Eliminate the now-redundant "rust-stable" CI task. * Don't use --all-targets when testing MSRV * Fix some Clippy warnings on apple I think these never showed up in CI before, because we've never run clippy on Rust stable on apple until now. * Suppress a Clippy false positive * GetCString only needs to be build with features=net * Fix Clippy on Solarish, with Rust stable * Disable the libc::personality doc test on QEMU It's failing there with EPERM. It's probably seccomp's fault * Skip lio_listio doc test on musl/aarch64/i686 as it hangs Do not run this doc test on: * aarch64-unknown-linux-musl * i686-unknown-linux-musl because it hangs on these targets. After further debugging, we think this is likely a bug of musl. Since we only test our bindings and do not intend to fix the underlying libc bug, we skip this test here. See this thread [1] for the discussion of this issue [1]: #2689 (comment) * Run rustfmt on src/sys/aio.rs * Set RUST_BACKTRACE=1 when running tests Set this to enable the backtrace to make debugging easier * Cross env var passthrough: RUSTDOCFLAGS and RUST_BACKTRACE I don't know if "RUSTDOCFLAGS" will be passed automatically, but from their doc [1]: > In the instances that you do want to pass through additional environment > variables, this can be done via build.env.passthrough in your Cross.toml: > > ```toml > [build.env] > passthrough = [ > "RUST_BACKTRACE" > ] > ``` We do need to specify "RUST_BACKTRACE" here. Anyway, let's pass both in case Cross won't do this for us. [1]: https://github.com/cross-rs/cross/blob/49cd054de9b832dfc11a4895c72b0aef533b5c6a/docs/environment_variables.md#environment-variable-passthrough * Disable the ScmTimestamp doc test on 32-bit musl Because this platform has very unique behavior. It can be worked around, but our doc test does not include that workaround. #2698 --------- Co-authored-by: Steve Lau <stevelauc@outlook.com>
1 parent a5b6062 commit 14a5dcb

File tree

10 files changed

+123
-56
lines changed

10 files changed

+123
-56
lines changed

.cirrus.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ task:
5050
setup_script:
5151
- kldload mqueuefs
5252
- fetch https://sh.rustup.rs -o rustup.sh
53-
- sh rustup.sh -y --profile=minimal --default-toolchain $MSRV
53+
- sh rustup.sh -y --profile=minimal --default-toolchain stable
5454
- . $HOME/.cargo/env
5555
- rustup target add i686-unknown-freebsd
5656
- rustup component add clippy

.github/actions/build/action.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ inputs:
2121
required: false
2222
default: -D warnings
2323

24+
TARGETS:
25+
description: 'Build all targets or only default?'
26+
required: false
27+
default: "--all-targets"
28+
2429
TOOL:
2530
description: 'Tool used to involve the BUILD command, can be cargo or cross'
2631
required: false
@@ -30,6 +35,16 @@ inputs:
3035
required: false
3136
default:
3237

38+
NOCLIPPY:
39+
description: "whether to run cargo clippy"
40+
required: false
41+
default: false
42+
43+
NODOC:
44+
description: "whether to run cargo doc"
45+
required: false
46+
default: false
47+
3348
NOHACK:
3449
description: "whether to run cargo hack"
3550
required: false
@@ -52,13 +67,15 @@ runs:
5267
5368
- name: build
5469
shell: bash
55-
run: ${{ inputs.TOOL }} ${{ inputs.BUILD }} ${{ inputs.ZFLAGS }} --target ${{ inputs.TARGET }} --all-targets --all-features
70+
run: ${{ inputs.TOOL }} ${{ inputs.BUILD }} ${{ inputs.ZFLAGS }} --target ${{ inputs.TARGET }} ${{ inputs.TARGETS }} --all-features
5671

5772
- name: doc
73+
if: inputs.NODOC == 'false'
5874
shell: bash
5975
run: ${{ inputs.TOOL }} doc ${{ inputs.ZFLAGS }} --no-deps --target ${{ inputs.TARGET }} --all-features
6076

6177
- name: clippy
78+
if: inputs.NOCLIPPY == 'false'
6279
shell: bash
6380
run: ${{ inputs.TOOL}} clippy ${{ inputs.ZFLAGS }} --target ${{ inputs.TARGET }} --all-targets --all-features -- ${{ inputs.CLIPPYFLAGS }}
6481

.github/actions/test/action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,20 @@ inputs:
1919
required: false
2020
default: -D warnings -A unknown-lints
2121

22+
RUSTDOCFLAGS:
23+
required: false
24+
default: -D warnings
25+
2226
runs:
2327
using: "composite"
2428
steps:
2529
- name: set up Rust env
2630
shell: bash
2731
run: |
2832
echo "RUSTFLAGS=${{ inputs.RUSTFLAGS }}" >> $GITHUB_ENV
33+
echo "RUSTDOCFLAGS=${{ inputs.RUSTDOCFLAGS }}" >> $GITHUB_ENV
34+
# Enable backtrace to make debugging easier
35+
echo "RUST_BACKTRACE=1" >> $GITHUB_ENV
2936
3037
- name: test
3138
shell: bash

.github/workflows/ci.yml

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ permissions:
1414

1515
env:
1616
MSRV: 1.69.0
17-
# Rust's Loongarch support merged in 1.71.0
18-
MSRV_LOONGARCH: 1.71.0
19-
# Minimal Rust version to support all 3 official OpenHarmony targets as tier2
20-
MSRV_OHOS: 1.78.0
2117
RUSTFLAGS: -Dwarnings
2218

2319
jobs:
@@ -32,7 +28,7 @@ jobs:
3228
- name: setup Rust
3329
uses: dtolnay/rust-toolchain@master
3430
with:
35-
toolchain: '${{ env.MSRV }}'
31+
toolchain: stable
3632
components: clippy
3733

3834
- name: build
@@ -59,7 +55,7 @@ jobs:
5955
- name: setup Rust
6056
uses: dtolnay/rust-toolchain@master
6157
with:
62-
toolchain: '${{ env.MSRV }}'
58+
toolchain: stable
6359
components: clippy
6460

6561
- name: build
@@ -79,7 +75,7 @@ jobs:
7975
# cross needs to execute Docker, GitHub Action already has it installed
8076
cross:
8177
runs-on: ubuntu-24.04
82-
needs: [rustfmt, minver, macos, x86_64_linux_native_builds, rust_stable]
78+
needs: [rustfmt, minver, macos, x86_64_linux_native_builds]
8379
strategy:
8480
fail-fast: false
8581
matrix:
@@ -108,8 +104,7 @@ jobs:
108104
- name: setup Rust
109105
uses: dtolnay/rust-toolchain@master
110106
with:
111-
# Use a newer version rustc if the target is Loongarch, remove this workaround after MSRV is newer than 1.71.0
112-
toolchain: "${{ matrix.target == 'loongarch64-unknown-linux-gnu' && env.MSRV_LOONGARCH || env.MSRV }}"
107+
toolchain: stable
113108
components: clippy
114109

115110
# cross relies on docker or podman, GitHub Acton already has it installed.
@@ -132,6 +127,7 @@ jobs:
132127
SUDO: ""
133128
TOOL: cross
134129
RUSTFLAGS: --cfg qemu -D warnings
130+
RUSTDOCFLAGS: --cfg qemu
135131

136132
- name: before_cache_script
137133
run: rm -rf $CARGO_HOME/registry/index
@@ -156,7 +152,7 @@ jobs:
156152
- name: setup Rust
157153
uses: dtolnay/rust-toolchain@master
158154
with:
159-
toolchain: '${{ env.MSRV }}'
155+
toolchain: stable
160156
components: clippy
161157

162158
- name: install targets
@@ -193,7 +189,7 @@ jobs:
193189
- name: setup Rust
194190
uses: dtolnay/rust-toolchain@master
195191
with:
196-
toolchain: '${{ env.MSRV }}'
192+
toolchain: stable
197193
components: clippy
198194

199195
- name: install targets
@@ -212,38 +208,11 @@ jobs:
212208
- name: before_cache_script
213209
run: sudo rm -rf $CARGO_HOME/registry/index;
214210

215-
rust_stable:
216-
runs-on: ubuntu-latest
217-
env:
218-
TARGET: x86_64-unknown-linux-gnu
219-
steps:
220-
- name: checkout
221-
uses: actions/checkout@v4
222-
223-
- name: setup Rust
224-
uses: dtolnay/rust-toolchain@stable
225-
with:
226-
components: clippy
227-
228-
- name: build
229-
uses: ./.github/actions/build
230-
with:
231-
TARGET: '${{ env.TARGET }}'
232-
233-
- name: test
234-
uses: ./.github/actions/test
235-
with:
236-
TARGET: '${{ env.TARGET }}'
237-
238-
- name: before_cache_script
239-
run: sudo rm -rf $CARGO_HOME/registry/index
240-
241-
242211

243212
# Tasks for cross-compiling, but no testing
244213
cross_compiling:
245214
runs-on: ubuntu-latest
246-
needs: [rustfmt, minver, macos, x86_64_linux_native_builds, rust_stable]
215+
needs: [rustfmt, minver, macos, x86_64_linux_native_builds]
247216
env:
248217
BUILD: check
249218
strategy:
@@ -282,8 +251,7 @@ jobs:
282251
- name: setup Rust
283252
uses: dtolnay/rust-toolchain@master
284253
with:
285-
# Use a newer version rustc if it is OpenHarmony, remove this workaround after MSRV is newer than 1.78.0
286-
toolchain: "${{ contains(matrix.target, 'ohos') && env.MSRV_OHOS || env.MSRV }}"
254+
toolchain: stable
287255
components: clippy
288256

289257
- name: install targets
@@ -299,10 +267,56 @@ jobs:
299267
- name: before_cache_script
300268
run: rm -rf $CARGO_HOME/registry/index
301269

270+
# Check that Nix will build on the MSRV, on a variety of operating systems.
271+
# But don't check the tests. Those are not required to build on MSRV.
272+
msrv:
273+
runs-on: ubuntu-latest
274+
needs: [rustfmt, minver, macos, x86_64_linux_native_builds]
275+
env:
276+
BUILD: check
277+
NOCLIPPY: true
278+
NODOC: true
279+
NOHACK: true
280+
TARGETS: ""
281+
strategy:
282+
fail-fast: false
283+
matrix:
284+
include:
285+
- target: aarch64-linux-android
286+
- target: x86_64-unknown-linux-gnu
287+
- target: x86_64-unknown-linux-musl
288+
- target: aarch64-apple-darwin
289+
- target: x86_64-unknown-freebsd
290+
- target: x86_64-unknown-netbsd
291+
steps:
292+
- name: checkout
293+
uses: actions/checkout@v4
294+
295+
- name: setup Rust
296+
uses: dtolnay/rust-toolchain@master
297+
with:
298+
toolchain: $MSRV
299+
300+
- name: install targets
301+
run: rustup target add ${{ matrix.target }}
302+
303+
- name: build
304+
uses: ./.github/actions/build
305+
with:
306+
TARGET: '${{ matrix.target }}'
307+
TARGETS: '${{ env.TARGETS }}'
308+
BUILD: '${{ env.BUILD }}'
309+
NOCLIPPY: '${{ env.NOCLIPPY }}'
310+
NODOC: '${{ env.NODOC }}'
311+
NOHACK: '${{ env.NOHACK }}'
312+
313+
- name: before_cache_script
314+
run: rm -rf $CARGO_HOME/registry/index
315+
302316

303317
redox:
304318
runs-on: ubuntu-latest
305-
needs: [rustfmt, minver, macos, x86_64_linux_native_builds, rust_stable]
319+
needs: [rustfmt, minver, macos, x86_64_linux_native_builds]
306320
env:
307321
TARGET: x86_64-unknown-redox
308322
CLIPPYFLAGS: -D warnings

Cross.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
[build.env]
22
passthrough = [
33
"RUSTFLAGS",
4-
"RUST_TEST_THREADS"
4+
"RUSTDOCFLAGS",
5+
"RUST_TEST_THREADS",
6+
"RUST_BACKTRACE",
57
]
68

79
[target.loongarch64-unknown-linux-gnu]

src/sys/aio.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ impl<'a> AioFsync<'a> {
456456
/// * `fd`: File descriptor to sync.
457457
/// * `mode`: Whether to sync file metadata too, or just data.
458458
/// * `prio`: If POSIX Prioritized IO is supported, then the
459-
/// operation will be prioritized at the process's priority level minus
459+
/// operation will be prioritized at the process's priority level minus
460460
/// `prio`.
461461
/// * `sigev_notify`: Determines how you will be notified of event completion.
462462
pub fn new(
@@ -1141,7 +1141,29 @@ pub fn aio_suspend(
11411141
/// `EINTR`, in which case some but not all operations may have been submitted.
11421142
/// In that case, you must check the status of each individual operation, and
11431143
/// possibly resubmit some.
1144-
/// ```
1144+
///
1145+
// Do not run this doc test on:
1146+
// * aarch64-unknown-linux-musl
1147+
// * i686-unknown-linux-musl
1148+
// because it hangs on these targets. After further debugging, we think this is
1149+
// likely a bug of musl. Since we only test our bindings and do not intend to
1150+
// fix the underlying libc bug, we skip this test here.
1151+
// See this thread for the discussion of this issue:
1152+
// https://github.com/nix-rust/nix/pull/2689#issuecomment-3419813159
1153+
#[cfg_attr(
1154+
all(
1155+
target_env = "musl",
1156+
any(target_arch = "aarch64", target_arch = "x86")
1157+
),
1158+
doc = " ```no_run"
1159+
)]
1160+
#[cfg_attr(
1161+
not(all(
1162+
target_env = "musl",
1163+
any(target_arch = "aarch64", target_arch = "x86")
1164+
)),
1165+
doc = " ```"
1166+
)]
11451167
/// # use libc::c_int;
11461168
/// # use std::os::unix::io::AsFd;
11471169
/// # use std::sync::atomic::{AtomicBool, Ordering};

src/sys/personality.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ libc_bitflags! {
5454
///
5555
/// Example:
5656
///
57-
/// ```
57+
#[cfg_attr(any(qemu, target_arch = "aarch64"), doc = " ```no_run")]
58+
#[cfg_attr(not(any(qemu, target_arch = "aarch64")), doc = " ```")]
5859
/// # use nix::sys::personality::{self, Persona};
5960
/// let pers = personality::get().unwrap();
6061
/// assert!(!pers.contains(Persona::WHOLE_SECONDS));
@@ -78,10 +79,10 @@ pub fn get() -> Result<Persona> {
7879
///
7980
/// Example:
8081
///
81-
// Disable test on aarch64 until we know why it fails.
82+
// Disable test on aarch64 and with QEMU. seccomp interference is suspected.
8283
// https://github.com/nix-rust/nix/issues/2060
83-
#[cfg_attr(target_arch = "aarch64", doc = " ```no_run")]
84-
#[cfg_attr(not(target_arch = "aarch64"), doc = " ```")]
84+
#[cfg_attr(any(qemu, target_arch = "aarch64"), doc = " ```no_run")]
85+
#[cfg_attr(not(any(qemu, target_arch = "aarch64")), doc = " ```")]
8586
/// # use nix::sys::personality::{self, Persona};
8687
/// let mut pers = personality::get().unwrap();
8788
/// assert!(!pers.contains(Persona::ADDR_NO_RANDOMIZE));

src/sys/socket/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,9 @@ pub enum ControlMessageOwned {
772772
///
773773
/// # Examples
774774
///
775-
/// ```
775+
#[cfg_attr(all(target_env = "musl", target_pointer_width = "32"), doc = "See <https://github.com/nix-rust/nix/issues/2698> for notes regarding 32-bit musl")]
776+
#[cfg_attr(all(target_env = "musl", target_pointer_width = "32"), doc = "```no_run")]
777+
#[cfg_attr(any(not(target_env = "musl"), target_pointer_width = "64"), doc="```")]
776778
/// # #[macro_use] extern crate nix;
777779
/// # use nix::sys::socket::*;
778780
/// # use nix::sys::time::*;

src/sys/socket/sockopt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,12 +1972,14 @@ impl<'a> Set<'a, OsString> for SetOsString<'a> {
19721972

19731973
/// Getter for a `CString` value.
19741974
#[cfg(apple_targets)]
1975+
#[cfg(feature = "net")]
19751976
struct GetCString<T: AsMut<[u8]>> {
19761977
len: socklen_t,
19771978
val: MaybeUninit<T>,
19781979
}
19791980

19801981
#[cfg(apple_targets)]
1982+
#[cfg(feature = "net")]
19811983
impl<T: AsMut<[u8]>> Get<CString> for GetCString<T> {
19821984
fn uninit() -> Self {
19831985
GetCString {

test/test_sendfile.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ fn test_sendfile_dragonfly() {
159159
fn test_sendfile_darwin() {
160160
// Declare the content
161161
let header_strings =
162-
vec!["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"];
162+
["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"];
163163
let body = "Xabcdef123456";
164164
let body_offset = 1;
165-
let trailer_strings = vec!["\n", "Served by Make Believe\n"];
165+
let trailer_strings = ["\n", "Served by Make Believe\n"];
166166

167167
// Write the body to a file
168168
let mut tmp = tempfile().unwrap();
@@ -195,7 +195,7 @@ fn test_sendfile_darwin() {
195195
+ &trailer_strings.concat();
196196

197197
// Verify the message that was sent
198-
assert_eq!(bytes_written as usize, expected_string.as_bytes().len());
198+
assert_eq!(bytes_written as usize, expected_string.len());
199199

200200
let mut read_string = String::new();
201201
let bytes_read = rd.read_to_string(&mut read_string).unwrap();
@@ -258,7 +258,7 @@ fn test_sendfilev() {
258258
+ &trailer_strings.concat();
259259

260260
// Verify the message that was sent
261-
assert_eq!(bytes_written, expected_string.as_bytes().len());
261+
assert_eq!(bytes_written, expected_string.len());
262262

263263
let mut read_string = String::new();
264264
let bytes_read = rd.read_to_string(&mut read_string).unwrap();

0 commit comments

Comments
 (0)