main.yml 5.0 KB

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