summaryrefslogtreecommitdiffstats
path: root/.github/workflows/check.yml
blob: e13b3c35ad4bd868ab6cf480989b2cdc745cd0fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
on: [pull_request]

name: check

jobs:
  # Fast test before we kick off all the other jobs
  fast-test:
    name: Fast test
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4
      - name: Cache build files
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: fast-test-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
      - name: Install toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
      - name: Install more toolchain
        run: rustup component add rustfmt clippy
      - name: Run tests
        run: cargo clippy --all-targets -- -D warnings && cargo fmt -- --check && cargo test

  # Test, and also do other things like doctests and examples
  detailed-test:
    needs: fast-test
    name: Test main target
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4
      - name: Cache build files
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
            ~/.cargo/bin
            /tmp/cargo-install-target-dir
          key: detailed-test-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
      - name: Install toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
          components: rustfmt, clippy
      - name: Install node toolchain
        uses: actions/setup-node@v3
        with:
          node-version: "20"
          cache: "yarn"
          cache-dependency-path: compile_assets/yarn.lock
      - name: Install additional test dependencies
        env:
          CARGO_TARGET_DIR: "/tmp/cargo-install-target-dir"
        run: ./scripts/install
      - name: Run check script
        run: ./scripts/check

  # Test on all supported platforms
  test:
    needs: fast-test
    name: Test all other targets
    strategy:
      matrix:
        os:
          - ubuntu-20.04
        rust:
          - stable
          - beta
          - 1.74.0
        experimental:
          - false
        include:
          # Run a canary test on nightly that's allowed to fail
          - os: ubuntu-20.04
            rust: nightly
            experimental: true
          # Test only stable on Windows, presume we'd get same result on other
          # versions as Linux
          - os: windows-2022
            rust: stable
            experimental: false
        exclude:
          # Don't bother retesting stable linux, we did it in the comprehensive test
          - os: ubuntu-20.04
            rust: stable
            experimental: false
    runs-on: ${{ matrix.os }}
    continue-on-error: ${{ matrix.experimental }}
    steps:
      # This is required, otherwise we get files with CRLF on Windows
      # Which causes tests relying on data loaded from files to fail
      - name: Set git to use LF everywhere
        run: |
          git config --global core.autocrlf false
          git config --global core.eol lf
      - name: Checkout sources
        uses: actions/checkout@v4
      - name: Cache build files
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: test-${{ matrix.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.toml') }}
      - name: Install toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}
      - name: Run tests
        run: cargo test