]> git.lizzy.rs Git - rust.git/blob - .github/workflows/main.yml
[gh actions] Cache cargo registry and index
[rust.git] / .github / workflows / main.yml
1 name: CI
2
3 on:
4   - push
5   - pull_request
6
7 jobs:
8   build:
9     runs-on: ${{ matrix.os }}
10
11     strategy:
12       fail-fast: false
13       matrix:
14         os: [ubuntu-latest, macos-latest]
15
16     steps:
17     - uses: actions/checkout@v2
18     
19     # https://github.com/actions/cache/issues/133
20     - name: Fixup owner of ~/.cargo/bin
21       run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/bin
22     
23     - name: Cache cargo installed crates
24       uses: actions/cache@v1.1.2
25       with:
26         path: ~/.cargo/bin
27         key: cargo-installed-crates-${{ matrix.os }}
28
29     - name: Cache cargo registry
30       uses: actions/cache@v1
31       with:
32         path: ~/.cargo/registry
33         key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
34
35     - name: Cache cargo index
36       uses: actions/cache@v1
37       with:
38         path: ~/.cargo/git
39         key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
40
41     - name: Cache cargo target dir
42       uses: actions/cache@v1.1.2
43       with:
44         path: target
45         key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain') }}
46
47     - name: Prepare dependencies
48       run: |
49         git config --global user.email "user@example.com"
50         git config --global user.name "User"
51         ./prepare.sh
52     
53     # Compile is a separate step, as the actions-rs/cargo action supports error annotations
54     - name: Compile
55       uses: actions-rs/cargo@v1.0.1
56       with:
57         command: build
58         args: --release
59     
60     - name: Test
61       run: |
62         # Enable backtraces for easier debugging
63         export RUST_BACKTRACE=1
64         
65         # Reduce amount of benchmark runs as they are slow
66         export COMPILE_RUNS=2
67         export RUN_RUNS=2
68         
69         ./test.sh --release