main.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. name: Rust CI
  2. on:
  3. push:
  4. branches:
  5. - master
  6. paths:
  7. - packages/**
  8. - examples/**
  9. - docs/guide/**
  10. - src/**
  11. - .github/**
  12. - lib.rs
  13. - Cargo.toml
  14. - Makefile.toml
  15. - playwright-tests/**
  16. pull_request:
  17. types: [opened, synchronize, reopened, ready_for_review]
  18. branches:
  19. - master
  20. paths:
  21. - packages/**
  22. - examples/**
  23. - src/**
  24. - .github/**
  25. - lib.rs
  26. - Cargo.toml
  27. concurrency:
  28. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  29. cancel-in-progress: true
  30. jobs:
  31. check:
  32. if: github.event.pull_request.draft == false
  33. name: Check
  34. runs-on: ubuntu-latest
  35. env:
  36. CARGO_TERM_COLOR: always
  37. CARGO_INCREMENTAL: 0
  38. SCCACHE_GHA_ENABLED: "true"
  39. RUSTC_WRAPPER: "sccache"
  40. steps:
  41. - uses: dtolnay/rust-toolchain@stable
  42. - uses: mozilla-actions/sccache-action@v0.0.3
  43. - uses: ilammy/setup-nasm@v1
  44. - run: sudo apt-get update
  45. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev
  46. - uses: actions/checkout@v4
  47. - run: cargo check --all --examples --tests
  48. test:
  49. if: github.event.pull_request.draft == false
  50. name: Test Suite
  51. runs-on: ubuntu-latest
  52. env:
  53. CARGO_TERM_COLOR: always
  54. CARGO_INCREMENTAL: 0
  55. SCCACHE_GHA_ENABLED: "true"
  56. RUSTC_WRAPPER: "sccache"
  57. steps:
  58. - uses: dtolnay/rust-toolchain@stable
  59. - uses: mozilla-actions/sccache-action@v0.0.3
  60. - uses: ilammy/setup-nasm@v1
  61. - run: sudo apt-get update
  62. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
  63. - uses: davidB/rust-cargo-make@v1
  64. - uses: browser-actions/setup-firefox@latest
  65. - uses: jetli/wasm-pack-action@v0.4.0
  66. - uses: actions/checkout@v4
  67. - run: cargo make tests
  68. fmt:
  69. if: github.event.pull_request.draft == false
  70. name: Rustfmt
  71. runs-on: ubuntu-latest
  72. env:
  73. CARGO_TERM_COLOR: always
  74. CARGO_INCREMENTAL: 0
  75. SCCACHE_GHA_ENABLED: "true"
  76. RUSTC_WRAPPER: "sccache"
  77. steps:
  78. - uses: dtolnay/rust-toolchain@stable
  79. - uses: mozilla-actions/sccache-action@v0.0.3
  80. - uses: ilammy/setup-nasm@v1
  81. - run: rustup component add rustfmt
  82. - uses: actions/checkout@v4
  83. - run: cargo fmt --all -- --check
  84. clippy:
  85. if: github.event.pull_request.draft == false
  86. name: Clippy
  87. runs-on: ubuntu-latest
  88. env:
  89. CARGO_TERM_COLOR: always
  90. CARGO_INCREMENTAL: 0
  91. SCCACHE_GHA_ENABLED: "true"
  92. RUSTC_WRAPPER: "sccache"
  93. steps:
  94. - uses: dtolnay/rust-toolchain@stable
  95. - uses: mozilla-actions/sccache-action@v0.0.3
  96. - uses: ilammy/setup-nasm@v1
  97. - run: sudo apt-get update
  98. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev
  99. - run: rustup component add clippy
  100. - uses: actions/checkout@v4
  101. - run: cargo clippy --workspace --examples --tests -- -D warnings
  102. matrix_test:
  103. runs-on: ${{ matrix.platform.os }}
  104. env:
  105. CARGO_TERM_COLOR: always
  106. CARGO_INCREMENTAL: 0
  107. SCCACHE_GHA_ENABLED: "true"
  108. RUSTC_WRAPPER: "sccache"
  109. RUST_CARGO_COMMAND: ${{ matrix.platform.cross == true && 'cross' || 'cargo' }}
  110. strategy:
  111. matrix:
  112. platform:
  113. - {
  114. target: x86_64-pc-windows-msvc,
  115. os: windows-latest,
  116. toolchain: "1.70.0",
  117. cross: false,
  118. command: "test",
  119. args: "--all --tests",
  120. }
  121. - {
  122. target: x86_64-apple-darwin,
  123. os: macos-latest,
  124. toolchain: "1.70.0",
  125. cross: false,
  126. command: "test",
  127. args: "--all --tests",
  128. }
  129. - {
  130. target: aarch64-apple-ios,
  131. os: macos-latest,
  132. toolchain: "1.70.0",
  133. cross: false,
  134. command: "build",
  135. args: "--package dioxus-mobile",
  136. }
  137. - {
  138. target: aarch64-linux-android,
  139. os: ubuntu-latest,
  140. toolchain: "1.70.0",
  141. cross: true,
  142. command: "build",
  143. args: "--package dioxus-mobile",
  144. }
  145. steps:
  146. - uses: actions/checkout@v4
  147. - uses: ilammy/setup-nasm@v1
  148. - name: install stable
  149. uses: dtolnay/rust-toolchain@master
  150. with:
  151. toolchain: ${{ matrix.platform.toolchain }}
  152. targets: ${{ matrix.platform.target }}
  153. - name: Install cross
  154. if: ${{ matrix.platform.cross == true }}
  155. uses: taiki-e/install-action@cross
  156. - uses: mozilla-actions/sccache-action@v0.0.3
  157. with:
  158. workspaces: core -> ../target
  159. save-if: ${{ matrix.features.key == 'all' }}
  160. - name: Install rustfmt
  161. run: rustup component add rustfmt
  162. - uses: actions/checkout@v4
  163. - name: test
  164. run: |
  165. ${{ env.RUST_CARGO_COMMAND }} ${{ matrix.platform.command }} ${{ matrix.platform.args }} --target ${{ matrix.platform.target }}
  166. # Coverage is disabled until we can fix it
  167. # coverage:
  168. # name: Coverage
  169. # runs-on: ubuntu-latest
  170. # container:
  171. # image: xd009642/tarpaulin:develop-nightly
  172. # options: --security-opt seccomp=unconfined
  173. # steps:
  174. # - name: Checkout repository
  175. # uses: actions/checkout@v4
  176. # - name: Generate code coverage
  177. # run: |
  178. # apt-get update &&\
  179. # apt-get install build-essential &&\
  180. # apt install libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev -y &&\
  181. # cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
  182. # - name: Upload to codecov.io
  183. # uses: codecov/codecov-action@v2
  184. # with:
  185. # fail_ci_if_error: false