Skip to content

Commit b3598e8

Browse files
msrd0Empty2k12
andauthored
CI: Use cargo 1.84 feature to check MSRV (#160)
* CI: Use cargo 1.84 feature to check MSRV * github actions is stupid * kill the other msrv job * need to install yq * debian typo's apk as apt * apt needs sudo * add if to cache * fuck windows and mac os * Drop MSRV to 1.63 We could go lower but then we'd be at idna<1.0 and I believe that has some advisories ... * fix yaml indentation * actually we need 1.64 for workspace inheritance * whatever 1.65 it is * auto-update the rust version in the readme * fix readme * chore: update e-mail * remove obviously misleading comment I assume I thought this was necessary for the readme generation, but turns out the readme looks just fine. * Update clippy to 1.88; use fallback resolver for clippy as well * drop default resolver back down to 2 resolver 3 is only supported on Rust 1.84 and up --------- Co-authored-by: Gero Gerke <[email protected]>
1 parent 8ab0fe0 commit b3598e8

File tree

17 files changed

+173
-160
lines changed

17 files changed

+173
-160
lines changed

.github/workflows/rust.yml

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@v4
27-
- uses: dtolnay/rust-toolchain@1.75.0
27+
- uses: dtolnay/rust-toolchain@1.88.0
2828
with:
2929
components: clippy
30+
- name: Update Cargo.lock
31+
run: cargo --config 'resolver.incompatible-rust-versions="fallback"' update
3032
- name: Check Clippy lints (reqwest)
31-
run: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings
33+
run: cargo clippy --manifest-path influxdb/Cargo.toml --locked --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings
3234
- name: Check Clippy lints (surf)
33-
run: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings
35+
run: cargo clippy --manifest-path influxdb/Cargo.toml --locked --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings
3436

3537
# this checks that the code is formatted with rustfmt
3638
rustfmt:
@@ -44,20 +46,6 @@ jobs:
4446
- name: Check code formatting
4547
run: cargo fmt --all -- --check
4648

47-
# this checks the msrv
48-
msrv:
49-
name: Verify MSRV
50-
runs-on: ubuntu-latest
51-
steps:
52-
- uses: actions/checkout@v4
53-
- uses: baptiste0928/cargo-install@v3
54-
with:
55-
crate: cargo-msrv
56-
- name: Verify minimum rust version of influxdb crate
57-
run: cargo msrv --path influxdb --output-format json verify
58-
- name: Verify minimum rust version of influxdb_derive crate
59-
run: cargo msrv --path influxdb_derive --output-format json verify
60-
6149
# this tests that all unit and doc tests are successful
6250
unit_tests:
6351
name: Unit and Doc Tests (Rust ${{matrix.rust.name}} on ${{matrix.os}})
@@ -77,21 +65,51 @@ jobs:
7765
toolchain: nightly
7866
nightly: true
7967
os: [ubuntu-latest, windows-latest, macOS-latest]
68+
include:
69+
- rust:
70+
name: MSRV
71+
toolchain: stable
72+
nightly: false
73+
os: ubuntu-latest
8074
steps:
8175
- uses: actions/checkout@v4
8276
- uses: dtolnay/rust-toolchain@master
8377
with:
8478
toolchain: ${{matrix.rust.toolchain}}
8579
id: rust-toolchain
80+
- run: cargo --config 'resolver.incompatible-rust-versions="fallback"' update
81+
# on msrv runs, downgrade rust after generating the Cargo.lock file
82+
- run: sudo apt -y update && sudo apt -y install --no-install-recommends yq
83+
if: matrix.rust.name == 'MSRV'
84+
- run: echo "rust-version=$(tomlq -r '.workspace.package."rust-version"' Cargo.toml)" >>$GITHUB_OUTPUT
85+
id: msrv
86+
if: matrix.rust.name == 'MSRV'
87+
- uses: dtolnay/rust-toolchain@master
88+
with:
89+
toolchain: ${{steps.msrv.outputs.rust-version}}
90+
id: msrv-toolchain
91+
if: matrix.rust.name == 'MSRV'
92+
# on non-msrv runs, use one cache key ...
93+
- uses: actions/cache@v4
94+
with:
95+
path: |
96+
~/.cargo/git
97+
~/.cargo/registry
98+
target
99+
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}}"
100+
if: matrix.rust.name != 'MSRV'
101+
# ... and on msrv runs, use another
86102
- uses: actions/cache@v4
87103
with:
88104
path: |
89105
~/.cargo/git
90106
~/.cargo/registry
91107
target
92-
key: "${{matrix.rust.toolchain}} on ${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}}"
93-
- run: cargo test --lib
94-
- run: cargo test --doc
108+
key: "${{runner.os}} Rust ${{steps.msrv-toolchain.outputs.cachekey}}"
109+
if: matrix.rust.name == 'MSRV'
110+
# finally we can run tests
111+
- run: cargo test --lib --locked
112+
- run: cargo test --doc --locked
95113

