xref: /webrtc/.github/workflows/cargo.yml (revision e2bbf745)
1name: cargo
2
3on:
4  push:
5    branches: [master]
6  pull_request:
7    branches: [master]
8
9concurrency:
10  group: ${{ github.workflow }}-${{ github.ref }}
11  cancel-in-progress: true
12
13env:
14  CARGO_TERM_COLOR: always
15
16jobs:
17  test:
18    name: Test
19    strategy:
20      matrix:
21        os: ["ubuntu-latest", "macos-latest"]
22        toolchain:
23          - 1.65.0 # min supported version (https://github.com/webrtc-rs/webrtc/#toolchain)
24          - stable
25    runs-on: ${{ matrix.os }}
26    steps:
27      - uses: actions/checkout@v3
28      - name: Install Rust ${{ matrix.toolchain }}
29        uses: actions-rs/toolchain@v1
30        with:
31          toolchain: ${{ matrix.toolchain }}
32          override: true
33      - name: Install Rust
34        run: rustup update stable
35      - name: �� Cache cargo registry
36        uses: actions/cache@v3
37        with:
38          path: ~/.cargo/registry
39          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
40          restore-keys: |
41            ${{ runner.os }}-cargo-registry-
42      - uses: actions-rs/toolchain@v1
43        with:
44          toolchain: ${{ matrix.toolchain }}
45          profile: minimal
46          override: true
47      - name: �� Cache dependencies
48        uses: Swatinem/rust-cache@v2
49      - name: Test
50        run: cargo test --features metrics
51
52  test_windows:
53    name: Test (windows)
54    strategy:
55      matrix:
56        toolchain:
57          - 1.63.0 # min supported version (https://github.com/webrtc-rs/webrtc/#toolchain)
58          - stable
59    runs-on: windows-latest
60    steps:
61      - uses: actions/checkout@v3
62      - name: Install Rust ${{ matrix.toolchain }}
63        uses: actions-rs/toolchain@v1
64        with:
65          toolchain: ${{ matrix.toolchain }}
66          override: true
67      - name: Install Rust
68        run: rustup update stable
69      - name: �� Cache cargo registry
70        uses: actions/cache@v3
71        with:
72          path: ~/.cargo/registry
73          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
74          restore-keys: |
75            ${{ runner.os }}-cargo-registry-
76      - uses: actions-rs/toolchain@v1
77        with:
78          toolchain: ${{ matrix.toolchain }}
79          profile: minimal
80          override: true
81      - name: Copy to C drive
82        run: cp D:\a C:\ -Recurse
83      # - name: �� Cache dependencies
84      #   uses: Swatinem/rust-cache@v2
85      - name: Test
86        working-directory: "C:\\a\\webrtc\\webrtc"
87        run: cargo test --features metrics
88
89  rustfmt_and_clippy:
90    name: Check formatting style and run clippy
91    runs-on: ubuntu-latest
92    steps:
93      - uses: actions/checkout@v3
94      - uses: actions-rs/toolchain@v1
95        with:
96          toolchain: stable
97          profile: minimal
98          components: clippy, rustfmt
99          override: true
100      - name: �� Cache cargo registry
101        uses: actions/cache@v3
102        with:
103          path: ~/.cargo/registry
104          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
105          restore-keys: |
106            ${{ runner.os }}-cargo-registry-
107      - name: �� Run clippy
108        uses: actions-rs/cargo@v1
109        with:
110          command: clippy
111          args: --workspace --all-targets --all-features --all -- -D warnings
112      - name: �� Check formatting
113        uses: actions-rs/cargo@v1
114        with:
115          command: fmt
116          args: --all -- --check
117
118  minimal_versions:
119    name: Compile and test with minimal versions
120    runs-on: ubuntu-latest
121    steps:
122      - uses: actions/checkout@v3
123      - name: �� Install latest nightly
124        uses: actions-rs/toolchain@v1
125        with:
126          toolchain: nightly
127          override: true
128      - uses: taiki-e/install-action@cargo-hack
129      - uses: taiki-e/install-action@cargo-minimal-versions
130      - run: cargo minimal-versions check --workspace --all-features --ignore-private -v
131      - run: cargo minimal-versions build --workspace --all-features --ignore-private -v
132      - run: cargo minimal-versions test --workspace --all-features -v
133