Skip to content

Commit

Permalink
feat: add footer status countdown & duration since
Browse files Browse the repository at this point in the history
  • Loading branch information
voznik committed Jun 3, 2024
1 parent 2b78ef7 commit e2b5845
Show file tree
Hide file tree
Showing 19 changed files with 201 additions and 128 deletions.
File renamed without changes.
47 changes: 47 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# See https://nexte.st/book/configuration.html for format and defaults
# Profiles defined here inherit from profile.default

# profile used in GitHub test runs
# - Retry a few times to detect flaky tests
# - Call out every test as it finishes, including slow, skipped and flaky tests
# - List failures again at the end.
# - Run all tests even if some failed.
# - Output test results in JUnit format.
[profile.ci]
# "retries" defines the number of times a test should be retried. If set to a
# non-zero value, tests that succeed on a subsequent attempt will be marked as
# non-flaky. Can be overridden through the `--retries` option.
retries = 2

# * none: no output
# * fail: show failed (including exec-failed) tests
# * retry: show flaky and retried tests
# * slow: show slow tests
# * pass: show passed tests
# * skip: show skipped tests (most useful for CI)
# * all: all of the above
#
# Each value includes all the values above it; for example, "slow" includes
# failed and retried tests.
status-level = "all"

# * "immediate-final": output failures as soon as they happen and at the end of
# the test run; combination of "immediate" and "final"
failure-output = "immediate-final"

# Cancel the test run on the first failure. For CI runs, consider setting this
# to false.
fail-fast = false

[profile.ci.junit]
# Output a JUnit report into the given file inside 'store.dir/<profile-name>'.
# The default value for store.dir is 'target/nextest', so the following file
# is written to the target/nextest/ci/ directory.
path = "junit.xml"

# profile used in GitHub coverage runs
# - lower retry count as a compromise between speed and resilience
# - no fail-fast to at least keep coverage percentages accurate.
[profile.coverage]
retries = 1
fail-fast = false
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ jobs:
if: matrix.target != 'x86_64-pc-windows-msvc'

- name: cargo clippy
run: cargo clippy --tests --workspace -- -D warnings
run: cargo clippy --workspace -- -D warnings
63 changes: 33 additions & 30 deletions .github/workflows/package-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,58 +23,61 @@ jobs:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
client_artifact_name: target/x86_64-unknown-linux-musl/release/pueue
daemon_artifact_name: target/x86_64-unknown-linux-musl/release/pueued
client_release_name: pueue-linux-x86_64
daemon_release_name: pueued-linux-x86_64
client_artifact_name: target/x86_64-unknown-linux-musl/release/ralertsinua
daemon_artifact_name: target/x86_64-unknown-linux-musl/release/ralertsinuad
client_release_name: ralertsinua-linux-x86_64
daemon_release_name: ralertsinuad-linux-x86_64
cross: true
strip: true
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
client_artifact_name: target/aarch64-unknown-linux-musl/release/pueue
daemon_artifact_name: target/aarch64-unknown-linux-musl/release/pueued
client_release_name: pueue-linux-aarch64
daemon_release_name: pueued-linux-aarch64
client_artifact_name: target/aarch64-unknown-linux-musl/release/ralertsinua
daemon_artifact_name: target/aarch64-unknown-linux-musl/release/ralertsinuad
client_release_name: ralertsinua-linux-aarch64
daemon_release_name: ralertsinuad-linux-aarch64
cross: true
strip: false
env:
OPENSSL_LIB_DIR=/usr/lib
OPENSSL_INCLUDE_DIR=/usr/include
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
client_artifact_name: target/armv7-unknown-linux-musleabihf/release/pueue
daemon_artifact_name: target/armv7-unknown-linux-musleabihf/release/pueued
client_release_name: pueue-linux-armv7
daemon_release_name: pueued-linux-armv7
client_artifact_name: target/armv7-unknown-linux-musleabihf/release/ralertsinua
daemon_artifact_name: target/armv7-unknown-linux-musleabihf/release/ralertsinuad
client_release_name: ralertsinua-linux-armv7
daemon_release_name: ralertsinuad-linux-armv7
cross: true
strip: false
- os: ubuntu-latest
target: arm-unknown-linux-musleabihf
client_artifact_name: target/arm-unknown-linux-musleabihf/release/pueue
daemon_artifact_name: target/arm-unknown-linux-musleabihf/release/pueued
client_release_name: pueue-linux-arm
daemon_release_name: pueued-linux-arm
client_artifact_name: target/arm-unknown-linux-musleabihf/release/ralertsinua
daemon_artifact_name: target/arm-unknown-linux-musleabihf/release/ralertsinuad
client_release_name: ralertsinua-linux-arm
daemon_release_name: ralertsinuad-linux-arm
cross: true
strip: false
- os: windows-latest
target: x86_64-pc-windows-msvc
client_artifact_name: target/x86_64-pc-windows-msvc/release/pueue.exe
daemon_artifact_name: target/x86_64-pc-windows-msvc/release/pueued.exe
client_release_name: pueue-windows-x86_64.exe
daemon_release_name: pueued-windows-x86_64.exe
client_artifact_name: target/x86_64-pc-windows-msvc/release/ralertsinua.exe
daemon_artifact_name: target/x86_64-pc-windows-msvc/release/ralertsinuad.exe
client_release_name: ralertsinua-windows-x86_64.exe
daemon_release_name: ralertsinuad-windows-x86_64.exe
cross: false
strip: true
- os: macos-latest
target: x86_64-apple-darwin
client_artifact_name: target/x86_64-apple-darwin/release/pueue
daemon_artifact_name: target/x86_64-apple-darwin/release/pueued
client_release_name: pueue-macos-x86_64
daemon_release_name: pueued-macos-x86_64
client_artifact_name: target/x86_64-apple-darwin/release/ralertsinua
daemon_artifact_name: target/x86_64-apple-darwin/release/ralertsinuad
client_release_name: ralertsinua-macos-x86_64
daemon_release_name: ralertsinuad-macos-x86_64
cross: false
strip: true
- os: macos-latest
target: aarch64-apple-darwin
client_artifact_name: target/aarch64-apple-darwin/release/pueue
daemon_artifact_name: target/aarch64-apple-darwin/release/pueued
client_release_name: pueue-darwin-aarch64
daemon_release_name: pueued-darwin-aarch64
client_artifact_name: target/aarch64-apple-darwin/release/ralertsinua
daemon_artifact_name: target/aarch64-apple-darwin/release/ralertsinuad
client_release_name: ralertsinua-darwin-aarch64
daemon_release_name: ralertsinuad-darwin-aarch64
cross: false
strip: true

