-
Notifications
You must be signed in to change notification settings - Fork 79
232 lines (222 loc) · 7.29 KB
/
rust.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
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Rust
on:
push:
branches:
- main
pull_request:
jobs:
# this checks that the readme created from rustdoc is up to date
readmecheck:
name: README Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker://ghcr.io/msrd0/cargo-doc2readme:nightly
with:
entrypoint: cargo
args: doc2readme -p influxdb --expand-macros --check
# this checks that there are no clippy lints
clippy:
name: Style Check (clippy)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/[email protected]
with:
components: clippy
- name: Check Clippy lints (reqwest)
run: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings
- name: Check Clippy lints (surf)
run: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings
# this checks that the code is formatted with rustfmt
rustfmt:
name: Style Checks (rustfmt)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Check code formatting
run: cargo fmt --all -- --check
# this tests that all unit and doc tests are successful
unit_tests:
name: Unit and Doc Tests (Rust ${{matrix.rust.name}} on ${{matrix.os}})
runs-on: ${{matrix.os}}
continue-on-error: ${{matrix.rust.nightly}}
strategy:
fail-fast: false
matrix:
rust:
- name: MSRV
toolchain: "1.65"
nightly: false
- name: Stable
toolchain: stable
nightly: false
- name: Beta
toolchain: beta
nightly: false
- name: Nightly
toolchain: nightly
nightly: true
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust.toolchain}}
id: rust-toolchain
- uses: actions/cache@v4
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}}"
- run: cargo test --lib
- run: cargo test --doc
# this tests that all integration tests are successful
integration_tests:
name: Integration Tests (Rust ${{matrix.rust.name}} with ${{matrix.http-backend}})
runs-on: ubuntu-latest
continue-on-error: ${{matrix.rust.nightly}}
strategy:
fail-fast: false
matrix:
rust:
- name: Stable
toolchain: stable
nightly: false
http-backend:
- curl-client
- h1-client
- h1-client-rustls
- hyper-client
- reqwest-client-rustls
- reqwest-client-native-tls
- reqwest-client-native-tls-vendored
services:
influxdb:
image: influxdb:1.8
ports:
- 8086:8086
authed_influxdb:
image: influxdb:1.8
ports:
- 9086:8086
env:
INFLUXDB_HTTP_AUTH_ENABLED: true
INFLUXDB_ADMIN_USER: admin
INFLUXDB_ADMIN_PASSWORD: password
INFLUXDB_USER: nopriv_user
INFLUXDB_USER_PASSWORD: password
influxdbv2:
image: influxdb:2.6
ports:
- 2086:8086
env:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME: admin
DOCKER_INFLUXDB_INIT_PASSWORD: password
DOCKER_INFLUXDB_INIT_ORG: testing
DOCKER_INFLUXDB_INIT_BUCKET: mydb
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: admintoken
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust.toolchain}}
id: rust-toolchain
- uses: actions/cache@v4
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}}"
- name: Run tests
run: |
for test in integration_tests{,_v2}
do
cargo test -p influxdb --no-default-features --features 'serde derive ${{matrix.http-backend}}' --no-fail-fast --test $test
done
# this uses cargo-tarpaulin to inspect the code coverage
coverage:
name: Code Coverage (stable/ubuntu-latest)
runs-on: ubuntu-latest
services:
influxdb:
image: influxdb:1.8
ports:
- 8086:8086
authed_influxdb:
image: influxdb:1.8
ports:
- 9086:8086
env:
INFLUXDB_HTTP_AUTH_ENABLED: true
INFLUXDB_ADMIN_USER: admin
INFLUXDB_ADMIN_PASSWORD: password
INFLUXDB_USER: nopriv_user
INFLUXDB_USER_PASSWORD: password
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
- name: Get Tarpaulin Version
id: tarpaulin-version
run: echo "version=$(wget -qO- 'https://crates.io/api/v1/crates/cargo-tarpaulin' | jq -r '.crate.max_stable_version')" >>$GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/cargo-tarpaulin
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-version.outputs.version}} tarpaulin ${{steps.tarpaulin-version.outputs.version}}"
- name: Install Tarpaulin
run: |
ls -lh ~/.cargo/bin
test -e ~/.cargo/bin/cargo-tarpaulin || cargo install cargo-tarpaulin --version ${{steps.tarpaulin-version.outputs.version}}
- name: Run Tarpaulin coverage tests
run: |
cargo tarpaulin -v \
--target-dir target/tarpaulin \
--workspace \
--features serde,derive \
--exclude-files 'derive/*' \
--exclude-files 'target/*' \
--ignore-panics --ignore-tests \
--out Html --out Json
env:
RUST_BACKTRACE: 1
RUST_LOG: info
- uses: actions/upload-artifact@v4
with:
name: tarpaulin-report
path: |
tarpaulin-report.json
tarpaulin-report.html
# this uploads the code coverage to github pages
pages:
runs-on: ubuntu-latest
needs:
- coverage
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
- uses: actions/download-artifact@v4
with:
name: tarpaulin-report
- run: |
coverage=$(jq '.files | { covered: map(.covered) | add, coverable: map(.coverable) | add } | .covered / .coverable * 10000 | round | . / 100' tarpaulin-report.json)
color=$([[ $coverage < 80 ]] && printf yellow || printf brightgreen)
wget -qO coverage.svg "https://img.shields.io/badge/coverage-$coverage%25-$color"
git add coverage.svg tarpaulin-report.html
git status
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "GitHub Pages for ${{ github.sha }}"