main.yml 11 KB

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