-
Notifications
You must be signed in to change notification settings - Fork 10
179 lines (167 loc) · 5.32 KB
/
ci.yaml
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
179
name: ci
on:
pull_request:
branches:
- "*"
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cargo-cache.outputs.cache-primary-key }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Restore Cargo Cache
id: cargo-cache
uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
# We can do this now because we use specific verison and update with Dependabot
# but if we make the deps any less specifc, we'll have to fix
key: ${{ runner.os }}-deps-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/*.rs') }}
# start from the previous set of cached dependencies
restore-keys: |
${{ runner.os }}-deps-${{ hashFiles('**/Cargo.toml') }}-
${{ runner.os }}-deps-
- name: Check
run: cargo check --workspace --tests --examples --benches
- name: Build
run: cargo build --workspace --tests --examples --benches
# Always update the cache
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save Cargo Cache
uses: actions/cache/save@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ steps.cargo-cache.outputs.cache-primary-key }}
lint:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Restore Check Deps
id: cache-build-deps-restore
uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ needs.build.outputs.cache-key }}
- name: Format
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy -- -D warnings
test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Restore Check Deps
id: cache-build-deps-restore
uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ needs.build.outputs.cache-key }}
- name: Run tests
run: cargo test --verbose
e2e:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Restore Check Deps
id: cache-build-deps-restore
uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ needs.build.outputs.cache-key }}
- name: Run simple example
run: RUST_BACKTRACE=1 cargo run --example simple
- name: Run dump example
run: RUST_BACKTRACE=1 cargo run --example dump
# benchmarks were not being done in --release mode, we can enable this again later
# - name: Run benchmark example
# run: RUST_BACKTRACE=1 cargo run --example benchmark -- --nbatch 100 --batch-size 1000
- name: Run rev example
run: RUST_BACKTRACE=1 cargo run --example rev
docs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Restore Check Deps
id: cache-build-deps-restore
uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ needs.build.outputs.cache-key }}
- name: Lint intra docs links
run: cargo rustdoc -p firewood --lib -- -D rustdoc::broken-intra-doc-links
- name: Lint missing crate-level docs
run: cargo rustdoc -p firewood --lib -- -D rustdoc::missing-crate-level-docs