-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (174 loc) · 5.75 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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: CI
on:
pull_request:
branches-ignore:
- gh-pages
- dependabot/*
push:
branches-ignore:
- gh-pages
- dependabot/*
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
jobs:
tests:
name: Check code (${{ matrix.os }}, rust-${{ matrix.rust }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable, beta]
include:
- os: ubuntu-latest
sccache-path: /home/runner/.cache/sccache
- os: macos-latest
sccache-path: /Users/runner/Library/Caches/Mozilla.sccache
- os: windows-latest
sccache-path: "C:\\Users\\runner\\AppData\\Local\\Mozilla\\sccache\\cache"
env:
CARGO_INCREMENTAL: false
RUSTC_WRAPPER: sccache
RUSTV: ${{ matrix.rust }}
SCCACHE_CACHE_SIZE: 5G
SCCACHE_DIR: ${{ matrix.sccache-path }}
# SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment it back out
steps:
- name: Install sccache (ubuntu-latest)
if: matrix.os == 'ubuntu-latest'
env:
LINK: https://github.com/mozilla/sccache/releases/download
SCCACHE_VERSION: v0.2.15
run: |
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl
mkdir -p $HOME/.local/bin
curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
chmod +x $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install sccache (macos-latest)
if: matrix.os == 'macos-latest'
run: |
brew update
brew install sccache
- name: Install sccache (windows-latest)
if: matrix.os == 'windows-latest'
env:
LINK: https://github.com/mozilla/sccache/releases/download
SCCACHE_VERSION: v0.2.15
run: |
$SCCACHE_FILE = "sccache-$env:SCCACHE_VERSION-x86_64-pc-windows-msvc"
New-Item -ItemType Directory -Force $HOME/.local/bin
$TEMP_FILE = New-TemporaryFile
curl -L "$env:LINK/$env:SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" --output $TEMP_FILE
Start-Process -FilePath tar -ArgumentList "-xOzvf", "$TEMP_FILE", "*/sccache.exe" -RedirectStandardOutput "$HOME/.local/bin/sccache.exe"
echo "$HOME/.local/bin" >> $env:GITHUB_PATH
- name: Install Rust ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
components: rustfmt, clippy
- name: Checkout repo
uses: actions/checkout@v2
- name: Cache cargo registry
uses: actions/cache@v2
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Save sccache
uses: actions/cache@v2
continue-on-error: false
with:
path: ${{ matrix.sccache-path }}
key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-sccache-
- name: Start sccache server
run: sccache --start-server
- name: Build the crate
uses: actions-rs/cargo@v1
with:
command: build
- name: Test the crate
uses: actions-rs/cargo@v1
with:
command: test
- name: Print sccache stats
run: sccache --show-stats
- name: Stop sccache server
run: sccache --stop-server || true
clippy:
name: Lint code with clippy
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: clippy
- name: Checkout repo
uses: actions/checkout@v2
- name: Cache cargo registry
uses: actions/cache@v2
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: clippy-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
clippy-cargo-
- name: Run clippy with annotations
if: (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') || github.event_name == 'push'
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
- name: Run clippy manually without annotations
if: (github.event.pull_request.head.repo.full_name != github.repository || github.actor == 'dependabot[bot]') && github.event_name != 'push'
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features
format:
name: Check correct code formatting
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt
- name: Checkout repo
uses: actions/checkout@v2
- name: Cache cargo registry
uses: actions/cache@v2
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: rustfmt-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
clippy-cargo-
- name: Run format check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --check