]> git.lizzy.rs Git - rust.git/blob - .github/workflows/main.yml
[gh actions] Fix caching of ~/.cargo/bin
[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 target dir
30       uses: actions/cache@v1.1.2
31       with:
32         path: target
33         key: target-dir-${{ matrix.os }}-${{ hashFiles('rust-toolchain') }}
34
35     - name: Prepare dependencies
36       run: |
37         git config --global user.email "user@example.com"
38         git config --global user.name "User"
39         ./prepare.sh
40     
41     # Compile is a separate step, as the actions-rs/cargo action supports error annotations
42     - name: Compile
43       uses: actions-rs/cargo@v1.0.1
44       with:
45         command: build
46         args: --release
47     
48     - name: Test
49       run: |
50         # Enable backtraces for easier debugging
51         export RUST_BACKTRACE=1
52         
53         # Reduce amount of benchmark runs as they are slow
54         export COMPILE_RUNS=2
55         export RUN_RUNS=2
56         
57         ./test.sh --release