rust.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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@v3
  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: Cargo check (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@v3
  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, SBI 1.0.0)
  49. uses: actions-rs/cargo@v1
  50. with:
  51. command: check
  52. args: --target ${{ matrix.TARGET }} --no-default-features --verbose
  53. - name: Check (no default features, SBI 2.0-rc1)
  54. uses: actions-rs/cargo@v1
  55. with:
  56. command: check
  57. args: --features "sbi_2_0" --target ${{ matrix.TARGET }} --no-default-features --verbose
  58. - name: Check (machine, SBI 1.0.0)
  59. uses: actions-rs/cargo@v1
  60. with:
  61. command: check
  62. args: --target ${{ matrix.TARGET }} --features "machine" --verbose
  63. - name: Check (machine, SBI 2.0-rc1)
  64. uses: actions-rs/cargo@v1
  65. with:
  66. command: check
  67. args: --features "sbi_2_0" --target ${{ matrix.TARGET }} --features "machine" --verbose
  68. check-nightly:
  69. name: Cargo check (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@v3
  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. - name: Check (singleton, SBI 1.0.0)
  88. uses: actions-rs/cargo@v1
  89. with:
  90. command: check
  91. args: --features "singleton" --target ${{ matrix.TARGET }} --verbose
  92. - name: Check (singleton, SBI 2.0-rc1)
  93. uses: actions-rs/cargo@v1
  94. with:
  95. command: check
  96. args: --features "singleton,sbi_2_0" --target ${{ matrix.TARGET }} --verbose
  97. - name: Check (legacy, SBI 1.0.0)
  98. uses: actions-rs/cargo@v1
  99. with:
  100. command: check
  101. args: --features "legacy" --target ${{ matrix.TARGET }} --verbose
  102. - name: Check (legacy, SBI 2.0-rc1)
  103. uses: actions-rs/cargo@v1
  104. with:
  105. command: check
  106. args: --features "legacy,sbi_2_0" --target ${{ matrix.TARGET }} --verbose
  107. tests:
  108. name: Run tests
  109. needs: fmt
  110. runs-on: ubuntu-latest
  111. steps:
  112. - uses: actions/checkout@v3
  113. - uses: actions-rs/toolchain@v1
  114. with:
  115. profile: minimal
  116. toolchain: stable
  117. components: clippy
  118. override: true
  119. - name: Cache Dependencies
  120. uses: Swatinem/rust-cache@v2
  121. - name: Clippy
  122. uses: actions-rs/cargo@v1
  123. with:
  124. command: clippy
  125. - name: Run tests (no default features, SBI 1.0.0)
  126. uses: actions-rs/cargo@v1
  127. with:
  128. command: test
  129. args: --no-default-features --verbose
  130. - name: Run tests (no default features, SBI 2.0-rc1)
  131. uses: actions-rs/cargo@v1
  132. with:
  133. command: test
  134. args: --features "sbi_2_0" --no-default-features --verbose
  135. - name: Run tests (machine, SBI 1.0.0)
  136. uses: actions-rs/cargo@v1
  137. with:
  138. command: test
  139. args: --features "machine" --verbose
  140. - name: Run tests (machine, SBI 2.0-rc1)
  141. uses: actions-rs/cargo@v1
  142. with:
  143. command: test
  144. args: --features "machine,sbi_2_0" --verbose