Skip to content

Commit

Permalink
feat: add correct CI, update deps
Browse files Browse the repository at this point in the history
Signed-off-by: Martichou <[email protected]>
  • Loading branch information
Martichou committed Sep 22, 2024
1 parent 55aebb6 commit 429294f
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 94 deletions.
71 changes: 10 additions & 61 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
- 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"
31 changes: 22 additions & 9 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -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
skip-github-release: true
14 changes: 4 additions & 10 deletions .github/workflows/upload-to-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{".":"0.0.9"}
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ 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"] }
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" }
Expand All @@ -26,7 +26,6 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[features]
default = []
auth = []

[profile.release]
lto = true
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<p>

[![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)

</p>
</div>
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -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"
}
4 changes: 0 additions & 4 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -77,7 +76,6 @@ impl SpClient {
}
}

#[cfg(feature = "auth")]
fn prepare_update(&self) -> hyper::Request<hyper::Body> {
match build_update(&CONFIG.api_token) {
Ok(req) => req,
Expand All @@ -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();
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ static API_URL: Lazy<String> = Lazy::new(|| {
CONFIG.api_url.clone() + "?uuid=" + &CONFIG.uuid
});

#[cfg(feature = "auth")]
static SSO_URL: Lazy<String> = Lazy::new(|| {
info!(
"SSO_URL: {}",
Expand Down
1 change: 0 additions & 1 deletion src/utils/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
2 changes: 0 additions & 2 deletions src/utils/request.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "auth")]
use crate::SSO_URL;
use crate::{harvest::data_harvest::Data, API_URL};

Expand Down Expand Up @@ -34,7 +33,6 @@ pub fn build_request(
}
}

#[cfg(feature = "auth")]
pub fn build_update(token: &str) -> Result<hyper::Request<hyper::Body>, Error> {
match Request::builder()
.method(Method::PATCH)
Expand Down

0 comments on commit 429294f

Please sign in to comment.