Rust.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. name: Rust
  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. - name: Cache Dependencies
  21. uses: Swatinem/rust-cache@v2
  22. - name: Rustfmt Check
  23. uses: actions-rust-lang/rustfmt@v1
  24. build-rustsbi:
  25. name: Build rustsbi
  26. runs-on: ubuntu-latest
  27. needs: fmt
  28. strategy:
  29. matrix:
  30. TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
  31. TOOLCHAIN: [stable, nightly]
  32. steps:
  33. - uses: actions/checkout@v4
  34. - uses: actions-rust-lang/setup-rust-toolchain@v1
  35. with:
  36. target: ${{ matrix.TARGET }}
  37. toolchain: ${{ matrix.TOOLCHAIN }}
  38. - uses: Swatinem/rust-cache@v2
  39. with:
  40. key: ${{ matrix.TARGET }}
  41. - name: Build (no default features)
  42. run: |
  43. cargo build --target ${{ matrix.TARGET }} --verbose
  44. - name: Build (machine)
  45. run: |
  46. cargo build --target ${{ matrix.TARGET }} --verbose --features "machine"
  47. - name: Build (forward)
  48. run: |
  49. cargo build --target ${{ matrix.TARGET }} --verbose --features "forward"
  50. - name: Build (machine + forward)
  51. run: |
  52. cargo build --target ${{ matrix.TARGET }} --verbose --features "machine, forward"
  53. test-rustsbi:
  54. name: Test rustsbi
  55. needs: fmt
  56. runs-on: ubuntu-latest
  57. steps:
  58. - uses: actions/checkout@v4
  59. - uses: actions-rust-lang/setup-rust-toolchain@v1
  60. with:
  61. toolchain: stable
  62. - uses: Swatinem/rust-cache@v2
  63. - name: Run tests (no default features)
  64. run: |
  65. cargo test -p rustsbi --verbose
  66. - name: Run tests (machine)
  67. run: |
  68. cargo test -p rustsbi --verbose --features "machine"
  69. # Don't run tests with rustsbi `forward` features on here: it requires RISC-V targets to build.
  70. test-sbi-spec:
  71. name: Test sbi-spec
  72. needs: fmt
  73. runs-on: ubuntu-latest
  74. steps:
  75. - uses: actions/checkout@v4
  76. - uses: actions-rust-lang/setup-rust-toolchain@v1
  77. with:
  78. toolchain: stable
  79. - uses: Swatinem/rust-cache@v2
  80. # - name: Check clippy
  81. # run: cargo clippy -- -D warnings
  82. - name: Run tests
  83. run: cargo test -p sbi-spec --verbose
  84. build-sbi-rt:
  85. name: Build sbi-rt
  86. needs: fmt
  87. runs-on: ubuntu-latest
  88. strategy:
  89. matrix:
  90. TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
  91. steps:
  92. - uses: actions/checkout@v4
  93. - uses: actions-rust-lang/setup-rust-toolchain@v1
  94. with:
  95. target: ${{ matrix.TARGET }}
  96. toolchain: stable
  97. - uses: Swatinem/rust-cache@v2
  98. - name: Build
  99. run: |
  100. cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-rt
  101. build-sbi-testing:
  102. name: Build sbi-testing
  103. needs: fmt
  104. runs-on: ubuntu-latest
  105. strategy:
  106. matrix:
  107. TARGET: [riscv64imac-unknown-none-elf] #, riscv32imac-unknown-none-elf]
  108. steps:
  109. - uses: actions/checkout@v4
  110. - uses: actions-rust-lang/setup-rust-toolchain@v1
  111. with:
  112. target: ${{ matrix.TARGET }}
  113. toolchain: nightly
  114. - uses: Swatinem/rust-cache@v2
  115. - name: Build (no default features)
  116. run: |
  117. cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-testing
  118. - name: Build (log)
  119. run: |
  120. cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-testing --features "log"
  121. # sbi-testing:
  122. # name: Run rust-clippy analyzing
  123. # runs-on: ubuntu-latest
  124. # permissions:
  125. # security-events: write
  126. # steps:
  127. # - name: Checkout code
  128. # uses: actions/checkout@v4
  129. # - name: Check format
  130. # run: cargo fmt --check
  131. # - name: Install clippy-sarif
  132. # uses: actions-rs/[email protected]
  133. # with:
  134. # crate: clippy-sarif
  135. # version: latest
  136. # - name: Install sarif-fmt
  137. # uses: actions-rs/[email protected]
  138. # with:
  139. # crate: sarif-fmt
  140. # version: latest
  141. # - name: Run rust-clippy
  142. # run:
  143. # cargo clippy
  144. # --all-featuers
  145. # --package fast-trap
  146. # --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
  147. # continue-on-error: true
  148. # - name: Upload analysis results to GitHub
  149. # uses: github/codeql-action/upload-sarif@v2
  150. # with:
  151. # sarif_file: rust-clippy-results.sarif
  152. # wait-for-processing: true