forked from aya-rs/bpf-linker
-
Notifications
You must be signed in to change notification settings - Fork 0
208 lines (174 loc) · 6.09 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
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-latest
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-latest
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-container-image:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-unknown-linux-gnu
- target: aarch64-unknown-linux-musl
- target: riscv64-unknown-linux-gnu
- target: x86_64-unknown-linux-gnu
- target: x86_64-unknown-linux-musl
name: container target=${{ matrix.target }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Log in to GitHub Container Registry
run: |
set -euxo pipefail
echo "${{ secrets.GITHUB_TOKEN }}" | \
docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build container image
run: |
set -euxo pipefail
cargo xtask build-container-image \
--container-repository ghcr.io/${{ github.repository }} \
--target ${{ matrix.target }} \
--push
build:
runs-on: ${{ matrix.target.os }}
strategy:
fail-fast: false
matrix:
rust:
- stable
- beta
- nightly
# We don't use ubuntu-latest because we care about the apt packages available.
target:
- os: macos-14
target: aarch64-apple-darwin
- os: macos-13
target: x86_64-apple-darwin
- os: ubuntu-22.04
packages: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user
target: aarch64-unknown-linux-gnu
- os: ubuntu-22.04
packages: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross musl-dev qemu-user
target: aarch64-unknown-linux-musl
- os: ubuntu-22.04
packages: gcc-riscv64-linux-gnu g++-riscv64-linux-gnu libc6-dev-riscv64-cross qemu-user
target: riscv64gc-unknown-linux-gnu
- os: ubuntu-22.04
packages:
target: x86_64-unknown-linux-gnu
- os: ubuntu-22.04
packages:
target: x86_64-unknown-linux-musl
name: rustc=${{ matrix.rust }} target=${{ matrix.target.target }}
needs: llvm
env:
CARGO_BUILD_TARGET: ${{ matrix.target.target }}
RUST_BACKTRACE: full
steps:
- uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rust-src
targets: ${{ matrix.target.target }}
- uses: Swatinem/rust-cache@v2
- name: Install btfdump
if: matrix.rust == 'nightly'
run: cargo install btfdump
- name: Install dependencies
if: runner.os == 'Linux'
# ubuntu-22.04 comes with clang 13-15[0]; support for signed and 64bit
# enum values was added in clang 15[1] which isn't in `$PATH`.
#
# gcc-multilib provides at least <asm/types.h> which is referenced by libbpf.
#
# [0] https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
#
# [1] https://github.com/llvm/llvm-project/commit/dc1c43d
run: |
set -euxo pipefail
sudo apt update
sudo apt -y install ${{ matrix.target.packages }}
echo /usr/lib/llvm-15/bin >> $GITHUB_PATH
- name: Install dependencies
if: runner.os == 'macOS'
# We need system-wide LLVM only for FileCheck.
run: |
set -euxo pipefail
brew install llvm
echo $(brew --prefix)/opt/llvm/bin >> $GITHUB_PATH
- 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
# 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
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 --features llvm-sys/no-llvm-linking --feature-powerset
- name: Build
run: cargo xtask build --target ${{ matrix.target.target }}
- name: Test
if: matrix.rust == 'nightly'
run: cargo xtask test --target ${{ matrix.target.target }}
- uses: actions/checkout@v4
if: matrix.rust == 'nightly'
with:
repository: aya-rs/aya
path: aya
submodules: recursive
- name: Install
if: matrix.rust == 'nightly'
run: cargo install --path . --no-default-features
- name: Run aya integration tests
if: matrix.rust == 'nightly' && runner.os == 'Linux' && startsWith(matrix.target.target, 'x86_64')
working-directory: aya
run: cargo xtask integration-test local
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3