Expand Down Expand Up @@ -132,8 +135,8 @@ jobs:
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: utils/pueued.service
file: utils/ralertsinuad.service
tag: ${{ github.ref }}
asset_name: systemd.pueued.service
asset_name: systemd.ralertsinuad.service
body: ${{ steps.changelog_reader.outputs.log_entry }}
if: matrix.target == 'x86_64-unknown-linux-musl'
13 changes: 0 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 12 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ version = "0.5.2"
authors = ["voiceapiai <[email protected]>"]
license = "MIT"
edition = "2021"
exclude = [
"assets/*",
".github",
"CONTRIBUTING.md",
"*.log",
"tags",
]
exclude = ["assets/*", ".github", "CONTRIBUTING.md", "*.log", "tags"]
rust-version = "1.74.0"

build = "build.rs"
Expand All @@ -29,7 +23,7 @@ panic = 'unwind'
# debug = true

[workspace]
members = ["ralertsinua-http", "ralertsinua-geo", "ralertsinua-models"]
members = ["ralertsinua-geo", "ralertsinua-http", "ralertsinua-models"]

[package.metadata.release]
allow-branch = ["main"]
Expand Down Expand Up @@ -73,17 +67,8 @@ inherits = "release"
lto = "thin"

[dependencies]
ralertsinua-models = { path = "ralertsinua-models", version = "0.5.2" }
ralertsinua-geo = { path = "ralertsinua-geo", version = "0.5.2", features = [
"tui",
] }
ralertsinua-http = { path = "ralertsinua-http", version = "0.5.2", features = [
"cache",
], default-features = false }

