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.

100 lines
3.4 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: Download Circom
  50. run: |
  51. mkdir -p $HOME/bin
  52. curl -sSfL https://github.com/iden3/circom/releases/download/v2.1.6/circom-linux-amd64 -o $HOME/bin/circom
  53. chmod +x $HOME/bin/circom
  54. echo "$HOME/bin" >> $GITHUB_PATH
  55. - name: Execute compile.sh to generate .r1cs and .wasm from .circom
  56. run: bash ./src/frontend/circom/test_folder/compile.sh
  57. - name: Build
  58. # This build will be reused by nextest,
  59. # and also checks (--all-targets) that benches don't bit-rot
  60. run: cargo build --release --all-targets --no-default-features --features "${{ matrix.feature }}"
  61. - name: Test
  62. run: |
  63. cargo nextest run --profile ci --release --workspace --no-default-features --features "${{ matrix.feature }}"
  64. - name: Doctests # nextest does not support doc tests
  65. run: |
  66. cargo test --doc
  67. fmt:
  68. if: github.event.pull_request.draft == false
  69. name: Rustfmt
  70. timeout-minutes: 30
  71. runs-on: ubuntu-latest
  72. steps:
  73. - uses: actions/checkout@v2
  74. - uses: actions-rs/toolchain@v1
  75. - uses: Swatinem/rust-cache@v2
  76. - run: rustup component add rustfmt
  77. - uses: actions-rs/cargo@v1
  78. with:
  79. command: fmt
  80. args: --all -- --check
  81. clippy:
  82. if: github.event.pull_request.draft == false
  83. name: Clippy lint checks
  84. runs-on: ubuntu-latest
  85. steps:
  86. - uses: actions/checkout@v2
  87. - uses: actions-rs/toolchain@v1
  88. with:
  89. components: clippy
  90. - uses: Swatinem/rust-cache@v2
  91. - name: Run clippy
  92. uses: actions-rs/cargo@v1
  93. with:
  94. command: clippy
  95. args: --all-targets --all-features -- -D warnings