-
Notifications
You must be signed in to change notification settings - Fork 138
212 lines (206 loc) · 7.04 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Test
on:
push:
pull_request:
branches: [ master ]
workflow_call:
jobs:
build:
name: Test [${{ matrix.rust }}, ${{ matrix.profile }}]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [stable, nightly]
profile: [dev]
include:
- rust: stable
profile: release
# Anything nightly is treated as informational-only.
continue-on-error: ${{ matrix.rust == 'nightly' }}
steps:
- name: "Set environmental variables"
shell: bash
run: |
RUST_BACKTRACE_nightly='1'
CFLAGS_nightly='-fsanitize=leak'
CXXFLAGS_nightly='-fsanitize=leak'
RUSTFLAGS_nightly='-Zsanitizer=leak'
# A function for defining a variable conditional on the toolchain in
# use.
tc_var() {
# Replace any dots in the toolchain name with underscores. Necessary
# due to shell imposed variable naming restrictions.
var="${1}_$(echo ${{ matrix.rust }} | tr . _)"
echo "${1}=${!var}" >> ${GITHUB_ENV}
}
tc_var RUST_BACKTRACE
tc_var RUSTFLAGS
tc_var CFLAGS
tc_var CXXFLAGS
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/[email protected]
with:
profile: minimal
toolchain: ${{ matrix.rust }}
components: rustfmt
override: true
- name: Install deps
run: |
sudo apt-get install -y clang-14 libelf-dev zlib1g-dev linux-headers-$(uname -r)
sudo ln -s /usr/include/asm-generic /usr/include/asm
sudo rm -f /bin/clang && sudo ln -s /usr/bin/clang-14 /bin/clang
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --profile=${{ matrix.profile }} --locked --verbose --workspace --exclude runqslower
- name: Run tests
# Skip tests which require sudo
run: cargo test --profile=${{ matrix.profile }} --locked --verbose --workspace --exclude runqslower -- --skip test_sudo_ --include-ignored
- name: Run root tests
run: cd libbpf-rs && cargo test --profile=${{ matrix.profile }} --locked --verbose -- test_sudo_
build-minimum:
name: Build using minimum versions of dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install deps
run: sudo apt-get install -y libelf-dev
- name: Install Nightly Rust
uses: actions-rs/[email protected]
with:
profile: minimal
toolchain: nightly
- run: cargo +nightly -Z minimal-versions update
- name: Install minimum Rust
uses: actions-rs/[email protected]
with:
profile: minimal
# Please adjust README and rust-version field in Cargo.toml files when
# bumping version.
toolchain: 1.64.0
components: rustfmt
default: true
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --verbose --workspace --exclude runqslower
build-capable:
name: Build capable example with static libelf and libz
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install deps
run: sudo apt-get install -y libelf-dev
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v2
- run: RUSTFLAGS="$RUSTFLAGS -L /usr/lib/x86_64-linux-gnu" cargo build --locked --package capable --features=static
build-aarch64:
name: Build for aarch64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Add apt sources for arm64
run: |
dpkg --add-architecture arm64
release=$(. /etc/os-release && echo "$UBUNTU_CODENAME")
sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list
printf 'deb [arch=arm64] http://ports.ubuntu.com/ %s main restricted\n' \
$release $release-updates $release-security \
>> /etc/apt/sources.list
shell: sudo sh -e {0}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: aarch64-unknown-linux-gnu
override: true
- name: Install deps
run: |
sudo apt-get update
sudo apt-get install -y libelf-dev:arm64 zlib1g-dev:arm64 gcc-aarch64-linux-gnu
- uses: Swatinem/rust-cache@v2
- name: Build
env:
CARGO_BUILD_TARGET: aarch64-unknown-linux-gnu
RUSTFLAGS: -C linker=/usr/bin/aarch64-linux-gnu-gcc
run: cargo build --lib
build-armhf:
name: Build for aarch32
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Add apt sources for armhf
run: |
dpkg --add-architecture armhf
release=$(. /etc/os-release && echo "$UBUNTU_CODENAME")
sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list
printf 'deb [arch=armhf] http://ports.ubuntu.com/ %s main restricted\n' \
$release $release-updates $release-security \
>> /etc/apt/sources.list
shell: sudo sh -e {0}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: armv7-unknown-linux-gnueabihf
override: true
- name: Install deps
run: |
sudo apt-get update
sudo apt-get install -y libelf-dev:armhf zlib1g-dev:armhf gcc-arm-linux-gnueabihf
- uses: Swatinem/rust-cache@v2
- name: Build
env:
CARGO_BUILD_TARGET: armv7-unknown-linux-gnueabihf
RUSTFLAGS: -C linker=/usr/bin/armhf-linux-gnu-gcc
run: cargo build --lib
clippy:
name: Lint with clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install deps
run: sudo apt-get install -y libelf-dev
- uses: actions-rs/toolchain@v1
with:
profile: minimal
# TODO: Move back to `stable` once we are past 1.69
# See:
# https://github.com/clap-rs/clap/issues/4849
# https://github.com/rust-lang/rust-clippy/issues/10421
toolchain: 1.68.2
components: clippy,rustfmt
override: true
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --locked --no-deps --all-targets --tests -- -D warnings
rustfmt:
name: Check code formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt
override: true
- run: cargo fmt --package libbpf-cargo libbpf-rs -- --check
cargo-doc:
name: Check documentation
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: '-D warnings'
steps:
- uses: actions/checkout@v4
- name: Install deps
run: sudo apt-get install -y libelf-dev
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: cargo doc --locked --no-deps