From 39b7937e7b5ef3cb438e1402540824371a58c431 Mon Sep 17 00:00:00 2001 From: Heiko Seeberger Date: Sat, 7 Jan 2023 08:24:24 +0100 Subject: [PATCH] chore: badges, update GH workflows, dependabot (#16) * chore: badges, update GH workflows, dependabot * fix GH workflow * clippy --- .github/dependabot.yaml | 11 ++++++++ .github/workflows/ci.yaml | 47 +++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 21 --------------- Cargo.toml | 4 +-- README.md | 11 ++++++++ pub-sub-client/src/error/mod.rs | 2 +- pub-sub-client/src/lib.rs | 4 ++- rustfmt.toml | 6 ++--- 8 files changed, 78 insertions(+), 28 deletions(-) create mode 100644 .github/dependabot.yaml create mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/test.yml diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..e00b2db --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "cargo" + directory: "/" # Location of package manifests + schedule: + interval: "daily" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..28173df --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,47 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Check out + uses: actions/checkout@v3 + + - name: Install Rust toolchain + run: | + rustup update + rustup toolchain install nightly + rustup component add rustfmt --toolchain nightly + rustup component add clippy --toolchain nightly + + - name: Set up cargo cache + uses: actions/cache@v3 + continue-on-error: false + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + + - name: Check code format (cargo fmt) + run: cargo +nightly fmt --check + + - name: Lint (cargo clippy) + run: cargo clippy --no-deps -- -D warnings + + - name: Test (cargo test) + env: + GCP_SERVICE_ACCOUNT: ${{ secrets.GCP_SERVICE_ACCOUNT }} + run: | + printenv GCP_SERVICE_ACCOUNT > pub-sub-client-tests/secrets/active-road-365118-2eca6b7b8fd9.json + cargo test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 1d71eda..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: test - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - lint-and-test: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - run: rustup update - - run: cargo clippy -- -D warnings - - name: Run `cargo test` - env: - GCP_SERVICE_ACCOUNT: ${{ secrets.GCP_SERVICE_ACCOUNT }} - run: | - printenv GCP_SERVICE_ACCOUNT > pub-sub-client-tests/secrets/active-road-365118-2eca6b7b8fd9.json - cargo test diff --git a/Cargo.toml b/Cargo.toml index f7dd7f9..b39a2b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,12 +2,12 @@ members = [ "pub-sub-client", "pub-sub-client-derive", "pub-sub-client-tests" ] [workspace.package] -version = "0.10.1-alpha.0" +# No use to define version here, because cargo release ignores it! +# version = "0.10.1-alpha.0" edition = "2021" description = "Google Cloud Pub/Sub client library" authors = [ "Heiko Seeberger " ] license = "Apache-2.0" -readme = "README.md" homepage = "https://github.com/hseeberger/pub-sub-client" repository = "https://github.com/hseeberger/pub-sub-client" documentation = "https://github.com/hseeberger/pub-sub-client" diff --git a/README.md b/README.md index 4597a3c..9a3227a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,16 @@ # Google Cloud Pub/Sub client +[![Crates.io][crates-badge]][crates-url] +[![license][license-badge]][license-url] +[![build][build-badge]][build-url] + +[crates-badge]: https://img.shields.io/crates/v/pub-sub-client +[crates-url]: https://crates.io/crates/pub-sub-client +[license-badge]: https://img.shields.io/github/license/hseeberger/pub-sub-client +[license-url]: https://github.com/hseeberger/pub-sub-client/blob/main/LICENSE +[build-badge]: https://img.shields.io/github/actions/workflow/status/hseeberger/pub-sub-client/ci.yaml +[build-url]: https://github.com/hseeberger/pub-sub-client/actions/workflows/ci.yaml + Google Cloud Pub/Sub client library in [Rust](https://www.rust-lang.org/). Currently publishing, pulling and acknowledging are supported, but no management tasks like creating topics or subscriptions. Messages can either be published/pulled as raw or, if the payload is JSON data, serialized from/deserialized into domain messages (structs or enums) via [Serde](https://serde.rs/) and [Serde JSON](https://docs.serde.rs/serde_json). Both raw `ReceivedMessages` and "typed" `PulledMessages` expose metadata like message ID, acknowledge ID, attributes, etc. diff --git a/pub-sub-client/src/error/mod.rs b/pub-sub-client/src/error/mod.rs index d3c2ddc..d3c42b3 100644 --- a/pub-sub-client/src/error/mod.rs +++ b/pub-sub-client/src/error/mod.rs @@ -12,7 +12,7 @@ pub enum Error { }, #[error("Getting authentication token failed")] - TokenFetch { source: goauth::GoErr }, + TokenFetch { source: Box }, #[error("HTTP communication with Pub/Sub service failed")] HttpServiceCommunication { source: reqwest::Error }, diff --git a/pub-sub-client/src/lib.rs b/pub-sub-client/src/lib.rs index a7ec217..8ffe9fc 100644 --- a/pub-sub-client/src/lib.rs +++ b/pub-sub-client/src/lib.rs @@ -86,7 +86,9 @@ impl PubSubClient { .token_fetcher .fetch_token() .await - .map_err(|source| Error::TokenFetch { source })?; + .map_err(|source| Error::TokenFetch { + source: Box::new(source), + })?; let request = self .reqwest_client diff --git a/rustfmt.toml b/rustfmt.toml index b2e74b2..172facf 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,6 +1,6 @@ edition = "2021" -unstable_features = true -comment_width = 100 +unstable_features = true +comment_width = 100 imports_granularity = "Crate" -wrap_comments = true +wrap_comments = true