Skip to content

Commit 8374f9d

Browse files
authored
Merge pull request #50 from Rust-for-Linux/ci-fix
fix various mistakes in the CI
2 parents 21f7275 + ac7d1e9 commit 8374f9d

13 files changed

+247
-153
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ jobs:
1515
with:
1616
components: rustfmt
1717
- run: git config user.name "github-runner" && git config user.email "<>"
18-
- run: git rebase --exec 'cargo fmt --check' --root
19-
- run: git rebase --exec 'cd internal && cargo fmt --check' --root
18+
- run: git rebase --exec 'cargo fmt --check --all' --root
2019
readme:
2120
runs-on: ubuntu-latest
2221
steps:
@@ -40,7 +39,9 @@ jobs:
4039
with:
4140
components: rust-src
4241
- run: git config user.name "github-runner" && git config user.email "<>"
43-
- run: git rebase --exec 'cargo doc --no-deps' --root
42+
- run: git rebase --exec 'cargo doc --all-features --no-deps' --root
43+
env:
44+
RUSTFLAGS: "-Dwarnings"
4445
clippy:
4546
runs-on: ubuntu-latest
4647
steps:
@@ -53,7 +54,14 @@ jobs:
5354
components: clippy
5455
- run: cargo install cargo-hack
5556
- run: git config user.name "github-runner" && git config user.email "<>"
56-
- run: git rebase --exec 'cargo hack --clean-per-run --feature-powerset clippy --locked' --exec 'cargo clean' --root
57+
# examples and tests require `alloc`, since they make extensive use of `Box` etc.
58+
- run: git rebase --exec 'cargo hack --clean-per-run --feature-powerset clippy --all-targets --locked --features alloc' --exec 'cargo clean' --root
59+
env:
60+
RUSTFLAGS: "-Dwarnings"
61+
# the core lib does not, so also check that without the alloc feature.
62+
- run: git rebase --exec 'cargo hack --clean-per-run --feature-powerset clippy --lib --locked' --exec 'cargo clean' --root
63+
env:
64+
RUSTFLAGS: "-Dwarnings"
5765
test:
5866
runs-on: ubuntu-latest
5967
steps:
@@ -63,10 +71,19 @@ jobs:
6371
components: rust-src
6472
- run: cargo install cargo-expand
6573
- run: git config user.name "github-runner" && git config user.email "<>"
66-
- run: git rebase --exec 'cargo test --locked' --root
74+
- run: git rebase --exec 'cargo test --locked --all-targets' --root
75+
env:
76+
RUSTFLAGS: "-Dwarnings"
77+
# doctests are strangely not included in --all-targets
78+
- run: git rebase --exec 'cargo test --locked --doc' --root
79+
env:
80+
RUSTFLAGS: "-Dwarnings"
6781
miri:
6882
runs-on: ubuntu-latest
69-
name: "miri"
83+
name: "miri (${{matrix.MIRIFLAGS}})"
84+
strategy:
85+
matrix:
86+
MIRIFLAGS: ["", "-Zmiri-tree-borrows", "-Zmiri-strict-provenance", "-Zmiri-tree-borrows -Zmiri-strict-provenance"]
7087
steps:
7188
- uses: actions/checkout@v4
7289
with:
@@ -81,18 +98,20 @@ jobs:
8198
components: miri, rust-src
8299
- run: cargo install cargo-expand
83100
- run: git config user.name "github-runner" && git config user.email "<>"
84-
- run: git rebase --exec 'cargo miri test --locked' --root
85-
- run: git rebase --exec 'cargo miri test --locked' --root
101+
- run: git rebase --exec 'cargo miri test --locked --all-targets' --root
86102
env:
87-
MIRIFLAGS: "-Zmiri-tree-borrows"
88-
- run: git rebase --exec 'cargo miri test --locked' --root
103+
RUSTFLAGS: "-Dwarnings"
104+
MIRIFLAGS: ${{matrix.MIRIFLAGS}}
105+
# doctests are strangely not included in --all-targets
106+
- run: git rebase --exec 'cargo miri test --locked --doc' --root
89107
env:
90-
MIRIFLAGS: "-Zmiri-strict-provenance"
91-
- run: git rebase --exec 'cargo miri test --locked' --root
92-
env:
93-
MIRIFLAGS: "-Zmiri-tree-borrows -Zmiri-strict-provenance"
108+
RUSTFLAGS: "-Dwarnings"
109+
MIRIFLAGS: ${{matrix.MIRIFLAGS}}
94110
sanitizers:
95111
runs-on: ubuntu-latest
112+
strategy:
113+
matrix:
114+
targets: ["--doc", "--all-targets"]
96115
steps:
97116
- uses: actions/checkout@v4
98117
with:
@@ -109,10 +128,20 @@ jobs:
109128
- run: git rebase --exec "sed -i '/\[features\]/i [profile.dev]' Cargo.toml && sed -i '/profile.dev/a opt-level = 1' Cargo.toml && cargo test --lib --tests --target x86_64-unknown-linux-gnu && git restore Cargo.toml" --root
110129
env:
111130
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
112-
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=address"
113-
- run: git rebase --exec 'cargo test --target x86_64-unknown-linux-gnu' --root
131+
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=address -Dwarnings"
132+
# sed because of https://github.com/japaric/rust-san#unrealiable-leaksanitizer
133+
# doctests are strangely not included in --all-targets
134+
- run: git rebase --exec "sed -i '/\[features\]/i [profile.dev]' Cargo.toml && sed -i '/profile.dev/a opt-level = 1' Cargo.toml && cargo test --doc --target x86_64-unknown-linux-gnu && git restore Cargo.toml" --root
135+
env:
136+
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
137+
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=address -Dwarnings"
138+
- run: git rebase --exec 'cargo test --all-targets --target x86_64-unknown-linux-gnu' --root
139+
env:
140+
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=leak -Dwarnings"
141+
# doctests are strangely not included in --all-targets
142+
- run: git rebase --exec 'cargo test --doc --target x86_64-unknown-linux-gnu' --root
114143
env:
115-
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=leak"
144+
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=leak -Dwarnings"
116145
msrv:
117146
runs-on: ubuntu-latest
118147
steps:
@@ -123,7 +152,9 @@ jobs:
123152
- uses: dtolnay/rust-toolchain@stable
124153
- run: cargo install cargo-hack
125154
- run: git config user.name "github-runner" && git config user.email "<>"
126-
- run: git rebase --exec 'cargo hack --clean-per-run --feature-powerset --exclude-features alloc --exclude-features default --version-range 1.82.. --clean-per-version check --locked' --exec 'cargo clean' --root
155+
- run: git rebase --exec 'cargo hack --clean-per-run --feature-powerset --exclude-features alloc --exclude-features default --version-range 1.82.. --clean-per-version check --locked --all-targets' --exec 'cargo clean' --root
156+
env:
157+
RUSTFLAGS: "-Dwarnings"
127158
nightly-msrv:
128159
runs-on: ubuntu-latest
129160
steps:
@@ -137,9 +168,10 @@ jobs:
137168
- run: cargo install cargo-hack
138169
- run: cargo install cargo-expand
139170
- run: git config user.name "github-runner" && git config user.email "<>"
140-
- run: git rebase --exec 'cargo hack --clean-per-run --feature-powerset --version-range 1.78.. --clean-per-version check --locked' --exec 'cargo clean' --root
171+
- run: git rebase --exec 'cargo hack --clean-per-run --feature-powerset --version-range 1.78.. --clean-per-version check --locked --all-targets' --exec 'cargo clean' --root
141172
env:
142173
RUSTC_BOOTSTRAP: 1
174+
RUSTFLAGS: "-Dwarnings"
143175
os-check:
144176
strategy:
145177
fail-fast: false
@@ -157,7 +189,13 @@ jobs:
157189
components: rust-src
158190
- run: cargo install cargo-expand
159191
- run: git config user.name "github-runner" && git config user.email "<>"
160-
- run: git rebase --exec 'cargo test --locked' --root
192+
- run: git rebase --exec 'cargo test --all-targets --locked' --root
193+
env:
194+
RUSTFLAGS: "-Dwarnings"
195+
# doctests are strangely not included in --all-targets
196+
- run: git rebase --exec 'cargo test --doc --locked' --root
197+
env:
198+
RUSTFLAGS: "-Dwarnings"
161199
signed-off-by:
162200
runs-on: ubuntu-latest
163201
steps:
@@ -208,4 +246,6 @@ jobs:
208246
components: rust-src
209247
- run: sudo apt-get install -y linkchecker
210248
- run: git config user.name "github-runner" && git config user.email "<>"
211-
- run: git rebase --exec 'cargo doc --no-deps && linkchecker target/doc/*/*.html' --root
249+
- run: git rebase --exec 'cargo doc --all-features --no-deps && linkchecker target/doc/*/*.html' --root
250+
env:
251+
RUSTFLAGS: "-Dwarnings"

