1
0

main.yml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. # Whenever an open PR is updated, the workflow will be triggered
  2. #
  3. # This can get expensive, so we do a lot of caching and checks to prevent unnecessary runs
  4. name: Rust CI
  5. on:
  6. push:
  7. branches:
  8. - main
  9. paths:
  10. - packages/**
  11. - examples/**
  12. - docs/guide/**
  13. - src/**
  14. - .github/**
  15. - lib.rs
  16. - Cargo.toml
  17. - Makefile.toml
  18. pull_request:
  19. types: [opened, synchronize, reopened, ready_for_review]
  20. branches:
  21. - main
  22. paths:
  23. - packages/**
  24. - examples/**
  25. - src/**
  26. - .github/**
  27. - lib.rs
  28. - Cargo.toml
  29. # workflow_dispatch:
  30. concurrency:
  31. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  32. cancel-in-progress: true
  33. env:
  34. CARGO_TERM_COLOR: always
  35. CARGO_INCREMENTAL: "0"
  36. jobs:
  37. check:
  38. if: github.event.pull_request.draft == false
  39. name: Check
  40. runs-on: ubuntu-latest
  41. steps:
  42. - uses: actions/checkout@v4
  43. - run: sudo apt-get update
  44. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
  45. - uses: dtolnay/rust-toolchain@stable
  46. - uses: Swatinem/rust-cache@v2
  47. with:
  48. cache-all-crates: "true"
  49. save-if: ${{ github.ref == 'refs/heads/main' }}
  50. - uses: ilammy/setup-nasm@v1
  51. - run: cargo check --all --examples --tests --all-features --all-targets
  52. test:
  53. if: github.event.pull_request.draft == false
  54. name: Test Suite
  55. runs-on: ubuntu-latest
  56. steps:
  57. - uses: actions/checkout@v4
  58. - run: sudo apt-get update
  59. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
  60. - uses: dtolnay/rust-toolchain@stable
  61. - uses: Swatinem/rust-cache@v2
  62. with:
  63. cache-all-crates: "true"
  64. save-if: ${{ github.ref == 'refs/heads/main' }}
  65. - uses: ilammy/setup-nasm@v1
  66. - uses: davidB/rust-cargo-make@v1
  67. - uses: browser-actions/setup-firefox@latest
  68. - uses: jetli/wasm-pack-action@v0.4.0
  69. - name: Free Disk Space (Ubuntu)
  70. uses: jlumbroso/free-disk-space@v1.3.1
  71. with: # speed things up a bit
  72. large-packages: false
  73. docker-images: false
  74. swap-storage: false
  75. - run: cargo make tests
  76. fmt:
  77. if: github.event.pull_request.draft == false
  78. name: Rustfmt
  79. runs-on: ubuntu-latest
  80. steps:
  81. - uses: actions/checkout@v4
  82. - uses: ilammy/setup-nasm@v1
  83. - uses: dtolnay/rust-toolchain@stable
  84. with:
  85. components: rustfmt
  86. - uses: Swatinem/rust-cache@v2
  87. with:
  88. cache-all-crates: "true"
  89. save-if: ${{ github.ref == 'refs/heads/main' }}
  90. - run: cargo fmt --all -- --check
  91. clippy:
  92. if: github.event.pull_request.draft == false
  93. name: Clippy
  94. runs-on: ubuntu-latest
  95. steps:
  96. - uses: actions/checkout@v4
  97. - run: sudo apt-get update
  98. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev
  99. - uses: ilammy/setup-nasm@v1
  100. - uses: dtolnay/rust-toolchain@stable
  101. with:
  102. components: rustfmt, clippy
  103. - uses: Swatinem/rust-cache@v2
  104. with:
  105. cache-all-crates: "true"
  106. save-if: ${{ github.ref == 'refs/heads/main' }}
  107. - run: cargo clippy --workspace --examples --tests --all-features --all-targets -- -D warnings
  108. # Only run semver checks if the PR is not a draft and does not have the breaking label
  109. # Breaking PRs don't need to follow semver since they are breaking changes
  110. # However, this means we won't attempt to backport them, so you should be careful about using this label, as it will
  111. # likely make future backporting difficult
  112. #
  113. # todo: fix this so even if breaking changes have been merged, the fix can be backported
  114. #
  115. # This will stop working once the first breaking change has been merged, so we should really try to just backport the fix
  116. # and *then* run the semver checks. Basically "would backporting this PR cause a breaking change on stable?"
  117. #
  118. # semver:
  119. # if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'breaking')
  120. # name: Semver Check
  121. # runs-on: ubuntu-latest
  122. # steps:
  123. # - uses: actions/checkout@v4
  124. # - uses: dtolnay/rust-toolchain@stable
  125. # - uses: Swatinem/rust-cache@v2
  126. # with:
  127. # cache-all-crates: "true"
  128. # save-if: ${{ github.ref == 'refs/heads/main' }}
  129. # - name: Check semver
  130. # uses: obi1kenobi/cargo-semver-checks-action@v2
  131. # with:
  132. # manifest-path: ./Cargo.toml
  133. # exclude: "dioxus-cli, dioxus-ext"
  134. playwright:
  135. if: github.event.pull_request.draft == false
  136. name: Playwright Tests
  137. runs-on: ubuntu-latest
  138. steps:
  139. # Do our best to cache the toolchain and node install steps
  140. - uses: actions/checkout@v4
  141. - uses: ilammy/setup-nasm@v1
  142. - uses: actions/setup-node@v4
  143. with:
  144. node-version: 16
  145. - name: Free Disk Space (Ubuntu)
  146. uses: jlumbroso/free-disk-space@v1.3.1
  147. with: # speed things up a bit
  148. large-packages: false
  149. docker-images: false
  150. swap-storage: false
  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/main' }}
  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.75.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.75.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.75.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.75.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. - name: Free Disk Space (Ubuntu)
  231. if: ${{ matrix.platform.os == 'ubuntu-latest' }}
  232. uses: jlumbroso/free-disk-space@v1.3.1
  233. with: # speed things up a bit
  234. large-packages: false
  235. docker-images: false
  236. swap-storage: false
  237. - uses: Swatinem/rust-cache@v2
  238. with:
  239. key: "${{ matrix.platform.target }}"
  240. cache-all-crates: "true"
  241. save-if: ${{ github.ref == 'refs/heads/main' }}
  242. - name: test
  243. run: |
  244. ${{ env.RUST_CARGO_COMMAND }} ${{ matrix.platform.command }} ${{ matrix.platform.args }} --target ${{ matrix.platform.target }}