Library.yml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. name: Library
  2. on:
  3. push:
  4. branches: ["main"]
  5. pull_request:
  6. branches: ["main"]
  7. workflow_dispatch:
  8. env:
  9. CARGO_UNSTABLE_SPARSE_REGISTRY: true
  10. CARGO_TERM_COLOR: always
  11. jobs:
  12. fmt:
  13. name: Rustfmt all packages
  14. runs-on: ubuntu-latest
  15. steps:
  16. - uses: actions/checkout@v4
  17. - uses: actions-rust-lang/setup-rust-toolchain@v1
  18. with:
  19. components: rustfmt
  20. toolchain: nightly # support 2024 edition rustfmt checks
  21. - name: Cache Dependencies
  22. uses: Swatinem/rust-cache@v2
  23. - name: Rustfmt Check
  24. uses: actions-rust-lang/rustfmt@v1
  25. build-rustsbi:
  26. name: Build rustsbi
  27. runs-on: ubuntu-latest
  28. needs: fmt
  29. strategy:
  30. matrix:
  31. TOOLCHAIN: [nightly]
  32. TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
  33. steps:
  34. - uses: actions/checkout@v4
  35. - uses: actions-rust-lang/setup-rust-toolchain@v1
  36. with:
  37. target: ${{ matrix.TARGET }}
  38. toolchain: ${{ matrix.TOOLCHAIN }}
  39. - uses: Swatinem/rust-cache@v2
  40. with:
  41. key: ${{ matrix.TARGET }}
  42. - name: Build (no default features)
  43. run: |
  44. cargo build -p rustsbi --target ${{ matrix.TARGET }} --verbose
  45. - name: Build (machine)
  46. run: |
  47. cargo build -p rustsbi --target ${{ matrix.TARGET }} --verbose --features "machine"
  48. - name: Build (forward)
  49. run: |
  50. cargo build -p rustsbi --target ${{ matrix.TARGET }} --verbose --features "forward"
  51. - name: Build (machine + forward)
  52. run: |
  53. cargo build -p rustsbi --target ${{ matrix.TARGET }} --verbose --features "machine, forward"
  54. test-rustsbi:
  55. name: Test rustsbi
  56. needs: fmt
  57. runs-on: ubuntu-latest
  58. steps:
  59. - uses: actions/checkout@v4
  60. - uses: actions-rust-lang/setup-rust-toolchain@v1
  61. with:
  62. toolchain: nightly
  63. - uses: Swatinem/rust-cache@v2
  64. - name: Run tests (no default features)
  65. run: |
  66. cargo test -p rustsbi --verbose
  67. - name: Run tests (machine)
  68. run: |
  69. cargo test -p rustsbi --verbose --features "machine"
  70. # Don't run tests with rustsbi `forward` features on here: it requires RISC-V targets to build.
  71. test-sbi-spec:
  72. name: Test sbi-spec
  73. needs: fmt
  74. runs-on: ubuntu-latest
  75. steps:
  76. - uses: actions/checkout@v4
  77. - uses: actions-rust-lang/setup-rust-toolchain@v1
  78. with:
  79. toolchain: nightly
  80. - uses: Swatinem/rust-cache@v2
  81. # - name: Check clippy
  82. # run: cargo clippy -- -D warnings
  83. - name: Run tests
  84. run: cargo test -p sbi-spec --verbose
  85. test-penglai:
  86. name: Test `penglai` crate
  87. needs: fmt
  88. runs-on: ubuntu-latest
  89. steps:
  90. - uses: actions/checkout@v4
  91. - uses: actions-rust-lang/setup-rust-toolchain@v1
  92. with:
  93. toolchain: nightly
  94. - uses: Swatinem/rust-cache@v2
  95. # - name: Check clippy
  96. # run: cargo clippy -- -D warnings
  97. - name: Run tests
  98. run: cargo test -p penglai --verbose
  99. build-sbi-rt:
  100. name: Build sbi-rt
  101. needs: fmt
  102. runs-on: ubuntu-latest
  103. strategy:
  104. matrix:
  105. TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
  106. steps:
  107. - uses: actions/checkout@v4
  108. - uses: actions-rust-lang/setup-rust-toolchain@v1
  109. with:
  110. target: ${{ matrix.TARGET }}
  111. toolchain: nightly
  112. - uses: Swatinem/rust-cache@v2
  113. - name: Build
  114. run: |
  115. cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-rt
  116. test-sbi-rt:
  117. name: Test sbi-rt
  118. needs: fmt
  119. runs-on: ubuntu-latest
  120. steps:
  121. - uses: actions/checkout@v4
  122. - uses: actions-rust-lang/setup-rust-toolchain@v1
  123. with:
  124. toolchain: nightly
  125. - uses: Swatinem/rust-cache@v2
  126. - name: Run tests
  127. run: cargo test -p sbi-rt --verbose
  128. build-sbi-testing:
  129. name: Build sbi-testing
  130. needs: fmt
  131. runs-on: ubuntu-latest
  132. strategy:
  133. matrix:
  134. TARGET: [riscv64imac-unknown-none-elf] #, riscv32imac-unknown-none-elf]
  135. steps:
  136. - uses: actions/checkout@v4
  137. - uses: actions-rust-lang/setup-rust-toolchain@v1
  138. with:
  139. target: ${{ matrix.TARGET }}
  140. toolchain: nightly
  141. - uses: Swatinem/rust-cache@v2
  142. - name: Build (no default features)
  143. run: |
  144. cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-testing
  145. - name: Build (log)
  146. run: |
  147. cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-testing --features "log"
  148. msrv-test:
  149. name: MSRV Test (Rust 1.88.0)
  150. runs-on: ubuntu-latest
  151. strategy:
  152. matrix:
  153. rustsbi_TARGET:
  154. - riscv64imac-unknown-none-elf
  155. - riscv32imac-unknown-none-elf
  156. sbi_rt_TARGET:
  157. - riscv64imac-unknown-none-elf
  158. sbi_testing_TARGET:
  159. - riscv64imac-unknown-none-elf
  160. sbi_spec_TARGET:
  161. - riscv64imac-unknown-none-elf
  162. - riscv32imac-unknown-none-elf
  163. penglai_TARGET:
  164. - riscv64imac-unknown-none-elf
  165. - riscv32imac-unknown-none-elf
  166. TOOLCHAIN:
  167. - nightly-2025-04-22
  168. steps:
  169. - name: Checkout repository
  170. uses: actions/checkout@v4
  171. - name: Install MSRV toolchain
  172. uses: actions-rust-lang/setup-rust-toolchain@v1
  173. with:
  174. toolchain: ${{ matrix.TOOLCHAIN }}
  175. override: true
  176. - name: Install target
  177. run: |
  178. rustup target add ${{ matrix.rustsbi_TARGET }}
  179. rustup target add ${{ matrix.sbi_rt_TARGET }}
  180. rustup target add ${{ matrix.sbi_testing_TARGET }}
  181. rustup target add ${{ matrix.sbi_spec_TARGET }}
  182. rustup target add ${{ matrix.penglai_TARGET }}
  183. - uses: Swatinem/rust-cache@v2
  184. with:
  185. key: ${{ matrix.TOOLCHAIN }}
  186. - name: Check rustsbi
  187. run: cargo check --target ${{ matrix.rustsbi_TARGET }} -p rustsbi
  188. - name: Check sbi-rt
  189. run: cargo check --target ${{ matrix.sbi_rt_TARGET }} -p sbi-rt
  190. - name: Check sbi-testing
  191. run: cargo check --target ${{ matrix.sbi_testing_TARGET }} -p sbi-testing
  192. - name: Check sbi-spec (compilation check)
  193. run: cargo check --target ${{ matrix.sbi_spec_TARGET }} -p sbi-spec
  194. - name: Check penglai (compilation check)
  195. run: cargo check --target ${{ matrix.penglai_TARGET }} -p penglai
  196. # sbi-testing:
  197. # name: Run rust-clippy analyzing
  198. # runs-on: ubuntu-latest
  199. # permissions:
  200. # security-events: write
  201. # steps:
  202. # - name: Checkout code
  203. # uses: actions/checkout@v4
  204. # - name: Check format
  205. # run: cargo fmt --check
  206. # - name: Install clippy-sarif
  207. # uses: actions-rs/install@v0.1
  208. # with:
  209. # crate: clippy-sarif
  210. # version: latest
  211. # - name: Install sarif-fmt
  212. # uses: actions-rs/install@v0.1
  213. # with:
  214. # crate: sarif-fmt
  215. # version: latest
  216. # - name: Run rust-clippy
  217. # run:
  218. # cargo clippy
  219. # --all-featuers
  220. # --package fast-trap
  221. # --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
  222. # continue-on-error: true
  223. # - name: Upload analysis results to GitHub
  224. # uses: github/codeql-action/upload-sarif@v2
  225. # with:
  226. # sarif_file: rust-clippy-results.sarif
  227. # wait-for-processing: true