-
Notifications
You must be signed in to change notification settings - Fork 42
232 lines (194 loc) · 7.51 KB
/
ci.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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: CI
on:
push:
branches:
- main
- 'feature/**'
pull_request:
branches:
- main
- 'feature/**'
schedule:
- cron: 00 4 * * *
env:
CARGO_TERM_COLOR: always
jobs:
llvm:
uses: ./.github/workflows/llvm.yml
lint-stable:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy, rust-src
- name: Run clippy
run: cargo clippy --features llvm-sys/no-llvm-linking --all-targets --workspace -- --deny warnings
lint-nightly:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt, rust-src
- name: Check formatting
run: cargo fmt --all -- --check
build-linux:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
rust:
- stable
- beta
- nightly
target:
- target: aarch64-unknown-linux-musl
container: alpine:3.20
llvm-proxy: false
- target: x86_64-unknown-linux-gnu
container: ubuntu:22.04
llvm-proxy: true
- target: x86_64-unknown-linux-musl
container: alpine:3.20
llvm-proxy: false
container:
image: ${{ matrix.target.container }}
name: rustc=${{ matrix.rust }} target=${{ matrix.target.target }}
needs: llvm
env:
RUST_BACKTRACE: full
steps:
- uses: actions/checkout@v4
- name: Install dependencies
if: endsWith(matrix.target.target, 'gnu')
shell: bash
run: |
set -euxo pipefail
apt update
apt -y install clang curl linux-tools
- name: Install dependencies
if: endsWith(matrix.target.target, 'musl')
run: |
set -euxo pipefail
apk update
apk add bash bpftool clang curl dpkg git libgcc libstdc++-dev make musl-dev tar
- name: Install Rust ${{ matrix.rust }}
if: matrix.rust != 'nightly'
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Install Rust ${{ matrix.rust }}
if: matrix.rust == 'nightly'
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rust-src
# TODO: Remove this and run the integration tests on the local machine when they pass on 5.15.
targets: ${{ matrix.target.target }}
- uses: Swatinem/rust-cache@v2
- name: Check (default features, no system LLVM)
run: cargo check
- name: Build (default features, no system LLVM)
run: cargo build
- name: Restore LLVM
uses: actions/cache/restore@v4
with:
path: llvm-install
key: ${{ needs.llvm.outputs[format('cache-key-{0}', matrix.target.target)] }}
fail-on-cache-miss: true
- name: Add LLVM to PATH && LD_LIBRARY_PATH
shell: bash
run: |
set -euxo pipefail
# `${{ github.workspace }}` doesn't tell the truth when running inside
# containers. See https://github.com/actions/runner/issues/2058
# None of the workarounds works here, so let's just hard-code the full
# path of the decompressed cache...
echo "/__w/bpf-linker/bpf-linker/llvm-install/bin" >> $GITHUB_PATH
# LD_LIBRARY_PATH is needed because we're going to link everything dynamically below. This
# doesn't affect behavior, but greatly reduces disk usage.
echo "LD_LIBRARY_PATH=/__w/bpf-linker/bpf-linker/llvm-install/lib" >> $GITHUB_ENV
# llvm-sys discovers link flags at build script time; these are cached by cargo. The cached
# flags may be incorrect when the cache is reused across LLVM versions.
- name: Bust llvm-sys cache
shell: bash
run: |
set -euxo pipefail
cargo clean -p llvm-sys
cargo clean -p llvm-sys --release
- uses: taiki-e/install-action@cargo-hack
- name: Check
run: cargo hack check --feature-powerset
- name: Build
run: cargo hack build --feature-powerset
- name: Test
if: matrix.rust == 'nightly' && matrix.target.llvm-proxy == true
run: cargo hack test --feature-powerset
# llvm-proxy doesn't work on musl environments.
- name: Test
if: matrix.rust == 'nightly' && matrix.target.llvm-proxy != true
run: cargo hack test --feature-powerset --exclude-features default,rust-llvm
- uses: actions/checkout@v4
if: matrix.rust == 'nightly'
with:
# TODO: Switch to the main Aya repo once fixes land there.
repository: vadorovsky/aya
ref: integration-tests-linker
path: aya
submodules: recursive
- name: Install
if: matrix.rust == 'nightly' && matrix.target.llvm-proxy == true
run: cargo install --path .
- name: Install
if: matrix.rust == 'nightly' && matrix.target.llvm-proxy != true
run: cargo install --path . --no-default-features
# TODO: Remove this and run the integration tests on the local machine when they pass on 5.15.
- name: Download debian kernels
if: matrix.rust == 'nightly' && runner.arch == 'ARM64' && matrix.target.llvm-proxy != true
working-directory: aya
run: |
set -euxo pipefail
mkdir -p test/.tmp/debian-kernels/arm64
printf '%s\0' \
linux-image-6.1.0-16-cloud-arm64-unsigned_6.1.67-1_arm64.deb \
| xargs -0 -t -P0 -I {} wget -nd -nv -P test/.tmp/debian-kernels/arm64 https://ftp.debian.org/debian/pool/main/l/linux/{}
# TODO: Remove this and run the integration tests on the local machine when they pass on 5.15.
- name: Download debian kernels
if: matrix.rust == 'nightly' && runner.arch == 'X64' && matrix.target.llvm-proxy != true
working-directory: aya
run: |
set -euxo pipefail
mkdir -p test/.tmp/debian-kernels/amd64
printf '%s\0' \
linux-image-6.1.0-16-cloud-amd64-unsigned_6.1.67-1_amd64.deb \
| xargs -0 -t -P0 -I {} wget -nd -nv -P test/.tmp/debian-kernels/amd64 https://ftp.debian.org/debian/pool/main/l/linux/{}
# TODO: Remove this and run the integration tests on the local machine when they pass on 5.15.
- name: Extract debian kernels
if: matrix.rust == 'nightly' && matrix.target.llvm-proxy != true
working-directory: aya
run: |
set -euxo pipefail
find test/.tmp -name '*.deb' -print0 | xargs -t -0 -I {} \
sh -c "dpkg --fsys-tarfile {} | tar -C test/.tmp --wildcards --extract '*vmlinuz*' --file -"
- name: Run aya integration tests
if: matrix.rust == 'nightly' && matrix.llvm.proxy == true
run: cargo xtask integration-test local
- name: Run aya integration tests
if: matrix.rust == 'nightly' && matrix.llvm.proxy != true
working-directory: aya
run: |
set -euxo pipefail
apk add file findutils-locate qemu-system-arm qemu-system-x86_64
find test/.tmp -name 'vmlinuz-*' | RUSTFLAGS=-Cdebuginfo=line-directives-only xargs -t cargo xtask integration-test vm
# build-macos:
# runs-on: macos-13
# strategy:
# fail-fast: false
# matrix:
# rust:
# - stable
# - beta
# - nightly