diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b7adc4..9a2b22a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,71 +1,20 @@ -name: CI +name: Code quality - linting -on: [push, pull_request] +on: + push: + branches: [ "master" ] + pull_request: env: RUST_BACKTRACE: 1 jobs: style: - if: startsWith(github.ref, 'refs/tags/v') != true name: Check Style runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - components: rustfmt, clippy - profile: minimal - override: true - - - name: cargo fmt -- --check - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check - - - name: Check with Clippy - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features --all --tests - - build: - if: startsWith(github.ref, 'refs/tags/v') != true - name: ${{ matrix.name }} - needs: [style] - runs-on: ${{ matrix.os }} - strategy: - matrix: - name: - - linux / stable - - macOS / stable - include: - - name: linux / stable - os: ubuntu-latest - - name: macOS / stable - os: macOS-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - - - name: Test - uses: actions-rs/cargo@v1 - with: - command: test \ No newline at end of file + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - run: cargo fmt --all --check + - run: cargo clippy --all-features --all -- -D "warnings" \ No newline at end of file diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index f1761f6..2715575 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -1,18 +1,31 @@ -name: Create release +name: Release please flow on: push: - tags: - - "v*.*.*" + branches: + - master + tags-ignore: + - '**' + +env: + CARGO_TERM_COLOR: always jobs: - build: + release_please_tag: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 + - uses: googleapis/release-please-action@v4 + with: + token: ${{ secrets.GH_PAT_RELEASE_ACCESS }} + skip-github-pull-request: true - - name: Release - uses: softprops/action-gh-release@v1 + release_please_pr: + runs-on: ubuntu-latest + needs: release_please_tag + permissions: + contents: write + pull-requests: write + steps: + - uses: googleapis/release-please-action@v4 with: - generate_release_notes: true \ No newline at end of file + skip-github-release: true \ No newline at end of file diff --git a/.github/workflows/upload-to-release.yaml b/.github/workflows/upload-to-release.yaml index 06b5dce..d3e1302 100644 --- a/.github/workflows/upload-to-release.yaml +++ b/.github/workflows/upload-to-release.yaml @@ -23,17 +23,11 @@ jobs: - { target: x86_64-apple-darwin , os: macos-12 } steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install rust - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable with: - toolchain: stable - components: rustfmt, clippy - profile: minimal - override: true - target: ${{ matrix.job.target }} + targets: ${{ matrix.job.target }} + - uses: Swatinem/rust-cache@v2 - name: Build run: cargo build --release --all-features diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..20d7a34 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1 @@ +{".":"0.0.9"} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 9404223..4f70c82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,9 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -async-recursion = "1.0" +async-recursion = "1.1" chrono = { version = "0.4", features = ["serde"] } -config = "0.13" +config = "0.14" clap = { version = "4.2", features = ["derive"] } clap-verbosity-flag = "2.0" hyper = { version = "0.14", features = ["client", "http1", "http2"] } @@ -17,7 +17,7 @@ hyper-rustls = { version = "0.24", features = ["rustls-native-certs", "http2"]} log = "0.4" once_cell = "1.14" serde_json = "1.0" -simd-json = "0.9" +simd-json = "0.14" serde = { version = "1.0", features = ["derive"] } sha1_smol = { version = "1.0", features = ["std"] } sys_metrics = { git = "https://github.com/Martichou/sys_metrics" } @@ -26,7 +26,6 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } [features] default = [] -auth = [] [profile.release] lto = true diff --git a/README.md b/README.md index a4522d7..966adce 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@

[![Apache 2 License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE) -[![CI](https://github.com/Martichou/speculare-client/workflows/CI/badge.svg)](https://github.com/Martichou/speculare-client/actions) -[![Docs](https://img.shields.io/badge/Docs-latest-green.svg)](https://docs.speculare.cloud) +[![CI](https://github.com/speculare-cloud/speculare-client/actions/workflows/ci.yml/badge.svg)](https://github.com/speculare-cloud/speculare-client/actions)

diff --git a/.cargo/config b/config.toml similarity index 100% rename from .cargo/config rename to config.toml diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..11e9490 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,21 @@ +{ + "prerelease": true, + "packages": { + ".": { + "release-type": "simple" + } + }, + "extra-files": [ + { + "type": "toml", + "path": "Cargo.toml", + "jsonpath": "package.version" + }, + { + "type": "toml", + "path": "Cargo.lock", + "jsonpath": "$.package[?(@.name.value == 'speculare-client')].version" + } + ], + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" +} \ No newline at end of file diff --git a/src/client.rs b/src/client.rs index df71f25..0148b24 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,5 +1,4 @@ use crate::utils::request::build_client; -#[cfg(feature = "auth")] use crate::utils::request::build_update; use crate::CONFIG; use crate::{harvest::Data, utils::request::build_request}; @@ -77,7 +76,6 @@ impl SpClient { } } - #[cfg(feature = "auth")] fn prepare_update(&self) -> hyper::Request { match build_update(&CONFIG.api_token) { Ok(req) => req, @@ -92,13 +90,11 @@ impl SpClient { trace!("request: response: {}", resp.status()); if resp.status() == StatusCode::OK { self.data_cache.clear(); - #[cfg(feature = "auth")] return; } else { trace!("request: full response: {:?}", resp); } - #[cfg(feature = "auth")] if resp.status() == StatusCode::PRECONDITION_FAILED { warn!("The host_uuid is not defined for this key, updating..."); let update = self.prepare_update(); diff --git a/src/main.rs b/src/main.rs index f549d46..ef96a60 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,6 @@ static API_URL: Lazy = Lazy::new(|| { CONFIG.api_url.clone() + "?uuid=" + &CONFIG.uuid }); -#[cfg(feature = "auth")] static SSO_URL: Lazy = Lazy::new(|| { info!( "SSO_URL: {}", diff --git a/src/utils/config.rs b/src/utils/config.rs index 81d53a4..37fce36 100644 --- a/src/utils/config.rs +++ b/src/utils/config.rs @@ -26,7 +26,6 @@ pub struct Config { // GLOBAL SETTINGS #[serde(default = "default_cache_size")] pub cache_size: i64, - #[cfg(feature = "auth")] pub sso_url: String, } diff --git a/src/utils/request.rs b/src/utils/request.rs index 1081521..a1cc708 100644 --- a/src/utils/request.rs +++ b/src/utils/request.rs @@ -1,4 +1,3 @@ -#[cfg(feature = "auth")] use crate::SSO_URL; use crate::{harvest::data_harvest::Data, API_URL}; @@ -34,7 +33,6 @@ pub fn build_request( } } -#[cfg(feature = "auth")] pub fn build_update(token: &str) -> Result, Error> { match Request::builder() .method(Method::PATCH)