arnaucube
arnaucube/sonobePublic Self-hosted repository
sonobe/.github/workflows/ci.yml
.github/workflows/ci.ymlRaw
 1name: CI Check
 2on:
 3  merge_group:
 4  pull_request:
 5  push:
 6    branches:
 7      - main
 8env:
 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
30# Jobs launched for a PR event cancel the ongoing one for the same workflow + PR,
31# Only retries (of the same run) for a Push event cancel the prior one.
32concurrency:
33  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
34  cancel-in-progress: true
35  
36
37jobs:
38  test:
39    if: github.event.pull_request.draft == false
40    name: Test
41    runs-on: ubuntu-latest
42    strategy:
43      matrix:
44        include:
45          - feature: default
46    steps:
47      - uses: actions/checkout@v2
48      - uses: actions-rs/toolchain@v1
49      # use the more efficient nextest
50      - uses: taiki-e/install-action@nextest
51      - uses: Swatinem/rust-cache@v2
52      - name: Build
53        # This build will be reused by nextest,
54        # and also checks (--all-targets) that benches don't bit-rot
55        run: cargo build --release --all-targets --no-default-features --features "${{ matrix.feature }}"
56      - name: Test
57        run: |
58          cargo nextest run --profile ci --release --workspace --no-default-features --features "${{ matrix.feature }}"          
59      - name: Doctests # nextest does not support doc tests
60        run: |
61          cargo test --doc          
62
63  fmt:
64    if: github.event.pull_request.draft == false
65    name: Rustfmt
66    timeout-minutes: 30
67    runs-on: ubuntu-latest
68    steps:
69      - uses: actions/checkout@v2
70      - uses: actions-rs/toolchain@v1
71      - uses: Swatinem/rust-cache@v2
72      - run: rustup component add rustfmt
73      - uses: actions-rs/cargo@v1
74        with:
75          command: fmt
76          args: --all -- --check
77
78  clippy:
79    if: github.event.pull_request.draft == false
80    name: Clippy lint checks
81    runs-on: ubuntu-latest
82    steps:
83      - uses: actions/checkout@v2
84      - uses: actions-rs/toolchain@v1
85        with:
86          components: clippy
87      - uses: Swatinem/rust-cache@v2
88      - name: Run clippy
89        uses: actions-rs/cargo@v1
90        with:
91          command: clippy
92          args: --all-targets --all-features -- -D warnings