-
Notifications
You must be signed in to change notification settings - Fork 2
208 lines (177 loc) · 6.38 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: Continuous integration
on:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 # Fail cache download after 2 minutes.
jobs:
build:
name: Build on ${{ matrix.target }}
strategy:
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
cache: false # caching requires a go.sum file, which we don't have in our project
- uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1
with:
toolchain: stable
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
shared-key: ${{ matrix.target }}
# Always save the build artifacts to the cache to speed up builds of additional
# commits added to an already-opened pull request.
# save-if: ${{ github.ref == 'refs/heads/main' }}
- run: cargo build --workspace --all-features --all-targets --target=${{ matrix.target }}
test:
name: Test on ${{ matrix.target }}
runs-on: ${{ matrix.os }}
needs:
- build
strategy:
fail-fast: false
matrix:
include:
- target: "x86_64-apple-darwin"
os: macos-latest
- target: "x86_64-pc-windows-msvc"
os: windows-latest
- target: "x86_64-unknown-linux-gnu"
os: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
cache: false # caching requires a go.sum file, which we don't have in our project
- uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1
with:
toolchain: stable
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
shared-key: ${{ matrix.target }}
save-if: false
- name: Run all tests
run: cargo test --all-features --target=${{ matrix.target }}
# - name: Check if we compile without any features activated
# run: cargo build --package ${{ matrix.crate }} --no-default-features
#
# - name: Check if crate has been released
# id: check-released
# run: |
# RESPONSE_CODE=$(curl https://crates.io/api/v1/crates/${{ matrix.crate }} --silent --write-out "%{http_code}" --output /dev/null)
# echo "code=${RESPONSE_CODE}"
# echo "code=${RESPONSE_CODE}" >> $GITHUB_OUTPUT
#
# - name: Check public API for semver violations
# if: steps.check-released.outputs.code == 200 # Workaround until https://github.com/obi1kenobi/cargo-semver-check/issues/146 is shipped.
# run: |
# wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.17.1/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin
# cargo semver-checks check-release -p ${{ matrix.crate }}
check-rustdoc-links:
name: Check rustdoc intra-doc links
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
cache: false # caching requires a go.sum file, which we don't have in our project
- uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
shared-key: "x86_64-unknown-linux-gnu"
save-if: false
- name: Check rustdoc links
run: RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links --deny warnings" cargo doc --verbose --workspace --no-deps --all-features --document-private-items
clippy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1
with:
toolchain: stable
components: clippy
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
shared-key: "x86_64-unknown-linux-gnu"
save-if: false
- name: Run cargo clippy
run: cargo custom-clippy # cargo alias to allow reuse of config locally
rustfmt:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
cache: false # caching requires a go.sum file, which we don't have in our project
- uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1
with:
toolchain: stable
components: rustfmt
- name: Check formatting
run: cargo fmt -- --check
prettier-check:
name: Check formatting (Prettier)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actionsx/prettier@3d9f7c3fa44c9cb819e68292a328d7f4384be206 # latest
with:
# prettier CLI arguments.
args: --check .
validate_pr_title:
name: Validate PR title
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f # v5.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed (newline delimited).
types: |
feat
fix
chore
docs
deps
test
ci
refactor
requireScope: false
- name: Check PR title length
env:
TITLE: ${{ github.event.pull_request.title }}
run: |
title_length=${#TITLE}
if [ $title_length -gt 72 ]
then
echo "PR title is too long (greater than 72 characters)"
exit 1
fi