Library.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. build-sbi-rt:
  86. name: Build sbi-rt
  87. needs: fmt
  88. runs-on: ubuntu-latest
  89. strategy:
  90. matrix:
  91. TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
  92. steps:
  93. - uses: actions/checkout@v4
  94. - uses: actions-rust-lang/setup-rust-toolchain@v1
  95. with:
  96. target: ${{ matrix.TARGET }}
  97. toolchain: nightly
  98. - uses: Swatinem/rust-cache@v2
  99. - name: Build
  100. run: |
  101. cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-rt
  102. test-sbi-rt:
  103. name: Test sbi-rt
  104. needs: fmt
  105. runs-on: ubuntu-latest
  106. steps:
  107. - uses: actions/checkout@v4
  108. - uses: actions-rust-lang/setup-rust-toolchain@v1
  109. with:
  110. toolchain: nightly
  111. - uses: Swatinem/rust-cache@v2
  112. - name: Run tests
  113. run: cargo test -p sbi-rt --verbose
  114. build-sbi-testing:
  115. name: Build sbi-testing
  116. needs: fmt
  117. runs-on: ubuntu-latest
  118. strategy:
  119. matrix:
  120. TARGET: [riscv64imac-unknown-none-elf] #, riscv32imac-unknown-none-elf]
  121. steps:
  122. - uses: actions/checkout@v4
  123. - uses: actions-rust-lang/setup-rust-toolchain@v1
  124. with:
  125. target: ${{ matrix.TARGET }}
  126. toolchain: nightly
  127. - uses: Swatinem/rust-cache@v2
  128. - name: Build (no default features)
  129. run: |
  130. cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-testing
  131. - name: Build (log)
  132. run: |
  133. cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-testing --features "log"
  134. msrv-test:
  135. name: MSRV Test (Rust 1.83.0)
  136. runs-on: ubuntu-latest
  137. strategy:
  138. matrix:
  139. rustsbi_TARGET:
  140. - riscv64imac-unknown-none-elf
  141. - riscv32imac-unknown-none-elf
  142. sbi_rt_TARGET:
  143. - riscv64imac-unknown-none-elf
  144. sbi_testing_TARGET:
  145. - riscv64imac-unknown-none-elf
  146. sbi_spec_TARGET:
  147. - riscv64imac-unknown-none-elf
  148. - riscv32imac-unknown-none-elf
  149. TOOLCHAIN:
  150. - nightly-2024-11-28
  151. steps:
  152. - name: Checkout repository
  153. uses: actions/checkout@v4
  154. - name: Install MSRV toolchain
  155. uses: actions-rust-lang/setup-rust-toolchain@v1
  156. with:
  157. toolchain: ${{ matrix.TOOLCHAIN }}
  158. override: true
  159. - name: Install target
  160. run: |
  161. rustup target add ${{ matrix.rustsbi_TARGET }}
  162. rustup target add ${{ matrix.sbi_rt_TARGET }}
  163. rustup target add ${{ matrix.sbi_testing_TARGET }}
  164. rustup target add ${{ matrix.sbi_spec_TARGET }}
  165. - uses: Swatinem/rust-cache@v2
  166. with:
  167. key: ${{ matrix.TOOLCHAIN }}
  168. - name: Check rustsbi
  169. run: cargo check --target ${{ matrix.rustsbi_TARGET }} -p rustsbi
  170. - name: Check sbi-rt
  171. run: cargo check --target ${{ matrix.sbi_rt_TARGET }} -p sbi-rt
  172. - name: Check sbi-testing
  173. run: cargo check --target ${{ matrix.sbi_testing_TARGET }} -p sbi-testing
  174. - name: Check sbi-spec (compilation check)
  175. run: cargo check --target ${{ matrix.sbi_spec_TARGET }} -p sbi-spec
  176. # sbi-testing:
  177. # name: Run rust-clippy analyzing
  178. # runs-on: ubuntu-latest
  179. # permissions:
  180. # security-events: write
  181. # steps:
  182. # - name: Checkout code
  183. # uses: actions/checkout@v4
  184. # - name: Check format
  185. # run: cargo fmt --check
  186. # - name: Install clippy-sarif
  187. # uses: actions-rs/install@v0.1
  188. # with:
  189. # crate: clippy-sarif
  190. # version: latest
  191. # - name: Install sarif-fmt
  192. # uses: actions-rs/install@v0.1
  193. # with:
  194. # crate: sarif-fmt
  195. # version: latest
  196. # - name: Run rust-clippy
  197. # run:
  198. # cargo clippy
  199. # --all-featuers
  200. # --package fast-trap
  201. # --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
  202. # continue-on-error: true
  203. # - name: Upload analysis results to GitHub
  204. # uses: github/codeql-action/upload-sarif@v2
  205. # with:
  206. # sarif_file: rust-clippy-results.sarif
  207. # wait-for-processing: true