ci.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. build-integration-test:
  116. runs-on: ubuntu-22.04
  117. steps:
  118. - uses: actions/checkout@v3
  119. with:
  120. submodules: recursive
  121. - uses: dtolnay/rust-toolchain@master
  122. with:
  123. toolchain: nightly
  124. components: rust-src
  125. - uses: Swatinem/rust-cache@v2
  126. - name: bpf-linker
  127. run: cargo install bpf-linker --git https://github.com/aya-rs/bpf-linker.git
  128. - name: Install dependencies
  129. # ubuntu-22.04 comes with clang 14[0] which doesn't include support for signed and 64bit
  130. # enum values which was added in clang 15[1].
  131. #
  132. # gcc-multilib provides at least <asm/types.h> which is referenced by libbpf.
  133. #
  134. # llvm provides llvm-objcopy which is used to build the BTF relocation tests.
  135. #
  136. # [0] https://github.com/actions/runner-images/blob/ubuntu22/20230724.1/images/linux/Ubuntu2204-Readme.md
  137. #
  138. # [1] https://github.com/llvm/llvm-project/commit/dc1c43d
  139. run: |
  140. set -euxo pipefail
  141. wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
  142. echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main | sudo tee /etc/apt/sources.list.d/llvm.list
  143. sudo apt-get update
  144. sudo apt-get -y install clang gcc-multilib llvm
  145. - name: Build
  146. run: |
  147. set -euxo pipefail
  148. mkdir -p integration-test-binaries
  149. # See https://doc.rust-lang.org/cargo/reference/profiles.html for the
  150. # names of the builtin profiles. Note that dev builds "debug" targets.
  151. cargo xtask build-integration-test --cargo-arg=--profile=dev | xargs -I % cp % integration-test-binaries/dev
  152. cargo xtask build-integration-test --cargo-arg=--profile=release | xargs -I % cp % integration-test-binaries/release
  153. - uses: actions/upload-artifact@v3
  154. with:
  155. name: integration-test-binaries
  156. path: integration-test-binaries
  157. run-integration-test:
  158. runs-on: macos-latest
  159. needs: ["build-integration-test"]
  160. steps:
  161. - uses: actions/checkout@v3
  162. with:
  163. sparse-checkout: |
  164. test/run.sh
  165. test/cloud-localds
  166. - name: Install Pre-requisites
  167. run: |
  168. brew install qemu gnu-getopt coreutils cdrtools
  169. - name: Cache tmp files
  170. uses: actions/cache@v3
  171. with:
  172. path: |
  173. .tmp/*.qcow2
  174. .tmp/test_rsa
  175. .tmp/test_rsa.pub
  176. key: tmp-files-${{ hashFiles('test/run.sh') }}
  177. - uses: actions/download-artifact@v3
  178. with:
  179. name: integration-test-binaries
  180. path: integration-test-binaries
  181. - name: Run integration tests
  182. run: |
  183. set -euxo pipefail
  184. find integration-test-binaries -type f -exec chmod +x {} \;
  185. test/run.sh integration-test-binaries
  186. # Provides a single status check for the entire build workflow.
  187. # This is used for merge automation, like Mergify, since GH actions
  188. # has no concept of "when all status checks pass".
  189. # https://docs.mergify.com/conditions/#validating-all-status-checks
  190. build-workflow-complete:
  191. needs: ["lint", "build-test-aya", "build-test-aya-bpf", "run-integration-test"]
  192. runs-on: ubuntu-latest
  193. steps:
  194. - name: Build Complete
  195. run: echo "Build Complete"