main.yml 8.5 KB

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