.github/workflows/kernel.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/sync.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
permissions:
2+
contents: read
3+
on:
4+
push:
5+
branches: [kernel, next]
6+
schedule:
7+
- cron: '7 7 * * *'
8+
name: sync-check
9+
jobs:
10+
torvalds:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
ref: kernel
16+
path: pin-init
17+
- run: git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
18+
- run: |
19+
cp -r linux/rust/pin-init .
20+
cd pin-init
21+
if ! git diff --quiet ; then
22+
git diff
23+
false
24+
fi
25+
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
26+
git status
27+
false
28+
fi
29+
pin-init-next:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
ref: next
35+
path: pin-init
36+
- uses: actions/checkout@v4
37+
with:
38+
repository: "Rust-for-Linux/linux"
39+
ref: pin-init-next
40+
path: kernel
41+
- run:
42+
cp -r linux/rust/pin-init .
43+
cd pin-init
44+
if ! git diff --quiet ; then
45+
git diff
46+
false
47+
fi
48+
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
49+
git status
50+
false
51+
fi

examples/big_struct_in_place.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use pin_init::*;
44

55
// Struct with size over 1GiB
66
#[derive(Debug)]
7+
#[allow(dead_code)]
78
pub struct BigStruct {
89
buf: [u8; 1024 * 1024 * 1024],
910
a: u64,
@@ -25,15 +26,18 @@ impl ManagedBuf {
2526
}
2627

2728
fn main() {
28-
// we want to initialize the struct in-place, otherwise we would get a stackoverflow
29-
let buf: Box<BigStruct> = Box::init(init!(BigStruct {
30-
buf <- zeroed(),
31-
a: 7,
32-
b: 186,
33-
c: 7789,
34-
d: 34,
35-
managed_buf <- ManagedBuf::new(),
36-
}))
37-
.unwrap();
38-
println!("{}", core::mem::size_of_val(&*buf));
29+
#[cfg(any(feature = "std", feature = "alloc"))]
30+
{
31+
// we want to initialize the struct in-place, otherwise we would get a stackoverflow
32+
let buf: Box<BigStruct> = Box::init(init!(BigStruct {
33+
buf <- zeroed(),
34+
a: 7,
35+
b: 186,
36+
c: 7789,
37+
d: 34,
38+
managed_buf <- ManagedBuf::new(),
39+
}))
40+
.unwrap();
41+
println!("{}", core::mem::size_of_val(&*buf));
42+
}
3943
}

examples/linked_list.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ use core::{
1414

1515
use pin_init::*;
1616

17-
#[expect(unused_attributes)]
17+
#[allow(unused_attributes)]
1818
mod error;
19+
#[allow(unused_imports)]
1920
use error::Error;
2021

2122
#[pin_data(PinnedDrop)]
@@ -39,6 +40,7 @@ impl ListHead {
3940
}
4041

4142
#[inline]
43+
#[allow(dead_code)]
4244
pub fn insert_next(list: &ListHead) -> impl PinInit<Self, Infallible> + '_ {
4345
try_pin_init!(&this in Self {
4446
prev: list.next.prev().replace(unsafe { Link::new_unchecked(this)}),
@@ -112,6 +114,7 @@ impl Link {
112114
}
113115

114116
#[inline]
117+
#[allow(dead_code)]
115118
fn prev(&self) -> &Link {
116119
unsafe { &(*self.0.get().as_ptr()).prev }
117120
}
@@ -137,8 +140,13 @@ impl Link {
137140
}
138141
}
139142

143+
#[allow(dead_code)]
144+
#[cfg(not(any(feature = "std", feature = "alloc")))]
145+
fn main() {}
146+
140147
#[allow(dead_code)]
141148
#[cfg_attr(test, test)]
149+
#[cfg(any(feature = "std", feature = "alloc"))]
142150
fn main() -> Result<(), Error> {
143151
let a = Box::pin_init(ListHead::new())?;
144152
stack_pin_init!(let b = ListHead::insert_next(&a));

0 commit comments

Comments
 (0)