main.yml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. env:
  31. CARGO_TERM_COLOR: always
  32. CARGO_INCREMENTAL: 0
  33. SCCACHE_GHA_ENABLED: "true"
  34. RUSTC_WRAPPER: "sccache"
  35. jobs:
  36. check:
  37. if: github.event.pull_request.draft == false
  38. name: Check
  39. runs-on: ubuntu-latest
  40. steps:
  41. - run: sudo apt-get update
  42. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
  43. - uses: dtolnay/rust-toolchain@stable
  44. - uses: mozilla-actions/sccache-action@v0.0.3
  45. - uses: ilammy/setup-nasm@v1
  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. steps:
  53. - run: sudo apt-get update
  54. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
  55. - uses: dtolnay/rust-toolchain@stable
  56. - uses: mozilla-actions/sccache-action@v0.0.3
  57. - uses: ilammy/setup-nasm@v1
  58. - uses: davidB/rust-cargo-make@v1
  59. - uses: browser-actions/setup-firefox@latest
  60. - uses: jetli/wasm-pack-action@v0.4.0
  61. - uses: actions/checkout@v4
  62. - run: cargo make tests
  63. fmt:
  64. if: github.event.pull_request.draft == false
  65. name: Rustfmt
  66. runs-on: ubuntu-latest
  67. steps:
  68. - uses: ilammy/setup-nasm@v1
  69. - uses: dtolnay/rust-toolchain@stable
  70. with:
  71. components: rustfmt
  72. - uses: mozilla-actions/sccache-action@v0.0.3
  73. - uses: actions/checkout@v4
  74. - run: cargo fmt --all -- --check
  75. clippy:
  76. if: github.event.pull_request.draft == false
  77. name: Clippy
  78. runs-on: ubuntu-latest
  79. steps:
  80. - run: sudo apt-get update
  81. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev
  82. - uses: ilammy/setup-nasm@v1
  83. - uses: dtolnay/rust-toolchain@stable
  84. with:
  85. components: rustfmt, clippy
  86. - uses: mozilla-actions/sccache-action@v0.0.3
  87. - uses: actions/checkout@v4
  88. - run: cargo clippy --workspace --examples --tests -- -D warnings
  89. miri:
  90. if: github.event.pull_request.draft == false
  91. name: Miri
  92. runs-on: ubuntu-latest
  93. env:
  94. CARGO_UNSTABLE_SPARSE_REGISTRY: 'true'
  95. RUSTFLAGS: -Dwarnings
  96. RUST_BACKTRACE: 1
  97. MIRIFLAGS: -Zmiri-tag-gc=1
  98. # Change to specific Rust release to pin
  99. rust_stable: stable
  100. rust_nightly: nightly-2023-11-16
  101. rust_clippy: 1.70.0
  102. steps:
  103. - uses: actions/checkout@v4
  104. - uses: ilammy/setup-nasm@v1
  105. - name: Install Rust ${{ env.rust_nightly }}
  106. uses: dtolnay/rust-toolchain@master
  107. with:
  108. toolchain: ${{ env.rust_nightly }}
  109. components: miri
  110. - uses: mozilla-actions/sccache-action@v0.0.3
  111. - name: miri
  112. # Many of tests in tokio/tests and doctests use #[tokio::test] or
  113. # #[tokio::main] that calls epoll_create1 that Miri does not support.
  114. # run: cargo miri test --features full --lib --no-fail-fast
  115. run: |
  116. cargo miri test --package dioxus-core -- --exact --nocapture
  117. cargo miri test --package dioxus-native-core --test miri_native -- --exact --nocapture
  118. env:
  119. MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields
  120. PROPTEST_CASES: 10
  121. playwright:
  122. if: github.event.pull_request.draft == false
  123. name: Playwright Tests
  124. runs-on: ubuntu-latest
  125. steps:
  126. # Do our best to cache the toolchain and node install steps
  127. - uses: ilammy/setup-nasm@v1
  128. - uses: actions/setup-node@v4
  129. with:
  130. node-version: 16
  131. - name: Install Rust
  132. uses: dtolnay/rust-toolchain@master
  133. with:
  134. toolchain: stable
  135. targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
  136. - uses: mozilla-actions/sccache-action@v0.0.3
  137. - run: cd playwright-tests
  138. - name: Install dependencies
  139. run: npm ci
  140. - name: Install Playwright
  141. run: npm install -D @playwright/test
  142. - name: Install Playwright Browsers
  143. run: npx playwright install --with-deps
  144. # Cache the CLI by using cargo run internally
  145. # - name: Install Dioxus CLI
  146. # uses: actions-rs/cargo@v1
  147. # with:
  148. # command: install
  149. # args: --path packages/cli
  150. - uses: actions/checkout@v4
  151. - name: Run Playwright tests
  152. run: npx playwright test
  153. - uses: actions/upload-artifact@v4
  154. if: always()
  155. with:
  156. name: playwright-report
  157. path: playwright-report/
  158. retention-days: 30
  159. matrix_test:
  160. runs-on: ${{ matrix.platform.os }}
  161. if: github.event.pull_request.draft == false
  162. env:
  163. RUST_CARGO_COMMAND: ${{ matrix.platform.cross == true && 'cross' || 'cargo' }}
  164. strategy:
  165. matrix:
  166. platform:
  167. - {
  168. target: x86_64-pc-windows-msvc,
  169. os: windows-latest,
  170. toolchain: "1.70.0",
  171. cross: false,
  172. command: "test",
  173. args: "--all --tests",
  174. }
  175. - {
  176. target: x86_64-apple-darwin,
  177. os: macos-latest,
  178. toolchain: "1.70.0",
  179. cross: false,
  180. command: "test",
  181. args: "--all --tests",
  182. }
  183. - {
  184. target: aarch64-apple-ios,
  185. os: macos-latest,
  186. toolchain: "1.70.0",
  187. cross: false,
  188. command: "build",
  189. args: "--package dioxus-mobile",
  190. }
  191. - {
  192. target: aarch64-linux-android,
  193. os: ubuntu-latest,
  194. toolchain: "1.70.0",
  195. cross: true,
  196. command: "build",
  197. args: "--package dioxus-mobile",
  198. }
  199. steps:
  200. - uses: ilammy/setup-nasm@v1
  201. - name: install stable
  202. uses: dtolnay/rust-toolchain@master
  203. with:
  204. toolchain: ${{ matrix.platform.toolchain }}
  205. targets: ${{ matrix.platform.target }}
  206. components: rustfmt
  207. - name: Install cross
  208. if: ${{ matrix.platform.cross == true }}
  209. uses: taiki-e/install-action@cross
  210. - uses: mozilla-actions/sccache-action@v0.0.3
  211. with:
  212. workspaces: core -> ../target
  213. save-if: ${{ matrix.features.key == 'all' }}
  214. - uses: actions/checkout@v4
  215. - name: test
  216. run: |
  217. ${{ env.RUST_CARGO_COMMAND }} ${{ matrix.platform.command }} ${{ matrix.platform.args }} --target ${{ matrix.platform.target }}
  218. # Coverage is disabled until we can fix it
  219. # coverage:
  220. # name: Coverage
  221. # runs-on: ubuntu-latest
  222. # container:
  223. # image: xd009642/tarpaulin:develop-nightly
  224. # options: --security-opt seccomp=unconfined
  225. # steps:
  226. # - name: Checkout repository
  227. # uses: actions/checkout@v4
  228. # - name: Generate code coverage
  229. # run: |
  230. # apt-get update &&\
  231. # apt-get install build-essential &&\
  232. # apt install libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev -y &&\
  233. # cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
  234. # - name: Upload to codecov.io
  235. # uses: codecov/codecov-action@v2
  236. # with:
  237. # fail_ci_if_error: false