rust.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. name: CI
  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
  14. runs-on: ubuntu-latest
  15. steps:
  16. - uses: actions/checkout@v4
  17. - uses: actions-rs/toolchain@v1
  18. with:
  19. profile: minimal
  20. toolchain: stable
  21. override: true
  22. components: rustfmt
  23. - name: Cache Dependencies
  24. uses: Swatinem/rust-cache@v2
  25. - uses: actions-rs/cargo@v1
  26. with:
  27. command: fmt
  28. args: --all -- --check
  29. check-stable:
  30. name: Check rustsbi (stable)
  31. runs-on: ubuntu-latest
  32. needs: fmt
  33. strategy:
  34. matrix:
  35. TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
  36. steps:
  37. - uses: actions/checkout@v4
  38. - uses: actions-rs/toolchain@v1
  39. with:
  40. profile: minimal
  41. toolchain: stable
  42. override: true
  43. target: ${{ matrix.TARGET }}
  44. - name: Cache Dependencies
  45. uses: Swatinem/rust-cache@v2
  46. with:
  47. key: ${{ matrix.TARGET }}
  48. - name: Check (no default features)
  49. uses: actions-rs/cargo@v1
  50. with:
  51. command: check
  52. args: --target ${{ matrix.TARGET }} --verbose -p rustsbi
  53. - name: Check crate rustsbi (machine)
  54. uses: actions-rs/cargo@v1
  55. with:
  56. command: check
  57. args: --target ${{ matrix.TARGET }} --features "machine" --verbose -p rustsbi
  58. - name: Check crate rustsbi (forward)
  59. uses: actions-rs/cargo@v1
  60. with:
  61. command: check
  62. args: --target ${{ matrix.TARGET }} --features "forward" --verbose -p rustsbi
  63. - name: Check crate rustsbi (machine + forward)
  64. uses: actions-rs/cargo@v1
  65. with:
  66. command: check
  67. args: --target ${{ matrix.TARGET }} --features "machine, forward" --verbose -p rustsbi
  68. check-nightly:
  69. name: Check rustsbi (nightly)
  70. runs-on: ubuntu-latest
  71. needs: fmt
  72. strategy:
  73. matrix:
  74. TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
  75. steps:
  76. - uses: actions/checkout@v4
  77. - uses: actions-rs/toolchain@v1
  78. with:
  79. profile: minimal
  80. toolchain: nightly
  81. override: true
  82. target: ${{ matrix.TARGET }}
  83. - name: Cache Dependencies
  84. uses: Swatinem/rust-cache@v2
  85. with:
  86. key: ${{ matrix.TARGET }}
  87. tests:
  88. name: Test rustsbi
  89. needs: fmt
  90. runs-on: ubuntu-latest
  91. steps:
  92. - uses: actions/checkout@v4
  93. - uses: actions-rs/toolchain@v1
  94. with:
  95. profile: minimal
  96. toolchain: stable
  97. components: clippy
  98. override: true
  99. - name: Cache Dependencies
  100. uses: Swatinem/rust-cache@v2
  101. # - name: Clippy
  102. # uses: actions-rs/cargo@v1
  103. # with:
  104. # command: clippy
  105. - name: Run tests (no default features)
  106. uses: actions-rs/cargo@v1
  107. with:
  108. command: test
  109. args: --verbose -p rustsbi
  110. - name: Run tests (machine)
  111. uses: actions-rs/cargo@v1
  112. with:
  113. command: test
  114. args: --features "machine" --verbose -p rustsbi
  115. sbi-spec:
  116. name: Test sbi-spec
  117. needs: fmt
  118. runs-on: ubuntu-latest
  119. strategy:
  120. fail-fast: false
  121. matrix:
  122. target:
  123. [
  124. riscv32imac-unknown-none-elf,
  125. riscv64imac-unknown-none-elf,
  126. x86_64-unknown-none,
  127. ]
  128. steps:
  129. - uses: actions/checkout@v4
  130. # Cache REF:
  131. # - https://github.com/actions/cache/blob/main/examples.md#rust---cargo
  132. # - https://github.com/actions-rs/toolchain/issues/54
  133. - name: Cache Rust
  134. uses: actions/cache@v3
  135. with:
  136. key: rust-toolchain-${{ matrix.target }}
  137. path: |
  138. ~/.rustup/settings.toml
  139. ~/.rustup/toolchains/stable-*
  140. ~/.rustup/update-hashes/stable-*
  141. ~/.cargo/bin/
  142. ~/.cargo/registry/index/
  143. ~/.cargo/registry/cache/
  144. ~/.cargo/git/db/
  145. target/
  146. - name: Setup Rust
  147. run: |
  148. rustup toolchain install stable --profile minimal
  149. rustup component add rustfmt clippy
  150. rustup target add ${{ matrix.target }}
  151. - name: Check format
  152. run: cargo fmt --all --check -p sbi-spec
  153. # - name: Check clippy
  154. # run: cargo clippy -- -D warnings
  155. - name: Check build
  156. run: cargo build -p sbi-spec
  157. - name: Check test
  158. run: cargo test -p sbi-spec
  159. # sbi-testing:
  160. # name: Run rust-clippy analyzing
  161. # runs-on: ubuntu-latest
  162. # permissions:
  163. # security-events: write
  164. # steps:
  165. # - name: Checkout code
  166. # uses: actions/checkout@v4
  167. # - name: Check format
  168. # run: cargo fmt --check
  169. # - name: Install clippy-sarif
  170. # uses: actions-rs/[email protected]
  171. # with:
  172. # crate: clippy-sarif
  173. # version: latest
  174. # - name: Install sarif-fmt
  175. # uses: actions-rs/[email protected]
  176. # with:
  177. # crate: sarif-fmt
  178. # version: latest
  179. # - name: Run rust-clippy
  180. # run:
  181. # cargo clippy
  182. # --all-featuers
  183. # --package fast-trap
  184. # --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
  185. # continue-on-error: true
  186. # - name: Upload analysis results to GitHub
  187. # uses: github/codeql-action/upload-sarif@v2
  188. # with:
  189. # sarif_file: rust-clippy-results.sarif
  190. # wait-for-processing: true