async-trait = "0.1.80"
bincode = "1.3.3"
chrono = "0.4.38"
clap = { version = "4.5.4", features = [
"derive",
"cargo",
Expand All @@ -99,16 +84,23 @@ directories = "5.0.1"
dotenv_config = "0.1.9"
dotenvy = "0.15.7"
dotenvy_macro = "0.15.7"
dur = "0.5.1"
futures = "0.3.30"
geo = "0.28.0"
getset = "0.1.2"
dur = "0.5.1"
icu_collator = "1.5.0"
icu_locid = { version = "1.5.0", features = ["serde"] }
lazy_static = "1.4.0"
log = "0.4.21"
michie = "3.0.2"
miette = { version = "7.2.0", features = ["fancy", "serde"] }
ralertsinua-geo = { path = "ralertsinua-geo", version = "0.5.2", features = [
"tui",
] }
ralertsinua-http = { path = "ralertsinua-http", version = "0.5.2", features = [
"cache",
], default-features = false }
ralertsinua-models = { path = "ralertsinua-models", version = "0.5.2" }
ratatui = { version = "0.26.3", features = ["serde", "macros"] }
ratatui-macros = "0.4.0"
rust-i18n = "3.0.1"
Expand Down Expand Up @@ -136,14 +128,13 @@ tui-logger = { version = "0.11.1", features = ["tracing-support"] }
vergen = { version = "8.3.1", features = ["build", "git", "gitoxide", "cargo"] }

[dev-dependencies]
mockall = "0.12.1"
mockito = "1.4.0"
codspeed-criterion-compat = "2.6.0"
criterion = { version = "0.5.1", features = ["tokio", "async_tokio"] }
fakeit = "1.2.0"
mockall = "0.12.1"
mockito = "1.4.0"
pretty_assertions = "1.4.0"


[features]
default = ["cache", "reqwest-default-tls"]

Expand Down
1 change: 0 additions & 1 deletion ralertsinua-geo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ license = "MIT"
edition = "2021"
authors = ["voiceapiai <[email protected]>"]
readme = "./README.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
7 changes: 3 additions & 4 deletions ralertsinua-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ license = "MIT"
edition = "2021"
authors = ["voiceapiai <[email protected]>"]
readme = "./README.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ralertsinua-models = { path = "../ralertsinua-models", version = "0.5.2" }

async-trait = "0.1.80"
bytes = "1.6.0"
http = "1.1.0"
miette = { version = "7.2.0", features = [] }
log = "0.4.21"
miette = { version = "7.2.0", features = [] }
native-tls = { version = "0.2.11", optional = true }
quick_cache = { version = "0.5", default-features = false, optional = true }
ralertsinua-models = { path = "../ralertsinua-models", version = "0.5.2" }
#[rustfmt::skip]
reqwest = { version = "0.12", features = [
"json",
Expand All @@ -29,7 +29,6 @@ serde = { version = "1.0.198", features = ["derive"] }
serde_json = "1.0.116"
thiserror = "1.0"
time = { version = "0.3.36", features = ["serde", "formatting", "parsing"] }
quick_cache = { version = "0.5", default-features = false, optional = true }

[features]
default = ["cache", "reqwest-default-tls"]
Expand Down
4 changes: 4 additions & 0 deletions ralertsinua-http/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct CacheEntry(pub Bytes);

/// A trait providing methods for storing, reading, and removing cache records.
pub trait CacheManagerSync: Send + Sync + 'static {
fn is_empty(&self) -> bool;
/// Attempts to pull a cached response and related last_modified from cache.
fn get(&self, cache_key: &str) -> Result<Option<CacheEntry>>;
/// Attempts to cache a response and related last_modified.
Expand Down Expand Up @@ -47,6 +48,9 @@ impl CacheManagerQuick {
}

impl CacheManagerSync for CacheManagerQuick {
fn is_empty(&self) -> bool {
self.cache.is_empty()
}
fn get(&self, cache_key: &str) -> Result<Option<CacheEntry>> {
let entry: CacheEntry = match self.cache.get(cache_key) {
Some(bytes) => CacheEntry(bytes),
Expand Down
20 changes: 13 additions & 7 deletions ralertsinua-http/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ impl AlertsInUaClient {
if cfg!(feature = "cache") {
if let Some(CacheEntry(bytes)) = self.cache_manager.get(&url)? {
cached_data = bytes;
// Here we set the If-Modified-Since header from the last_modified
headers.insert(
"If-Modified-Since",
last_modified.parse().map_err(http::Error::from)?,
);
}
// Here we set the If-Modified-Since header from the last_modified
headers.insert(
"If-Modified-Since",
last_modified.parse().map_err(http::Error::from)?,
);
}

req = req.headers(headers);
Expand Down Expand Up @@ -154,8 +154,13 @@ impl AlertsInUaClient {
let data: Bytes = match res.status() {
#[cfg(feature = "cache")]
StatusCode::NOT_MODIFIED => {
log::trace!(target: PKG, "Response status '304 Not Modified', return cached data");
cached_data
if cached_data.is_empty() {
log::error!(target: PKG, "Response status '304 Not Modified', but cache is empty");
return Err(ApiError::Internal);
} else {
log::trace!(target: PKG, "Response status '304 Not Modified', return cached data");
cached_data
}
}
_ => {
let bytes = res.bytes().await?;
Expand Down Expand Up @@ -255,6 +260,7 @@ fn _assert_trait_object(_: &dyn AlertsInUaApi) {}

#[cfg(test)]
mod tests {
#![cfg_attr(debug_assertions, allow(dead_code, unused_imports))]

use super::*;
#[allow(unused_imports)]
Expand Down
1 change: 0 additions & 1 deletion ralertsinua-models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ license = "MIT"
edition = "2021"
authors = ["voiceapiai <[email protected]>"]
readme = "./README.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
Loading

0 comments on commit e2b5845

Please sign in to comment.