This repository has been archived by the owner on Jan 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
94 lines (80 loc) · 2.74 KB
/
ci.yml
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
name: CI
on:
push:
branches:
- master
pull_request:
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Cleanup pre-installed Rust toolchains
# The pre-installed toolchain is under root permission, and this would
# make tarball fail to extract. Here we remove the symlink and install
# our own Rust toolchain if necessary.
run: |
which rustup
which cargo
if [[ -L "$HOME/.cargo" && -L "$HOME/.rustup" ]]; then
rm -v "$HOME/.rustup"
rm -v "$HOME/.cargo"
fi
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Cache rustup
uses: actions/cache@v1
with:
path: ~/.rustup
key: ${{ runner.os }}-rustup-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rustup-
- name: Cache cargo binaries
uses: actions/cache@v1
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-bin-
- name: Cache cargo registry cache
uses: actions/cache@v1
with:
path: ~/.cargo/registry/cache
key: ${{ runner.os }}-cargo-registry-cache-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-cache-
- name: Cache cargo registry index
uses: actions/cache@v1
with:
path: ~/.cargo/registry/index
key: ${{ runner.os }}-cargo-registry-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-index-
- name: Cache cargo git db
uses: actions/cache@v1
with:
path: ~/.cargo/git/db
key: ${{ runner.os }}-cargo-git-db-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-git-db-
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-target-
- name: Install stable Rust
run: |
if [[ ! -d "$HOME/.cargo" || ! -d "$HOME/.rustup" ]]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
sh rustup-init.sh -y --default-toolchain none
fi
rustup update stable
rustup default stable
- name: Test and build
run: |
cargo test --verbose
cargo build --verbose
- name: Lint
run: cargo fmt -- --check # TODO: add clippy