main.yml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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 --all-features --all-targets
  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. - name: Free Disk Space (Ubuntu)
  67. uses: jlumbroso/free-disk-space@v1.3.1
  68. with: # speed things up a bit
  69. large-packages: false
  70. docker-images: false
  71. swap-storage: false
  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 --all-features --all-targets -- -D warnings
  105. playwright:
  106. if: github.event.pull_request.draft == false
  107. name: Playwright Tests
  108. runs-on: ubuntu-latest
  109. steps:
  110. # Do our best to cache the toolchain and node install steps
  111. - uses: actions/checkout@v4
  112. - uses: ilammy/setup-nasm@v1
  113. - uses: actions/setup-node@v4
  114. with:
  115. node-version: 16
  116. - name: Free Disk Space (Ubuntu)
  117. uses: jlumbroso/free-disk-space@v1.3.1
  118. with: # speed things up a bit
  119. large-packages: false
  120. docker-images: false
  121. swap-storage: false
  122. - name: Install Rust
  123. uses: dtolnay/rust-toolchain@master
  124. with:
  125. toolchain: stable
  126. targets: x86_64-unknown-linux-gnu,wasm32-unknown-unknown
  127. - uses: Swatinem/rust-cache@v2
  128. with:
  129. cache-all-crates: "true"
  130. save-if: ${{ github.ref == 'refs/heads/master' }}
  131. - name: Install dependencies
  132. run: npm ci
  133. working-directory: ./packages/playwright-tests
  134. - name: Install Playwright
  135. run: npm install -D @playwright/test
  136. working-directory: ./packages/playwright-tests
  137. - name: Install Playwright Browsers
  138. run: npx playwright install --with-deps
  139. working-directory: ./packages/playwright-tests
  140. - name: Run Playwright tests
  141. run: npx playwright test
  142. working-directory: ./packages/playwright-tests
  143. - uses: actions/upload-artifact@v4
  144. if: always()
  145. with:
  146. name: playwright-report
  147. path: playwright-report/
  148. retention-days: 30
  149. matrix_test:
  150. runs-on: ${{ matrix.platform.os }}
  151. if: github.event.pull_request.draft == false
  152. env:
  153. RUST_CARGO_COMMAND: ${{ matrix.platform.cross == true && 'cross' || 'cargo' }}
  154. strategy:
  155. matrix:
  156. platform:
  157. - {
  158. target: x86_64-pc-windows-msvc,
  159. os: windows-latest,
  160. toolchain: "1.75.0",
  161. cross: false,
  162. command: "test",
  163. args: "--all --tests",
  164. }
  165. - {
  166. target: x86_64-apple-darwin,
  167. os: macos-latest,
  168. toolchain: "1.75.0",
  169. cross: false,
  170. command: "test",
  171. args: "--all --tests",
  172. }
  173. - {
  174. target: aarch64-apple-ios,
  175. os: macos-latest,
  176. toolchain: "1.75.0",
  177. cross: false,
  178. command: "build",
  179. args: "--package dioxus-mobile",
  180. }
  181. - {
  182. target: aarch64-linux-android,
  183. os: ubuntu-latest,
  184. toolchain: "1.75.0",
  185. cross: true,
  186. command: "build",
  187. args: "--package dioxus-mobile",
  188. }
  189. steps:
  190. - uses: actions/checkout@v4
  191. - uses: ilammy/setup-nasm@v1
  192. - name: install stable
  193. uses: dtolnay/rust-toolchain@master
  194. with:
  195. toolchain: ${{ matrix.platform.toolchain }}
  196. targets: ${{ matrix.platform.target }}
  197. components: rustfmt
  198. - name: Install cross
  199. if: ${{ matrix.platform.cross == true }}
  200. uses: taiki-e/install-action@cross
  201. - name: Free Disk Space (Ubuntu)
  202. if: ${{ matrix.platform.os == 'ubuntu-latest' }}
  203. uses: jlumbroso/free-disk-space@v1.3.1
  204. with: # speed things up a bit
  205. large-packages: false
  206. docker-images: false
  207. swap-storage: false
  208. - uses: Swatinem/rust-cache@v2
  209. with:
  210. key: "${{ matrix.platform.target }}"
  211. cache-all-crates: "true"
  212. save-if: ${{ github.ref == 'refs/heads/master' }}
  213. - name: test
  214. run: |
  215. ${{ env.RUST_CARGO_COMMAND }} ${{ matrix.platform.command }} ${{ matrix.platform.args }} --target ${{ matrix.platform.target }}
  216. # Coverage is disabled until we can fix it
  217. # coverage:
  218. # name: Coverage
  219. # runs-on: ubuntu-latest
  220. # container:
  221. # image: xd009642/tarpaulin:develop-nightly
  222. # options: --security-opt seccomp=unconfined
  223. # steps:
  224. # - name: Checkout repository
  225. # uses: actions/checkout@v4
  226. # - name: Generate code coverage
  227. # run: |
  228. # apt-get update &&\
  229. # apt-get install build-essential &&\
  230. # apt install libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev -y &&\
  231. # cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
  232. # - name: Upload to codecov.io
  233. # uses: codecov/codecov-action@v2
  234. # with:
  235. # fail_ci_if_error: false