main.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. jobs:
  31. check:
  32. if: github.event.pull_request.draft == false
  33. name: Check
  34. runs-on: ubuntu-latest
  35. steps:
  36. - uses: dtolnay/rust-toolchain@stable
  37. - uses: Swatinem/rust-cache@v2
  38. - run: sudo apt-get update
  39. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev
  40. - uses: actions/checkout@v4
  41. - run: cargo check --all --examples --tests
  42. test:
  43. if: github.event.pull_request.draft == false
  44. name: Test Suite
  45. runs-on: ubuntu-latest
  46. steps:
  47. - uses: dtolnay/rust-toolchain@stable
  48. - uses: Swatinem/rust-cache@v2
  49. - run: sudo apt-get update
  50. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev
  51. - uses: davidB/rust-cargo-make@v1
  52. - uses: browser-actions/setup-firefox@latest
  53. - uses: jetli/wasm-pack-action@v0.4.0
  54. - uses: actions/checkout@v4
  55. - run: cargo make tests
  56. fmt:
  57. if: github.event.pull_request.draft == false
  58. name: Rustfmt
  59. runs-on: ubuntu-latest
  60. steps:
  61. - uses: dtolnay/rust-toolchain@stable
  62. - uses: Swatinem/rust-cache@v2
  63. - run: rustup component add rustfmt
  64. - uses: actions/checkout@v4
  65. - run: cargo fmt --all -- --check
  66. clippy:
  67. if: github.event.pull_request.draft == false
  68. name: Clippy
  69. runs-on: ubuntu-latest
  70. steps:
  71. - uses: dtolnay/rust-toolchain@stable
  72. - uses: Swatinem/rust-cache@v2
  73. - run: sudo apt-get update
  74. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev
  75. - run: rustup component add clippy
  76. - uses: actions/checkout@v4
  77. - run: cargo clippy --workspace --examples --tests -- -D warnings
  78. matrix_test:
  79. runs-on: ${{ matrix.platform.os }}
  80. env:
  81. RUST_CARGO_COMMAND: ${{ matrix.platform.cross == true && 'cross' || 'cargo' }}
  82. strategy:
  83. matrix:
  84. platform:
  85. - {
  86. target: x86_64-pc-windows-msvc,
  87. os: windows-latest,
  88. toolchain: "1.70.0",
  89. cross: false,
  90. command: "test",
  91. args: "--all --tests",
  92. }
  93. - {
  94. target: x86_64-apple-darwin,
  95. os: macos-latest,
  96. toolchain: "1.70.0",
  97. cross: false,
  98. command: "test",
  99. args: "--all --tests",
  100. }
  101. - {
  102. target: aarch64-apple-ios,
  103. os: macos-latest,
  104. toolchain: "1.70.0",
  105. cross: false,
  106. command: "build",
  107. args: "--package dioxus-mobile",
  108. }
  109. - {
  110. target: aarch64-linux-android,
  111. os: ubuntu-latest,
  112. toolchain: "1.70.0",
  113. cross: true,
  114. command: "build",
  115. args: "--package dioxus-mobile",
  116. }
  117. steps:
  118. - name: install stable
  119. uses: dtolnay/rust-toolchain@master
  120. with:
  121. toolchain: ${{ matrix.platform.toolchain }}
  122. targets: ${{ matrix.platform.target }}
  123. - name: Install cross
  124. if: ${{ matrix.platform.cross == true }}
  125. uses: taiki-e/install-action@cross
  126. - uses: Swatinem/rust-cache@v2
  127. with:
  128. workspaces: core -> ../target
  129. save-if: ${{ matrix.features.key == 'all' }}
  130. - name: Install rustfmt
  131. run: rustup component add rustfmt
  132. - uses: actions/checkout@v4
  133. - name: test
  134. run: |
  135. ${{ env.RUST_CARGO_COMMAND }} ${{ matrix.platform.command }} ${{ matrix.platform.args }} --target ${{ matrix.platform.target }}
  136. # Coverage is disabled until we can fix it
  137. # coverage:
  138. # name: Coverage
  139. # runs-on: ubuntu-latest
  140. # container:
  141. # image: xd009642/tarpaulin:develop-nightly
  142. # options: --security-opt seccomp=unconfined
  143. # steps:
  144. # - name: Checkout repository
  145. # uses: actions/checkout@v4
  146. # - name: Generate code coverage
  147. # run: |
  148. # apt-get update &&\
  149. # apt-get install build-essential &&\
  150. # apt install libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev -y &&\
  151. # cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
  152. # - name: Upload to codecov.io
  153. # uses: codecov/codecov-action@v2
  154. # with:
  155. # fail_ci_if_error: false