.github/workflows/ci.yml 2.8 K raw
1
name: CI
2
3
on:
4
  pull_request:
5
  push:
6
    branches:
7
      - main
8
      - master
9
      - develop
10
11
env:
12
  CARGO_TERM_COLOR: always
13
14
# ensure that the workflow is only triggered once per PR, subsequent pushes to the PR will cancel
15
# and restart the workflow. See https://docs.github.com/en/actions/using-jobs/using-concurrency
16
concurrency:
17
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
18
  cancel-in-progress: true
19
20
jobs:
21
  fmt:
22
    name: fmt
23
    runs-on: ubuntu-latest
24
    steps:
25
      - name: Checkout
26
        uses: actions/checkout@v4
27
      - name: Install Rust stable
28
        uses: dtolnay/rust-toolchain@stable
29
        with:
30
          components: rustfmt
31
      - name: check formatting
32
        run: cargo fmt -- --check
33
      - name: Cache Cargo dependencies
34
        uses: Swatinem/rust-cache@v2
35
  clippy:
36
    name: clippy
37
    runs-on: ubuntu-latest
38
    permissions:
39
      contents: read
40
      checks: write
41
    steps:
42
      - name: Checkout
43
        uses: actions/checkout@v4
44
      - name: Install Rust stable
45
        uses: dtolnay/rust-toolchain@stable
46
        with:
47
          components: clippy
48
      - name: Run clippy action
49
        uses: clechasseur/rs-clippy-check@v3
50
      - name: Cache Cargo dependencies
51
        uses: Swatinem/rust-cache@v2
52
  doc:
53
    # run docs generation on nightly rather than stable. This enables features like
54
    # https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an
55
    # API be documented as only available in some specific platforms.
56
    name: doc
57
    runs-on: ubuntu-latest
58
    steps:
59
      - uses: actions/checkout@v4
60
      - name: Install Rust nightly
61
        uses: dtolnay/rust-toolchain@nightly
62
      - name: Run cargo doc
63
        run: cargo doc --no-deps --all-features
64
        env:
65
          RUSTDOCFLAGS: --cfg docsrs
66
  test:
67
    runs-on: ${{ matrix.os }}
68
    name: test ${{ matrix.os }}
69
    strategy:
70
      fail-fast: false
71
      matrix:
72
        os: [macos-latest, windows-latest]
73
    steps:
74
      # if your project needs OpenSSL, uncomment this to fix Windows builds.
75
      # it's commented out by default as the install command takes 5-10m.
76
      # - run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
77
      #   if: runner.os == 'Windows'
78
      # - run: vcpkg install openssl:x64-windows-static-md
79
      #   if: runner.os == 'Windows'
80
      - uses: actions/checkout@v4
81
      - name: Install Rust
82
        uses: dtolnay/rust-toolchain@stable
83
      # enable this ci template to run regardless of whether the lockfile is checked in or not
84
      - name: cargo generate-lockfile
85
        if: hashFiles('Cargo.lock') == ''
86
        run: cargo generate-lockfile
87
      - name: cargo test --locked
88
        run: cargo test --locked --all-features --all-targets
89
      - name: Cache Cargo dependencies
90
        uses: Swatinem/rust-cache@v2