Skip to content

Commit e15c9b1

Browse files
authored
Merge pull request sfackler#749 from sfackler/actions
Switch CI to github actions
2 parents 7da21e1 + ead071b commit e15c9b1

File tree

7 files changed

+97
-62
lines changed

7 files changed

+97
-62
lines changed

.circleci/config.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
env:
12+
RUSTFLAGS: -Dwarnings
13+
RUST_BACKTRACE: 1
14+
15+
jobs:
16+
rustfmt:
17+
name: rustfmt
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: sfackler/actions/rustup@master
22+
- uses: sfackler/actions/rustfmt@master
23+
24+
clippy:
25+
name: clippy
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v2
29+
- uses: sfackler/actions/rustup@master
30+
- run: echo "::set-output name=version::$(rustc --version)"
31+
id: rust-version
32+
- uses: actions/cache@v1
33+
with:
34+
path: ~/.cargo/registry/index
35+
key: index-${{ runner.os }}-${{ github.run_number }}
36+
restore-keys: |
37+
index-${{ runner.os }}-
38+
- run: cargo generate-lockfile
39+
- uses: actions/cache@v1
40+
with:
41+
path: ~/.cargo/registry/cache
42+
key: registry-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
43+
- run: cargo fetch
44+
- uses: actions/cache@v1
45+
with:
46+
path: target
47+
key: clippy-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}y
48+
- run: cargo clippy --all --all-targets
49+
50+
test:
51+
name: test
52+
runs-on: ubuntu-latest
53+
services:
54+
postgres:
55+
image: sfackler/rust-postgres-test:6
56+
ports:
57+
- 5433:5433
58+
steps:
59+
- uses: actions/checkout@v2
60+
- uses: sfackler/actions/rustup@master
61+
with:
62+
version: 1.45.0
63+
- run: echo "::set-output name=version::$(rustc --version)"
64+
id: rust-version
65+
- uses: actions/cache@v1
66+
with:
67+
path: ~/.cargo/registry/index
68+
key: index-${{ runner.os }}-${{ github.run_number }}
69+
restore-keys: |
70+
index-${{ runner.os }}-
71+
- run: cargo generate-lockfile
72+
- uses: actions/cache@v1
73+
with:
74+
path: ~/.cargo/registry/cache
75+
key: registry-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
76+
- run: cargo fetch
77+
- uses: actions/cache@v1
78+
with:
79+
path: target
80+
key: test-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}y
81+
- run: cargo test --all
82+
- run: cargo test --manifest-path tokio-postgres/Cargo.toml --no-default-features
83+
- run: cargo test --manifest-path tokio-postgres/Cargo.toml --all-features

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Rust-Postgres
2-
[![CircleCI](https://circleci.com/gh/sfackler/rust-postgres.svg?style=shield)](https://circleci.com/gh/sfackler/rust-postgres)
32

43
PostgreSQL support for Rust.
54

postgres-protocol/src/types/mod.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ fn write_pascal_string(s: &str, buf: &mut BytesMut) -> Result<(), StdBox<dyn Err
231231

232232
/// Deserializes an `HSTORE` value.
233233
#[inline]
234-
pub fn hstore_from_sql<'a>(
235-
mut buf: &'a [u8],
236-
) -> Result<HstoreEntries<'a>, StdBox<dyn Error + Sync + Send>> {
234+
pub fn hstore_from_sql(
235+
mut buf: &[u8],
236+
) -> Result<HstoreEntries<'_>, StdBox<dyn Error + Sync + Send>> {
237237
let count = buf.read_i32::<BigEndian>()?;
238238
if count < 0 {
239239
return Err("invalid entry count".into());
@@ -319,9 +319,7 @@ where
319319

320320
/// Deserializes a `VARBIT` or `BIT` value.
321321
#[inline]
322-
pub fn varbit_from_sql<'a>(
323-
mut buf: &'a [u8],
324-
) -> Result<Varbit<'a>, StdBox<dyn Error + Sync + Send>> {
322+
pub fn varbit_from_sql(mut buf: &[u8]) -> Result<Varbit<'_>, StdBox<dyn Error + Sync + Send>> {
325323
let len = buf.read_i32::<BigEndian>()?;
326324
if len < 0 {
327325
return Err("invalid varbit length: varbit < 0".into());
@@ -508,7 +506,7 @@ where
508506

509507
/// Deserializes an array value.
510508
#[inline]
511-
pub fn array_from_sql<'a>(mut buf: &'a [u8]) -> Result<Array<'a>, StdBox<dyn Error + Sync + Send>> {
509+
pub fn array_from_sql(mut buf: &[u8]) -> Result<Array<'_>, StdBox<dyn Error + Sync + Send>> {
512510
let dimensions = buf.read_i32::<BigEndian>()?;
513511
if dimensions < 0 {
514512
return Err("invalid dimension count".into());
@@ -738,7 +736,7 @@ pub enum RangeBound<T> {
738736

739737
/// Deserializes a range value.
740738
#[inline]
741-
pub fn range_from_sql<'a>(mut buf: &'a [u8]) -> Result<Range<'a>, StdBox<dyn Error + Sync + Send>> {
739+
pub fn range_from_sql(mut buf: &[u8]) -> Result<Range<'_>, StdBox<dyn Error + Sync + Send>> {
742740
let tag = buf.read_u8()?;
743741

744742
if tag == RANGE_EMPTY {
@@ -911,7 +909,7 @@ where
911909

912910
/// Deserializes a Postgres path.
913911
#[inline]
914-
pub fn path_from_sql<'a>(mut buf: &'a [u8]) -> Result<Path<'a>, StdBox<dyn Error + Sync + Send>> {
912+
pub fn path_from_sql(mut buf: &[u8]) -> Result<Path<'_>, StdBox<dyn Error + Sync + Send>> {
915913
let closed = buf.read_u8()? != 0;
916914
let points = buf.read_i32::<BigEndian>()?;
917915

tokio-postgres/src/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,8 @@ impl<'a> UrlParser<'a> {
760760

761761
fn remove_url_prefix(s: &str) -> Option<&str> {
762762
for prefix in &["postgres://", "postgresql://"] {
763-
if s.starts_with(prefix) {
764-
return Some(&s[prefix.len()..]);
763+
if let Some(stripped) = s.strip_prefix(prefix) {
764+
return Some(stripped);
765765
}
766766
}
767767

@@ -825,8 +825,8 @@ impl<'a> UrlParser<'a> {
825825

826826
let host = &chunk[1..idx];
827827
let remaining = &chunk[idx + 1..];
828-
let port = if remaining.starts_with(':') {
829-
Some(&remaining[1..])
828+
let port = if let Some(port) = remaining.strip_prefix(':') {
829+
Some(port)
830830
} else if remaining.is_empty() {
831831
None
832832
} else {

tokio-postgres/src/connection.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,10 @@ where
200200
return Ok(false);
201201
}
202202

203-
if let Poll::Pending = Pin::new(&mut self.stream)
203+
if Pin::new(&mut self.stream)
204204
.poll_ready(cx)
205205
.map_err(Error::io)?
206+
.is_pending()
206207
{
207208
trace!("poll_write: waiting on socket");
208209
return Ok(false);

tokio-postgres/tests/test/types/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,7 @@ async fn domain() {
483483
}
484484

485485
fn accepts(ty: &Type) -> bool {
486-
ty.name() == "session_id"
487-
&& match *ty.kind() {
488-
Kind::Domain(_) => true,
489-
_ => false,
490-
}
486+
ty.name() == "session_id" && matches!(ty.kind(), Kind::Domain(_))
491487
}
492488

493489
to_sql_checked!();

0 commit comments

Comments
 (0)