Skip to content

Commit

Permalink
ci: code quality (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
seren5240 authored Mar 10, 2024
1 parent bcbaad2 commit 2e19f3f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: code quality
on: "push"
concurrency:
group: ${{ github.workflow }}-${{ (github.ref == 'refs/heads/main' && github.sha) || github.ref }}
cancel-in-progress: true
jobs:
clippy_check:
runs-on: "nscloud-ubuntu-22.04-amd64-4x16"
steps:
- name: clone code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Protoc
run: sudo apt-get install -y protobuf-compiler
- run: rustup component add clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --features test_ci --exclude marzano-wasm-bindings -- -D warnings
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
.vscode
7 changes: 2 additions & 5 deletions crates/auth/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ impl AuthInfo {

pub fn get_expiry(&self) -> Result<DateTime<Utc>> {
let payload = self.get_payload()?;
let expiry = DateTime::<Utc>::from_naive_utc_and_offset(
chrono::NaiveDateTime::from_timestamp_opt(payload.exp as i64, 0)
.ok_or(anyhow::anyhow!("Invalid timestamp"))?,
Utc,
);
let expiry = DateTime::<Utc>::from_timestamp(payload.exp as i64, 0)
.ok_or(anyhow::anyhow!("Invalid timestamp"))?;
Ok(expiry)
}

Expand Down
10 changes: 5 additions & 5 deletions crates/cli/src/updater.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::bail;
use anyhow::{Context, Result};
use chrono::NaiveDateTime;
use chrono::{DateTime, NaiveDateTime, Utc};
use colored::Colorize;
use log::info;
use marzano_auth::info::AuthInfo;
Expand Down Expand Up @@ -622,7 +622,7 @@ impl Updater {
}

/// Get the release date of the app, based on the release ID
fn _get_app_release_date(&self, app_name: SupportedApp) -> Result<NaiveDateTime> {
fn _get_app_release_date(&self, app_name: SupportedApp) -> Result<DateTime<Utc>> {
let app_manifest = self._get_app_manifest(app_name)?;
let version_string = app_manifest
.version
Expand All @@ -632,7 +632,7 @@ impl Updater {
// The date is the last part
let timestamp = version_string.last().context("Missing timestamp")?;
// Convert the unix timestamp to a date
let date = NaiveDateTime::from_timestamp_millis(timestamp.parse::<i64>()?)
let date = DateTime::from_timestamp_millis(timestamp.parse::<i64>()?)
.context("Could not parse timestamp")?;
Ok(date)
}
Expand Down Expand Up @@ -785,10 +785,10 @@ mod tests {
let cli_release_date = updater._get_app_release_date(SupportedApp::Cli)?;
assert_eq!(
cli_release_date,
NaiveDate::from_ymd_opt(2023, 7, 12)
DateTime::<Utc>::from_naive_utc_and_offset(NaiveDate::from_ymd_opt(2023, 7, 12)
.unwrap()
.and_hms_opt(5, 2, 9)
.unwrap()
.unwrap(), Utc),
);

Ok(())
Expand Down

0 comments on commit 2e19f3f

Please sign in to comment.