You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.0 KiB

  1. name: CI Check
  2. on:
  3. merge_group:
  4. pull_request:
  5. push:
  6. branches:
  7. - main
  8. env:
  9. CARGO_TERM_COLOR: always
  10. # Disable incremental compilation.
  11. #
  12. # Incremental compilation is useful as part of an edit-build-test-edit cycle,
  13. # as it lets the compiler avoid recompiling code that hasn't changed. However,
  14. # on CI, we're not making small edits; we're almost always building the entire
  15. # project from scratch. Thus, incremental compilation on CI actually
  16. # introduces *additional* overhead to support making future builds
  17. # faster...but no future builds will ever occur in any given CI environment.
  18. #
  19. # See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
  20. # for details.
  21. CARGO_INCREMENTAL: 0
  22. # Allow more retries for network requests in cargo (downloading crates) and
  23. # rustup (installing toolchains). This should help to reduce flaky CI failures
  24. # from transient network timeouts or other issues.
  25. CARGO_NET_RETRY: 10
  26. RUSTUP_MAX_RETRIES: 10
  27. # Don't emit giant backtraces in the CI logs.
  28. RUST_BACKTRACE: short
  29. # Jobs launched for a PR event cancel the ongoing one for the same workflow + PR,
  30. # Only retries (of the same run) for a Push event cancel the prior one.
  31. concurrency:
  32. group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  33. cancel-in-progress: true
  34. jobs:
  35. test:
  36. if: github.event.pull_request.draft == false
  37. name: Test
  38. runs-on: ubuntu-latest
  39. strategy:
  40. matrix:
  41. include:
  42. - feature: default
  43. steps:
  44. - uses: actions/checkout@v2
  45. - uses: actions-rs/toolchain@v1
  46. # use the more efficient nextest
  47. - uses: taiki-e/install-action@nextest
  48. - uses: Swatinem/rust-cache@v2
  49. - name: Build
  50. # This build will be reused by nextest,
  51. # and also checks (--all-targets) that benches don't bit-rot
  52. run: cargo build --release --all-targets --no-default-features --features "${{ matrix.feature }}"
  53. - name: Test
  54. run: |
  55. cargo nextest run --profile ci --release --workspace --no-default-features --features "${{ matrix.feature }}"
  56. - name: Doctests # nextest does not support doc tests
  57. run: |
  58. cargo test --doc
  59. fmt:
  60. if: github.event.pull_request.draft == false
  61. name: Rustfmt
  62. timeout-minutes: 30
  63. runs-on: ubuntu-latest
  64. steps:
  65. - uses: actions/checkout@v2
  66. - uses: actions-rs/toolchain@v1
  67. - uses: Swatinem/rust-cache@v2
  68. - run: rustup component add rustfmt
  69. - uses: actions-rs/cargo@v1
  70. with:
  71. command: fmt
  72. args: --all -- --check
  73. clippy:
  74. if: github.event.pull_request.draft == false
  75. name: Clippy lint checks
  76. runs-on: ubuntu-latest
  77. steps:
  78. - uses: actions/checkout@v2
  79. - uses: actions-rs/toolchain@v1
  80. with:
  81. components: clippy
  82. - uses: Swatinem/rust-cache@v2
  83. - name: Run clippy
  84. uses: actions-rs/cargo@v1
  85. with:
  86. command: clippy
  87. args: --all-targets --all-features -- -D warnings