main.yml 8.4 KB

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