main.yml 8.4 KB

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