main.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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. SCCACHE_GHA_ENABLED: "true"
  35. # RUSTC_WRAPPER: "sccache"
  36. SCCACHE_IDLE_TIMEOUT: "0"
  37. SCCACHE_GHA_VERSION: "sccache"
  38. SCCACHE_BYPASS_CHECK: "on"
  39. jobs:
  40. check:
  41. if: github.event.pull_request.draft == false
  42. name: Check
  43. runs-on: ubuntu-latest
  44. steps:
  45. - uses: actions/checkout@v4
  46. - run: sudo apt-get update
  47. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
  48. - uses: dtolnay/rust-toolchain@stable
  49. - uses: Swatinem/rust-cache@v2
  50. with:
  51. cache-all-crates: "true"
  52. save-if: ${{ github.ref == 'refs/heads/master' }}
  53. - uses: ilammy/setup-nasm@v1
  54. - run: cargo check --all --examples --tests
  55. test:
  56. if: github.event.pull_request.draft == false
  57. name: Test Suite
  58. runs-on: ubuntu-latest
  59. steps:
  60. - uses: actions/checkout@v4
  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: dtolnay/rust-toolchain@stable
  64. - uses: Swatinem/rust-cache@v2
  65. with:
  66. cache-all-crates: "true"
  67. save-if: ${{ github.ref == 'refs/heads/master' }}
  68. - uses: ilammy/setup-nasm@v1
  69. - uses: davidB/rust-cargo-make@v1
  70. - uses: browser-actions/setup-firefox@latest
  71. - uses: jetli/wasm-pack-action@v0.4.0
  72. - run: sudo rm -rf /usr/share/dotnet
  73. - run: sudo rm -rf "$AGENT_TOOLSDIRECTORY"
  74. - run: |
  75. df -h
  76. sudo rm -rf ${GITHUB_WORKSPACE}/.git
  77. df -h
  78. - run: cargo make tests
  79. fmt:
  80. if: github.event.pull_request.draft == false
  81. name: Rustfmt
  82. runs-on: ubuntu-latest
  83. steps:
  84. - uses: actions/checkout@v4
  85. - uses: ilammy/setup-nasm@v1
  86. - uses: dtolnay/rust-toolchain@stable
  87. with:
  88. components: rustfmt
  89. - uses: Swatinem/rust-cache@v2
  90. with:
  91. cache-all-crates: "true"
  92. save-if: ${{ github.ref == 'refs/heads/master' }}
  93. - run: cargo fmt --all -- --check
  94. clippy:
  95. if: github.event.pull_request.draft == false
  96. name: Clippy
  97. runs-on: ubuntu-latest
  98. steps:
  99. - uses: actions/checkout@v4
  100. - run: sudo apt-get update
  101. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev
  102. - uses: ilammy/setup-nasm@v1
  103. - uses: dtolnay/rust-toolchain@stable
  104. with:
  105. components: rustfmt, clippy
  106. - uses: Swatinem/rust-cache@v2
  107. with:
  108. cache-all-crates: "true"
  109. save-if: ${{ github.ref == 'refs/heads/master' }}
  110. - run: cargo clippy --workspace --examples --tests -- -D warnings
  111. miri:
  112. if: github.event.pull_request.draft == false
  113. name: Miri
  114. runs-on: ubuntu-latest
  115. env:
  116. CARGO_UNSTABLE_SPARSE_REGISTRY: 'true'
  117. RUSTFLAGS: -Dwarnings
  118. RUST_BACKTRACE: 1
  119. MIRIFLAGS: -Zmiri-tag-gc=1
  120. # Change to specific Rust release to pin
  121. rust_stable: stable
  122. rust_nightly: nightly-2023-11-16
  123. rust_clippy: 1.70.0
  124. steps:
  125. - uses: actions/checkout@v4
  126. - uses: ilammy/setup-nasm@v1
  127. - name: Install Rust ${{ env.rust_nightly }}
  128. uses: dtolnay/rust-toolchain@master
  129. with:
  130. toolchain: ${{ env.rust_nightly }}
  131. components: miri
  132. - uses: Swatinem/rust-cache@v2
  133. with:
  134. cache-all-crates: "true"
  135. save-if: ${{ github.ref == 'refs/heads/master' }}
  136. - name: miri
  137. # Many of tests in tokio/tests and doctests use #[tokio::test] or
  138. # #[tokio::main] that calls epoll_create1 that Miri does not support.
  139. # run: cargo miri test --features full --lib --no-fail-fast
  140. run: |
  141. cargo miri test --package dioxus-core -- --exact --nocapture
  142. cargo miri test --package dioxus-native-core --test miri_native -- --exact --nocapture
  143. env:
  144. MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields
  145. PROPTEST_CASES: 10
  146. playwright:
  147. if: github.event.pull_request.draft == false
  148. name: Playwright Tests
  149. runs-on: ubuntu-latest
  150. steps:
  151. # Do our best to cache the toolchain and node install steps
  152. - uses: actions/checkout@v4
  153. - uses: ilammy/setup-nasm@v1
  154. - uses: actions/setup-node@v4
  155. with:
  156. node-version: 16
  157. - name: Install Rust
  158. uses: dtolnay/rust-toolchain@master
  159. with:
  160. toolchain: stable
  161. targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
  162. - uses: Swatinem/rust-cache@v2
  163. with:
  164. cache-all-crates: "true"
  165. save-if: ${{ github.ref == 'refs/heads/master' }}
  166. - name: Install dependencies
  167. run: npm ci
  168. working-directory: ./playwright-tests
  169. - name: Install Playwright
  170. run: npm install -D @playwright/test
  171. working-directory: ./playwright-tests
  172. - name: Install Playwright Browsers
  173. run: npx playwright install --with-deps
  174. working-directory: ./playwright-tests
  175. # Cache the CLI by using cargo run internally
  176. # - name: Install Dioxus CLI
  177. # uses: actions-rs/cargo@v1
  178. # with:
  179. # command: install
  180. # args: --path packages/cli
  181. - name: Run Playwright tests
  182. run: npx playwright test
  183. working-directory: ./playwright-tests
  184. - uses: actions/upload-artifact@v4
  185. if: always()
  186. with:
  187. name: playwright-report
  188. path: playwright-report/
  189. retention-days: 30
  190. matrix_test:
  191. runs-on: ${{ matrix.platform.os }}
  192. if: github.event.pull_request.draft == false
  193. env:
  194. RUST_CARGO_COMMAND: ${{ matrix.platform.cross == true && 'cross' || 'cargo' }}
  195. strategy:
  196. matrix:
  197. platform:
  198. - {
  199. target: x86_64-pc-windows-msvc,
  200. os: windows-latest,
  201. toolchain: "1.70.0",
  202. cross: false,
  203. command: "test",
  204. args: "--all --tests",
  205. }
  206. - {
  207. target: x86_64-apple-darwin,
  208. os: macos-latest,
  209. toolchain: "1.70.0",
  210. cross: false,
  211. command: "test",
  212. args: "--all --tests",
  213. }
  214. - {
  215. target: aarch64-apple-ios,
  216. os: macos-latest,
  217. toolchain: "1.70.0",
  218. cross: false,
  219. command: "build",
  220. args: "--package dioxus-mobile",
  221. }
  222. - {
  223. target: aarch64-linux-android,
  224. os: ubuntu-latest,
  225. toolchain: "1.70.0",
  226. cross: true,
  227. command: "build",
  228. args: "--package dioxus-mobile",
  229. }
  230. steps:
  231. - uses: actions/checkout@v4
  232. - uses: ilammy/setup-nasm@v1
  233. - name: install stable
  234. uses: dtolnay/rust-toolchain@master
  235. with:
  236. toolchain: ${{ matrix.platform.toolchain }}
  237. targets: ${{ matrix.platform.target }}
  238. components: rustfmt
  239. - name: Install cross
  240. if: ${{ matrix.platform.cross == true }}
  241. uses: taiki-e/install-action@cross
  242. - uses: Swatinem/rust-cache@v2
  243. with:
  244. # The prefix cache key, this can be changed to start a new cache manually.
  245. # default: "v0-rust"
  246. # prefix-key: ""
  247. # A cache key that is used instead of the automatic `job`-based key,
  248. # and is stable over multiple jobs.
  249. # default: empty
  250. # shared-key: ""
  251. # An additional cache key that is added alongside the automatic `job`-based
  252. # cache key and can be used to further differentiate jobs.
  253. # default: empty
  254. key: "${{ matrix.platform.target }}"
  255. # A whitespace separated list of env-var *prefixes* who's value contributes
  256. # to the environment cache key.
  257. # The env-vars are matched by *prefix*, so the default `RUST` var will
  258. # match all of `RUSTC`, `RUSTUP_*`, `RUSTFLAGS`, `RUSTDOC_*`, etc.
  259. # default: "CARGO CC CFLAGS CXX CMAKE RUST"
  260. # env-vars: ""
  261. # The cargo workspaces and target directory configuration.
  262. # These entries are separated by newlines and have the form
  263. # `$workspace -> $target`. The `$target` part is treated as a directory
  264. # relative to the `$workspace` and defaults to "target" if not explicitly given.
  265. # default: ". -> target"
  266. # workspaces: ""
  267. # Additional non workspace directories to be cached, separated by newlines.
  268. # cache-directories: ""
  269. # Determines whether workspace `target` directories are cached.
  270. # If `false`, only the cargo registry will be cached.
  271. # default: "true"
  272. # cache-targets: ""
  273. # Determines if the cache should be saved even when the workflow has failed.
  274. # default: "false"
  275. # cache-on-failure: "true"
  276. # Determines which crates are cached.
  277. # If `true` all crates will be cached, otherwise only dependent crates will be cached.
  278. # Useful if additional crates are used for CI tooling.
  279. # default: "false"
  280. cache-all-crates: "true"
  281. # save-if: ${{ github.ref == 'refs/heads/master' }}
  282. # Determiners whether the cache should be saved.
  283. # If `false`, the cache is only restored.
  284. # Useful for jobs where the matrix is additive e.g. additional Cargo features,
  285. # or when only runs from `master` should be saved to the cache.
  286. # default: "true"
  287. # save-if: ""
  288. # To only cache runs from `master`:
  289. save-if: ${{ github.ref == 'refs/heads/master' }}
  290. # Specifies what to use as the backend providing cache
  291. # Can be set to either "github" or "buildjet"
  292. # default: "github"
  293. # cache-provider: ""
  294. # - uses: mozilla-actions/sccache-action@v0.0.3
  295. # with:
  296. # workspaces: core -> ../target
  297. # save-if: ${{ matrix.features.key == 'all' }}
  298. - name: test
  299. run: |
  300. ${{ env.RUST_CARGO_COMMAND }} ${{ matrix.platform.command }} ${{ matrix.platform.args }} --target ${{ matrix.platform.target }}
  301. # Coverage is disabled until we can fix it
  302. # coverage:
  303. # name: Coverage
  304. # runs-on: ubuntu-latest
  305. # container:
  306. # image: xd009642/tarpaulin:develop-nightly
  307. # options: --security-opt seccomp=unconfined
  308. # steps:
  309. # - name: Checkout repository
  310. # uses: actions/checkout@v4
  311. # - name: Generate code coverage
  312. # run: |
  313. # apt-get update &&\
  314. # apt-get install build-essential &&\
  315. # apt install libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev -y &&\
  316. # cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
  317. # - name: Upload to codecov.io
  318. # uses: codecov/codecov-action@v2
  319. # with:
  320. # fail_ci_if_error: false