4
0

ci.yml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. name: aya-ci
  2. on:
  3. push:
  4. branches:
  5. - main
  6. pull_request:
  7. branches:
  8. - main
  9. env:
  10. CARGO_TERM_COLOR: always
  11. jobs:
  12. lint:
  13. runs-on: ubuntu-22.04
  14. steps:
  15. - uses: actions/checkout@v3
  16. - uses: dtolnay/rust-toolchain@master
  17. with:
  18. toolchain: nightly
  19. components: rustfmt, clippy, miri, rust-src
  20. - uses: Swatinem/rust-cache@v2
  21. - uses: taiki-e/install-action@v2
  22. with:
  23. tool: cargo-hack,taplo-cli
  24. - run: taplo fmt --check
  25. - name: Check formatting
  26. run: cargo fmt --all -- --check
  27. - name: Run clippy
  28. run: cargo hack clippy --all-targets --feature-powerset --workspace -- --deny warnings
  29. - name: Check public API
  30. run: cargo xtask public-api
  31. - name: Run miri
  32. run: |
  33. set -euxo pipefail
  34. cargo hack miri test --all-targets --feature-powerset \
  35. --exclude aya-bpf \
  36. --exclude aya-bpf-bindings \
  37. --exclude aya-log-ebpf \
  38. --exclude integration-ebpf \
  39. --exclude integration-test \
  40. --workspace
  41. build-test-aya:
  42. strategy:
  43. fail-fast: false
  44. matrix:
  45. arch:
  46. - x86_64-unknown-linux-gnu
  47. - aarch64-unknown-linux-gnu
  48. - armv7-unknown-linux-gnueabi
  49. - riscv64gc-unknown-linux-gnu
  50. runs-on: ubuntu-22.04
  51. steps:
  52. - uses: actions/checkout@v3
  53. - uses: dtolnay/rust-toolchain@master
  54. with:
  55. toolchain: stable
  56. targets: ${{ matrix.arch }}
  57. - uses: Swatinem/rust-cache@v2
  58. - uses: taiki-e/install-action@cargo-hack
  59. - uses: taiki-e/setup-cross-toolchain-action@v1
  60. with:
  61. target: ${{ matrix.arch }}
  62. - name: Build
  63. run: |
  64. set -euxo pipefail
  65. cargo hack build --all-targets --feature-powerset \
  66. --exclude aya-bpf \
  67. --exclude aya-bpf-bindings \
  68. --exclude aya-log-ebpf \
  69. --exclude integration-ebpf \
  70. --workspace
  71. - name: Test
  72. env:
  73. RUST_BACKTRACE: full
  74. run: |
  75. set -euxo pipefail
  76. cargo hack test --all-targets --feature-powerset \
  77. --exclude aya-bpf \
  78. --exclude aya-bpf-bindings \
  79. --exclude aya-log-ebpf \
  80. --exclude integration-ebpf \
  81. --exclude integration-test \
  82. --workspace
  83. build-test-aya-bpf:
  84. strategy:
  85. fail-fast: false
  86. matrix:
  87. arch:
  88. - x86_64
  89. - aarch64
  90. - arm
  91. - riscv64
  92. target:
  93. - bpfel-unknown-none
  94. - bpfeb-unknown-none
  95. runs-on: ubuntu-22.04
  96. steps:
  97. - uses: actions/checkout@v3
  98. - uses: dtolnay/rust-toolchain@master
  99. with:
  100. toolchain: nightly
  101. components: rust-src
  102. - uses: Swatinem/rust-cache@v2
  103. - name: bpf-linker
  104. run: cargo install bpf-linker --git https://github.com/aya-rs/bpf-linker.git
  105. - uses: taiki-e/install-action@cargo-hack
  106. - name: Build
  107. env:
  108. CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.arch }}
  109. run: |
  110. set -euxo pipefail
  111. cargo hack build --package aya-bpf --package aya-log-ebpf \
  112. --feature-powerset \
  113. --target ${{ matrix.target }} \
  114. -Z build-std=core
  115. run-integration-test:
  116. strategy:
  117. fail-fast: false
  118. matrix:
  119. runner:
  120. - macos-12
  121. - ubuntu-22.04
  122. runs-on: ${{ matrix.runner }}
  123. steps:
  124. - uses: actions/checkout@v3
  125. with:
  126. submodules: recursive
  127. - uses: dtolnay/rust-toolchain@master
  128. with:
  129. toolchain: nightly
  130. components: rust-src
  131. targets: aarch64-unknown-linux-musl,x86_64-unknown-linux-musl
  132. - uses: Swatinem/rust-cache@v2
  133. - name: Install prerequisites
  134. if: runner.os == 'Linux'
  135. # ubuntu-22.04 comes with clang 14[0] which doesn't include support for signed and 64bit
  136. # enum values which was added in clang 15[1].
  137. #
  138. # gcc-multilib provides at least <asm/types.h> which is referenced by libbpf.
  139. #
  140. # llvm provides llvm-objcopy which is used to build the BTF relocation tests.
  141. #
  142. # [0] https://github.com/actions/runner-images/blob/ubuntu22/20230724.1/images/linux/Ubuntu2204-Readme.md
  143. #
  144. # [1] https://github.com/llvm/llvm-project/commit/dc1c43d
  145. run: |
  146. set -euxo pipefail
  147. wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
  148. echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main | sudo tee /etc/apt/sources.list.d/llvm.list
  149. sudo apt update
  150. sudo apt -y install clang gcc-multilib llvm locate qemu-system-{arm,x86}
  151. - name: bpf-linker
  152. if: runner.os == 'Linux'
  153. run: cargo install bpf-linker --git https://github.com/aya-rs/bpf-linker.git
  154. - name: Install prerequisites
  155. if: runner.os == 'macOS'
  156. # The clang shipped on macOS doesn't support BPF, so we need LLVM from brew.
  157. #
  158. # We also need LLVM for bpf-linker, see comment below.
  159. run: |
  160. set -euxo pipefail
  161. brew install qemu dpkg pkg-config llvm
  162. echo /usr/local/opt/llvm/bin >> $GITHUB_PATH
  163. - name: bpf-linker
  164. if: runner.os == 'macOS'
  165. # NB: rustc doesn't ship libLLVM.so on macOS, so disable proxying (default feature).
  166. run: cargo install bpf-linker --git https://github.com/aya-rs/bpf-linker.git --no-default-features
  167. - name: Download debian kernels
  168. if: runner.arch == 'ARM64'
  169. run: |
  170. set -euxo pipefail
  171. mkdir -p test/.tmp/debian-kernels/arm64
  172. # NB: a 4.19 kernel image for arm64 was not available.
  173. # TODO: enable tests on kernels before 6.0.
  174. # linux-image-5.10.0-23-cloud-arm64-unsigned_5.10.179-3_arm64.deb \
  175. printf '%s\0' \
  176. linux-image-6.1.0-10-cloud-arm64-unsigned_6.1.38-2_arm64.deb \
  177. linux-image-6.4.0-1-cloud-arm64-unsigned_6.4.4-2_arm64.deb \
  178. | xargs -0 -t -P0 -I {} wget -nd -q -P test/.tmp/debian-kernels/arm64 ftp://ftp.us.debian.org/debian/pool/main/l/linux/{}
  179. - name: Download debian kernels
  180. if: runner.arch == 'X64'
  181. run: |
  182. set -euxo pipefail
  183. mkdir -p test/.tmp/debian-kernels/amd64
  184. # TODO: enable tests on kernels before 6.0.
  185. # linux-image-4.19.0-21-cloud-amd64-unsigned_4.19.249-2_amd64.deb \
  186. # linux-image-5.10.0-23-cloud-amd64-unsigned_5.10.179-3_amd64.deb \
  187. printf '%s\0' \
  188. linux-image-6.1.0-10-cloud-amd64-unsigned_6.1.38-2_amd64.deb \
  189. linux-image-6.4.0-1-cloud-amd64-unsigned_6.4.4-2_amd64.deb \
  190. | xargs -0 -t -P0 -I {} wget -nd -q -P test/.tmp/debian-kernels/amd64 ftp://ftp.us.debian.org/debian/pool/main/l/linux/{}
  191. - name: Alias gtar as tar
  192. if: runner.os == 'macOS'
  193. # macOS tar doesn't support --wildcards which we use below.
  194. run: mkdir tar-is-gtar && ln -s "$(which gtar)" tar-is-gtar/tar && echo "$PWD"/tar-is-gtar >> $GITHUB_PATH
  195. - name: Extract debian kernels
  196. run: |
  197. set -euxo pipefail
  198. find test/.tmp -name '*.deb' -print0 | xargs -t -0 -I {} \
  199. sh -c "dpkg --fsys-tarfile {} | tar -C test/.tmp --wildcards --extract '*vmlinuz*' --file -"
  200. - name: Run integration tests
  201. run: find test/.tmp -name 'vmlinuz-*' | xargs -t cargo xtask integration-test vm
  202. # Provides a single status check for the entire build workflow.
  203. # This is used for merge automation, like Mergify, since GH actions
  204. # has no concept of "when all status checks pass".
  205. # https://docs.mergify.com/conditions/#validating-all-status-checks
  206. build-workflow-complete:
  207. needs:
  208. - lint
  209. - build-test-aya
  210. - build-test-aya-bpf
  211. - run-integration-test
  212. runs-on: ubuntu-latest
  213. steps:
  214. - name: Build Complete
  215. run: echo "Build Complete"