96114
# this tests that all integration tests are successful
97115
integration_tests:

Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
[workspace]
44
members = ["influxdb", "influxdb_derive", "benches"]
5+
resolver = "2"
6+
7+
[workspace.package]
8+
authors = ["Gero Gerke <[email protected]>", "Dominic <[email protected]>"]
9+
edition = "2018"
10+
rust-version = "1.65"
11+
license = "MIT"
12+
repository = "https://github.com/influxdb-rs/influxdb-rust"
13+
14+
[workspace.lints.rust]
15+
bare_trait_objects = "forbid"
16+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin)', 'cfg(tarpaulin_include)'] }
17+
18+
[workspace.lints.clippy]
19+
multiple_bound_locations = "allow" # clippy has wrong opinions
20+
needless_doctest_main = "allow"
21+
needless_lifetimes = "allow" # False positive in client/mod.rs query fn
522

623
[patch.crates-io]
724
influxdb = { path = "./influxdb" }

README.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
<a href="https://www.rust-lang.org/en-US/">
2626
<img src="https://img.shields.io/badge/Made%20with-Rust-orange.svg" alt='Build with Rust' />
2727
</a>
28-
<a href="https://blog.rust-lang.org/2022/11/03/Rust-1.67.0.html">
29-
<img src="https://img.shields.io/badge/rustc-1.67+-yellow.svg" alt='Minimum Rust Version: 1.67' />
28+
<a href="https://github.com/rust-lang/rust/releases/tag/{{ rust_version | urlencode }}">
29+
<img src="https://img.shields.io/badge/rustc-{{ rust_version | urlencode }}+-yellow.svg" alt='Minimum Rust Version: {{ rust_version }}' />
3030
</a>
3131
</p>
3232

README.md

Lines changed: 56 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,36 @@
2525
<a href="https://www.rust-lang.org/en-US/">
2626
<img src="https://img.shields.io/badge/Made%20with-Rust-orange.svg" alt='Build with Rust' />
2727
</a>
28-
<a href="https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html">
29-
<img src="https://img.shields.io/badge/rustc-1.65+-yellow.svg" alt='Minimum Rust Version: 1.65' />
28+
<a href="https://github.com/rust-lang/rust/releases/tag/1.65.0">
29+
<img src="https://img.shields.io/badge/rustc-1.65.0+-yellow.svg" alt='Minimum Rust Version: 1.65.0' />
3030
</a>
3131
</p>
3232

3333
Pull requests are always welcome. See [Contributing][__link0] and [Code of Conduct][__link1]. For a list of past changes, see [CHANGELOG.md][__link2].
3434

35-
3635
### Currently Supported Features
3736

