Skip to content

Commit 840c38d

Browse files
authored
chore: updates (#17)
* chore: updates * build: use just * fixes * doc * fix: GH workflow
1 parent 39b7937 commit 840c38d

File tree

11 files changed

+135
-94
lines changed

11 files changed

+135
-94
lines changed

.github/workflows/ci.yaml

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
1-
name: CI
1+
name: ci
22

33
on:
44
push:
5-
branches: [main]
5+
branches:
6+
- main
7+
tags-ignore:
8+
- v*
9+
610
pull_request:
7-
branches: [main]
11+
branches:
12+
- main
813

914
jobs:
10-
test:
15+
ci:
1116
runs-on: ubuntu-latest
1217
steps:
1318
- name: Check out
1419
uses: actions/checkout@v3
1520

21+
# Nightly needed for `cargo +nightly fmt` below
1622
- name: Install Rust toolchain
1723
run: |
1824
rustup update
19-
rustup toolchain install nightly
25+
rustup toolchain install nightly --profile minimal
2026
rustup component add rustfmt --toolchain nightly
21-
rustup component add clippy --toolchain nightly
27+
# rustup component add clippy --toolchain nightly
2228
23-
- name: Set up cargo cache
24-
uses: actions/cache@v3
25-
continue-on-error: false
29+
- name: Install just
30+
uses: taiki-e/install-action@v2
2631
with:
27-
path: |
28-
~/.cargo/bin/
29-
~/.cargo/registry/index/
30-
~/.cargo/registry/cache/
31-
~/.cargo/git/db/
32-
target/
33-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
34-
restore-keys: ${{ runner.os }}-cargo-
35-
36-
- name: Check code format (cargo fmt)
37-
run: cargo +nightly fmt --check
38-
39-
- name: Lint (cargo clippy)
40-
run: cargo clippy --no-deps -- -D warnings
41-
42-
- name: Test (cargo test)
32+
tool: just
33+
34+
- name: Set up Rust cache
35+
uses: Swatinem/rust-cache@v2
36+
37+
- name: Check code format
38+
run: just fmt_check
39+
40+
- name: Run linter
41+
run: just lint
42+
43+
- name: Run tests
4344
env:
4445
GCP_SERVICE_ACCOUNT: ${{ secrets.GCP_SERVICE_ACCOUNT }}
4546
run: |
4647
printenv GCP_SERVICE_ACCOUNT > pub-sub-client-tests/secrets/active-road-365118-2eca6b7b8fd9.json
47-
cargo test
48+
just test

Cargo.toml

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
[workspace]
2-
members = [ "pub-sub-client", "pub-sub-client-derive", "pub-sub-client-tests" ]
2+
members = [
3+
"pub-sub-client",
4+
"pub-sub-client-derive",
5+
"pub-sub-client-tests",
6+
]
7+
resolver = "2"
38

49
[workspace.package]
510
# No use to define version here, because cargo release ignores it!
@@ -8,21 +13,27 @@ edition = "2021"
813
description = "Google Cloud Pub/Sub client library"
914
authors = [ "Heiko Seeberger <[email protected]>" ]
1015
license = "Apache-2.0"
16+
readme = "README.md"
1117
homepage = "https://github.com/hseeberger/pub-sub-client"
1218
repository = "https://github.com/hseeberger/pub-sub-client"
1319
documentation = "https://github.com/hseeberger/pub-sub-client"
20+
publish = true
1421

1522
[workspace.dependencies]
16-
anyhow = "1.0"
17-
base64 = "0.13"
18-
goauth = "0.13"
19-
reqwest = { version = "0.11" }
20-
serde = { version = "1.0" }
21-
serde_json = "1.0"
22-
smpl_jwt = "0.7"
23-
thiserror = "1.0"
24-
time = { version = "0.3" }
25-
tracing = "0.1"
26-
testcontainers = "0.14"
27-
tokio = "1.21"
28-
tracing-subscriber = "0.3"
23+
anyhow = { version = "1.0" }
24+
base64 = { version = "0.21" }
25+
goauth = { version = "0.13" }
26+
proc-macro2 = { version = "1.0" }
27+
quote = { version = "1.0" }
28+
reqwest = { version = "0.11" }
29+
serde = { version = "1.0" }
30+
serde_json = { version = "1.0" }
31+
smpl_jwt = { version = "0.7" }
32+
syn = { version = "2.0" }
33+
testcontainers = { version = "0.15" }
34+
testcontainers-modules = { version = "0.1", features = [ "google_cloud_sdk_emulators" ] }
35+
thiserror = { version = "1.0" }
36+
time = { version = "0.3" }
37+
tokio = { version = "1" }
38+
tracing = { version = "0.1" }
39+
tracing-subscriber = { version = "0.3" }

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,4 @@ authority to do so.
9797

9898
This code is open source software licensed under the
9999
[Apache 2.0 License]("http://www.apache.org/licenses/LICENSE-2.0.html").
100+

justfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set shell := ["bash", "-uc"]
2+
3+
check:
4+
cargo check --tests
5+
6+
fmt:
7+
cargo +nightly fmt
8+
9+
fmt_check:
10+
cargo +nightly fmt --check
11+
12+
lint:
13+
cargo clippy --no-deps -- -D warnings
14+
15+
test:
16+
cargo test
17+
18+
all: fmt check lint test

pub-sub-client-derive/Cargo.toml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
[package]
2-
name = "pub-sub-client-derive"
3-
version= "0.11.1-alpha.0"
4-
edition.workspace = true
5-
description.workspace = true
6-
authors.workspace = true
7-
license.workspace = true
8-
readme.workspace = true
9-
homepage.workspace = true
10-
repository.workspace = true
11-
documentation.workspace = true
2+
name = "pub-sub-client-derive"
3+
version = "0.11.1-alpha.0"
4+
description = { workspace = true }
5+
edition = { workspace = true }
6+
authors = { workspace = true }
7+
license = { workspace = true }
8+
readme = { workspace = true }
9+
homepage = { workspace = true }
10+
repository = { workspace = true }
11+
documentation = { workspace = true }
12+
publish = { workspace = true }
1213

1314
[lib]
1415
proc-macro = true
1516

1617
[dependencies]
17-
proc-macro2 = "1.0"
18-
quote = "1.0"
19-
syn = "1.0"
18+
proc-macro2 = { workspace = true }
19+
quote = { workspace = true }
20+
syn = { workspace = true }

pub-sub-client-tests/Cargo.toml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
[package]
2-
name = "pub-sub-client-tests"
3-
version= "0.11.1-alpha.0"
4-
edition.workspace = true
5-
description.workspace = true
6-
authors.workspace = true
7-
license.workspace = true
8-
readme.workspace = true
9-
homepage.workspace = true
10-
repository.workspace = true
11-
documentation.workspace = true
12-
publish = false
2+
name = "pub-sub-client-tests"
3+
version = "0.11.1-alpha.0"
4+
description = { workspace = true }
5+
edition = { workspace = true }
6+
authors = { workspace = true }
7+
license = { workspace = true }
8+
readme = { workspace = true }
9+
homepage = { workspace = true }
10+
repository = { workspace = true }
11+
documentation = { workspace = true }
12+
publish = false
1313

1414
[dev-dependencies]
15-
pub-sub-client = { version = "=0.11.1-alpha.0", path = "../pub-sub-client", features = [ "derive" ] }
16-
anyhow = { workspace = true }
17-
base64 = { workspace = true }
18-
reqwest = { workspace = true, features = [ "json" ] }
19-
serde = { workspace = true, features = [ "derive" ] }
20-
serde_json = { workspace = true }
21-
testcontainers = { workspace = true }
22-
tokio = { workspace = true, features = [ "full" ] }
23-
tracing-subscriber = { workspace = true, features = [ "env-filter", "fmt", "json", "tracing-log" ] }
15+
pub-sub-client = { version = "=0.11.1-alpha.0", path = "../pub-sub-client", features = [ "derive" ] }
16+
anyhow = { workspace = true }
17+
base64 = { workspace = true }
18+
reqwest = { workspace = true, features = [ "json" ] }
19+
serde = { workspace = true, features = [ "derive" ] }
20+
serde_json = { workspace = true }
21+
testcontainers = { workspace = true }
22+
testcontainers-modules = { workspace = true }
23+
tokio = { workspace = true, features = [ "full" ] }
24+
tracing-subscriber = { workspace = true, features = [ "env-filter", "fmt", "json", "tracing-log" ] }

pub-sub-client-tests/examples/transform.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::anyhow;
2+
use base64::{engine::general_purpose::STANDARD, Engine};
23
use pub_sub_client::{
34
Error, PubSubClient, PublishedMessage, PulledMessage, RawPublishedMessage,
45
RawPulledMessageEnvelope,
@@ -40,7 +41,7 @@ async fn run() -> Result<(), Error> {
4041

4142
let messages = vec!["Hello", "from pub-sub-client"]
4243
.iter()
43-
.map(|s| base64::encode(json!({ "text": s }).to_string()))
44+
.map(|s| STANDARD.encode(json!({ "text": s }).to_string()))
4445
.map(|data| {
4546
RawPublishedMessage::new(data)
4647
.with_attributes(HashMap::from([("type".to_string(), "Foo".to_string())]))

pub-sub-client-tests/tests/test.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
use base64::{engine::general_purpose::STANDARD, Engine};
12
use pub_sub_client::{PubSubClient, PublishedMessage, RawPublishedMessage};
23
use reqwest::{Client, StatusCode};
34
use serde::{Deserialize, Serialize};
45
use serde_json::json;
56
use std::{collections::HashMap, env, time::Duration, vec};
6-
use testcontainers::{
7-
clients::Cli,
8-
images::google_cloud_sdk_emulators::{CloudSdk, PUBSUB_PORT},
9-
};
7+
use testcontainers::clients::Cli;
8+
use testcontainers_modules::google_cloud_sdk_emulators::{CloudSdk, PUBSUB_PORT};
109

1110
const PROJECT_ID: &str = "active-road-365118";
1211
const TOPIC_ID: &str = "test";
@@ -64,7 +63,7 @@ async fn test() {
6463
let pub_sub_client = pub_sub_client.unwrap();
6564

6665
// Publish raw
67-
let foo = base64::encode(json!({ "Foo": { "text": TEXT } }).to_string());
66+
let foo = STANDARD.encode(json!({ "Foo": { "text": TEXT } }).to_string());
6867
let messages = vec![RawPublishedMessage::new(foo)];
6968
let result = pub_sub_client
7069
.publish_raw(TOPIC_ID, messages, Some(Duration::from_secs(10)))

pub-sub-client/Cargo.toml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
[package]
2-
name = "pub-sub-client"
3-
version= "0.11.1-alpha.0"
4-
edition.workspace = true
5-
description.workspace = true
6-
authors.workspace = true
7-
license.workspace = true
8-
readme.workspace = true
9-
homepage.workspace = true
10-
repository.workspace = true
11-
documentation.workspace = true
12-
exclude = [ "tests" ]
2+
name = "pub-sub-client"
3+
version = "0.11.1-alpha.0"
4+
description = { workspace = true }
5+
edition = { workspace = true }
6+
authors = { workspace = true }
7+
license = { workspace = true }
8+
readme = { workspace = true }
9+
homepage = { workspace = true }
10+
repository = { workspace = true }
11+
documentation = { workspace = true }
12+
publish = { workspace = true }
13+
exclude = [ "tests" ]
1314

1415
[features]
1516
derive = [ "pub-sub-client-derive" ]

pub-sub-client/src/publisher/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{error::Error, PubSubClient};
2+
use base64::{engine::general_purpose::STANDARD, Engine};
23
use serde::{Deserialize, Serialize};
34
use std::{collections::HashMap, fmt::Debug, time::Duration};
45
use tracing::debug;
@@ -101,7 +102,7 @@ impl PubSubClient {
101102
.map_err(|source| Error::Serialize { source })?
102103
.into_iter()
103104
.map(|(bytes, attributes)| RawPublishedMessage {
104-
data: Some(base64::encode(bytes)),
105+
data: Some(STANDARD.encode(bytes)),
105106
attributes,
106107
ordering_key,
107108
})

0 commit comments

Comments
 (0)