38-
- Reading and writing to InfluxDB
39-
- Optional Serde support for deserialization
40-
- Running multiple queries in one request (e.g. `SELECT * FROM weather_berlin; SELECT * FROM weather_london`)
41-
- Writing single or multiple measurements in one request (e.g. `WriteQuery` or `Vec<WriteQuery>` argument)
42-
- Authenticated and unauthenticated connections
43-
- `async`/`await` support
44-
- `#[derive(InfluxDbWriteable)]` derive macro for writing / reading into structs
45-
- `GROUP BY` support
46-
- Tokio and async-std support (see example below) or [available backends][__link3]
47-
- Swappable HTTP backends ([see below](#Choice-of-HTTP-backend))
48-
37+
* Reading and writing to InfluxDB
38+
* Optional Serde support for deserialization
39+
* Running multiple queries in one request (e.g. `SELECT * FROM weather_berlin; SELECT * FROM weather_london`)
40+
* Writing single or multiple measurements in one request (e.g. `WriteQuery` or `Vec<WriteQuery>` argument)
41+
* Authenticated and unauthenticated connections
42+
* `async`/`await` support
43+
* `#[derive(InfluxDbWriteable)]` derive macro for writing / reading into structs
44+
* `GROUP BY` support
45+
* Tokio and async-std support (see example below) or [available backends][__link3]
46+
* Swappable HTTP backends ([see below](#Choice-of-HTTP-backend))
4947

5048
## Quickstart
5149

5250
Add the following to your `Cargo.toml`
5351

54-
5552
```toml
5653
influxdb = { version = "0.7.2", features = ["derive"] }
5754
```
5855

5956
For an example with using Serde deserialization, please refer to [serde_integration][__link4]
6057

61-
6258
```rust
6359
use chrono::{DateTime, Utc};
6460
use influxdb::{Client, Error, InfluxDbWriteable, ReadQuery, Timestamp};
@@ -104,73 +100,62 @@ async fn main() -> Result<(), Error> {
104100
}
105101
```
106102

107-
For further examples, check out the integration tests in `tests/integration_tests.rs` in the repository.
108-
103+
For further examples, check out the integration tests in `tests/integration_tests.rs`
104+
in the repository.
109105

110106
## Choice of HTTP backend
111107

112108
To communicate with InfluxDB, you can choose the HTTP backend to be used configuring the appropriate feature. We recommend sticking with the default reqwest-based client, unless you really need async-std compatibility.
113109

114-
- **[hyper][__link5]** (through reqwest, used by default), with [rustls][__link6]
115-
```toml
116-
influxdb = { version = "0.7.2", features = ["derive"] }
117-
```
118-
119-
120-
- **[hyper][__link7]** (through reqwest), with native TLS (OpenSSL)
121-
```toml
122-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls"] }
123-
```
124-
125-
126-
- **[hyper][__link8]** (through reqwest), with vendored native TLS (OpenSSL)
127-
```toml
128-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls-vendored"] }
129-
```
130-
131-
132-
- **[hyper][__link9]** (through surf), use this if you need tokio 0.2 compatibility
133-
```toml
134-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "hyper-client"] }
135-
```
136-
137-
138-
- **[curl][__link10]**, using [libcurl][__link11]
139-
```toml
140-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "curl-client"] }
141-
```
142-
143-
144-
- **[async-h1][__link12]** with native TLS (OpenSSL)
145-
```toml
146-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client"] }
147-
```
148-
149-
150-
- **[async-h1][__link13]** with [rustls][__link14]
151-
```toml
152-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client-rustls"] }
153-
```
154-
155-
156-
- WebAssembly’s `window.fetch`, via `web-sys` and **[wasm-bindgen][__link15]**
157-
```toml
158-
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "wasm-client"] }
159-
```
160-
161-
162-
110+
* **[hyper][__link5]** (through reqwest, used by default), with [rustls][__link6]
111+
```toml
112+
influxdb = { version = "0.7.2", features = ["derive"] }
113+
```
114+
115+
* **[hyper][__link7]** (through reqwest), with native TLS (OpenSSL)
116+
```toml
117+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls"] }
118+
```
119+
120+
* **[hyper][__link8]** (through reqwest), with vendored native TLS (OpenSSL)
121+
```toml
122+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls-vendored"] }
123+
```
124+
125+
* **[hyper][__link9]** (through surf), use this if you need tokio 0.2 compatibility
126+
```toml
127+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "hyper-client"] }
128+
```
129+
130+
* **[curl][__link10]**, using [libcurl][__link11]
131+
```toml
132+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "curl-client"] }
133+
```
134+
135+
* **[async-h1][__link12]** with native TLS (OpenSSL)
136+
```toml
137+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client"] }
138+
```
139+
140+
* **[async-h1][__link13]** with [rustls][__link14]
141+
```toml
142+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client-rustls"] }
143+
```
144+
145+
* WebAssembly’s `window.fetch`, via `web-sys` and **[wasm-bindgen][__link15]**
146+
```toml
147+
influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "wasm-client"] }
148+
```
163149

164150
## License
165151

166-
[![License: MIT][__link16]][__link17]
167-
152+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)][__link16]
168153

169154

170155
@ 2020-2024 Gero Gerke, msrd0 and [contributors].
171156

172157
[contributors]: https://github.com/influxdb-rs/influxdb-rust/graphs/contributors
173-
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG_RDmlyxxvyrG0rwcLBKoYdvG5It9hbWNgjUGzjD8iBYfsFFYXKEG1LaAVLASZMqG5J2qfpyCvbMG_Rohh5BobOmG0DqLv5454SZYWSBgmhpbmZsdXhkYmUwLjcuMg
158+
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEGzJ_QpW55zB1G0S-TER-rIfLG2gXv8EYBG3jG1nuXXn-kdx-YXKEG1LaAVLASZMqG5J2qfpyCvbMG_Rohh5BobOmG0DqLv5454SZYWSBgmhpbmZsdXhkYmUwLjcuMg
174159
[__link0]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CONTRIBUTING.md
175160
[__link1]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CODE_OF_CONDUCT.md
176161
[__link10]: https://github.com/alexcrichton/curl-rust
@@ -179,8 +164,7 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu
179164
[__link13]: https://github.com/http-rs/async-h1
180165
[__link14]: https://github.com/ctz/rustls
181166
[__link15]: https://github.com/rustwasm/wasm-bindgen
182-
[__link16]: https://img.shields.io/badge/License-MIT-yellow.svg
183-
[__link17]: https://opensource.org/licenses/MIT
167+
[__link16]: https://opensource.org/licenses/MIT
184168
[__link2]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CHANGELOG.md
185169
[__link3]: https://github.com/influxdb-rs/influxdb-rust/blob/main/influxdb/Cargo.toml
186170
[__link4]: https://docs.rs/influxdb/0.7.2/influxdb/?search=integrations::serde_integration

influxdb/Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
[package]
44
name = "influxdb"
55
version = "0.7.2"
6-
authors = ["Gero Gerke <[email protected]>"]
7-
edition = "2018"
6+
authors.workspace = true
7+
edition.workspace = true
8+
rust-version.workspace = true
89
description = "InfluxDB Driver for Rust"
910
keywords = ["influxdb", "database", "influx"]
10-
license = "MIT"
11+
license.workspace = true
1112
readme = "README.md"
1213
include = ["src/**/*", "tests/**/*", "Cargo.toml", "LICENSE"]
13-
repository = "https://github.com/influxdb-rs/influxdb-rust"
14-
rust-version = "1.70"
14+
repository.workspace = true
15+
16+
[lints]
17+
workspace = true
1518

1619
[dependencies]
1720
chrono = { version = "0.4.23", features = ["serde"], default-features = false }

influxdb/src/client/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Client {
162162
.send()
163163
.await
164164
.map_err(|err| Error::ProtocolError {
165-
error: format!("{}", err),
165+
error: err.to_string(),
166166
})?;
167167

168168
const BUILD_HEADER: &str = "X-Influxdb-Build";
@@ -276,13 +276,13 @@ impl Client {
276276
let body = res.body_string();
277277

278278
let s = body.await.map_err(|_| Error::DeserializationError {
279-
error: "response could not be converted to UTF-8".to_string(),
279+
error: "response could not be converted to UTF-8".into(),
280280
})?;
281281

282282
// todo: improve error parsing without serde
283283
if s.contains("\"error\"") || s.contains("\"Error\"") {
284284
return Err(Error::DatabaseError {
285-
error: format!("influxdb error: \"{}\"", s),
285+
error: format!("influxdb error: {s:?}"),
286286
});
287287
}
288288

@@ -291,7 +291,7 @@ impl Client {
291291

292292
fn auth_if_needed(&self, rb: RequestBuilder) -> RequestBuilder {
293293
if let Some(ref token) = self.token {
294-
rb.header("Authorization", format!("Token {}", token))
294+
rb.header("Authorization", format!("Token {token}"))
295295
} else {
296296
rb
297297
}
@@ -314,7 +314,7 @@ mod tests {
314314
#[test]
315315
fn test_client_debug_redacted_password() {
316316
let client = Client::new("https://localhost:8086", "db").with_auth("user", "pass");
317-
let actual = format!("{:#?}", client);
317+
let actual = format!("{client:#?}");
318318
let expected = indoc! { r#"
319319
Client {
320320
url: "https://localhost:8086",

0 commit comments

Comments
 (0)