Compare commits

...

7 Commits

Author SHA1 Message Date
Christoph J. Scherr 11a2d7908e chore: just use github for ci and also add cd 2024-10-16 20:26:44 +02:00
Christoph J. Scherr 90e3442b50 chore: change ci message to fit conventional git commits 2024-10-16 13:49:50 +02:00
Christoph J. Scherr 30168c5523 chore: bump version
cargo devel CI / cargo CI (push) Successful in 1m49s Details
2024-09-08 01:34:28 +02:00
Christoph J. Scherr a7d0c18f52 chore: reset publish script
cargo devel CI / cargo CI (push) Has been cancelled Details
2024-09-08 01:27:27 +02:00
Christoph J. Scherr 54a694645f refactor(log): make logfile kinda behave like normal
cargo devel CI / cargo CI (push) Has been cancelled Details
2024-09-08 01:26:37 +02:00
Christoph J. Scherr 492e655d29 chore: bump versions
cargo devel CI / cargo CI (push) Successful in 1m50s Details
2024-09-08 01:14:35 +02:00
Christoph J. Scherr a9fbcf9518 fix(log): panic when trying to open alogfile in a dir that did not exist
cargo devel CI / cargo CI (push) Has been cancelled Details
2024-09-08 01:14:04 +02:00
10 changed files with 109 additions and 26 deletions

View File

@ -21,8 +21,6 @@ jobs:
run: |
rustup component add rustfmt
rustup component add clippy
- name: install python
run: apt update && apt install libpython3-dev -y
- name: config custom registry
run: |
mkdir -p ~/.cargo/
@ -45,4 +43,4 @@ jobs:
with:
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: automatic cargo CI changes
commit_message: "ci: automatic cargo CI changes"

7
.github/dependabot.yaml vendored Normal file
View File

@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
# Check for updates every Monday
schedule:
interval: "weekly"

View File

@ -1,10 +1,16 @@
name: cargo devel CI
name: Rust CI
on:
pull_request:
branches:
- '**'
push:
branches:
- '**'
# - '!master'
env:
CARGO_TERM_COLOR: always
jobs:
CI:
runs-on: ubuntu-latest
@ -42,10 +48,10 @@ jobs:
- name: cargo fmt
run: cargo fmt --all
- name: cargo test
run: cargo test --all-features --all-targets --workspace && cargo test --all-features --workspace --doc
run: cargo test --all-features --all-targets --workspace
- name: commit back to repository
uses: stefanzweifel/git-auto-commit-action@v5
with:
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: automatic cargo CI changes
commit_message: "ci: automatic Rust CI changes"

54
.github/workflows/release.yaml vendored Normal file
View File

@ -0,0 +1,54 @@
name: Release-plz
permissions:
pull-requests: write
contents: write
on:
push:
branches:
- master
- main
jobs:
# Release unpublished packages.
release-plz-release:
name: Release-plz release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: MarcoIeni/release-plz-action@v0.5
with:
command: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# Create a PR with the new versions and changelog, preparing the next release.
release-plz-pr:
name: Release-plz PR
runs-on: ubuntu-latest
concurrency:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: MarcoIeni/release-plz-action@v0.5
with:
command: release-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

View File

@ -5,7 +5,7 @@ default-members = [".", "members/libpt-core"]
[workspace.package]
publish = true
version = "0.7.3-alpha.0"
version = "0.7.3-alpha.2"
edition = "2021"
authors = ["Christoph J. Scherr <software@cscherr.de>"]
license = "GPL-3.0-or-later"
@ -21,8 +21,8 @@ anyhow = "1.0.79"
thiserror = "1.0.56"
libpt-core = { version = "0.5.0", path = "members/libpt-core" }
libpt-bintols = { version = "0.5.1", path = "members/libpt-bintols" }
libpt-log = { version = "0.6.2-alpha.0", path = "members/libpt-log" }
libpt-cli = { version = "0.2.2-alpha.0", path = "members/libpt-cli" }
libpt-log = { version = "0.6.2-alpha.1", path = "members/libpt-log" }
libpt-cli = { version = "0.2.2-alpha.1", path = "members/libpt-cli" }
[package]
name = "libpt"

View File

@ -1,7 +1,7 @@
[package]
name = "libpt-cli"
publish.workspace = true
version = "0.2.2-alpha.0"
version = "0.2.2-alpha.2"
edition.workspace = true
authors.workspace = true
license.workspace = true

View File

@ -1,7 +1,7 @@
[package]
name = "libpt-log"
publish.workspace = true
version = "0.6.2-alpha.0"
version = "0.6.2-alpha.2"
edition.workspace = true
authors.workspace = true
license.workspace = true

View File

@ -20,4 +20,6 @@ pub enum Error {
/// any other error type, wrapped in [`anyhow::Error`]
#[error(transparent)]
Other(#[from] anyhow::Error),
#[error("Tried to open the logfile, but logging to file was not requested")]
LogfileButNoFilelog,
}

View File

@ -151,9 +151,23 @@ impl LoggerBuilder {
));
if self.log_to_file {
tracing_subscriber::registry()
.with(layer.and_then(
tracing_subscriber::fmt::layer().with_writer(self.logfile().unwrap()),
))
.with(layer.and_then({
tracing_subscriber::fmt::layer()
.with_writer(
self.logfile()?
.expect("logging to file is requested but logfile returned None"),
)
.with_ansi(self.ansi)
.with_target(self.display_target)
.with_file(self.display_filename)
.with_thread_ids(self.display_thread_ids)
.with_line_number(self.display_line_number)
.with_thread_names(self.display_thread_names)
.with_span_events(self.span_events.clone())
.with_filter(tracing::level_filters::LevelFilter::from_level(
self.max_level,
))
}))
.init();
} else {
tracing_subscriber::registry().with(layer).init();
@ -163,25 +177,24 @@ impl LoggerBuilder {
Ok(Logger {})
}
fn logfile(&self) -> Option<std::fs::File> {
/// Opens a new file for logging to.
///
/// Format: `{log_dir}/{consumer_name}_2024-09-01.log`
///
/// Will be none if [`Self::log_to_file`] is [false].
fn logfile(&self) -> Result<Option<std::fs::File>> {
if !self.log_to_file {
return None;
return Err(Error::LogfileButNoFilelog.into());
}
let mut path = self.log_dir.clone();
std::fs::create_dir_all(&path)?;
path.push(format!(
"{}.{}.log",
"{}_{}.log",
libpt_core::get_crate_name().unwrap_or_else(|| "logfile".to_string()),
chrono::Local::now().date_naive()
));
let file = match std::fs::File::create(path) {
Ok(f) => f,
Err(e) => {
eprintln!("libpt: could not start logging to file: {e}");
return None;
}
};
Some(file)
let file = std::fs::File::create(path)?;
Ok(Some(file))
}
/// enable or disable logging to and creating of logfiles

View File

@ -1,6 +1,9 @@
#!/bin/bash
set -e
cargo check --all-features --workspace
echo ">>>>>>>> SELECT A NEW VERSION"
cargo ws version
NEW_VERSION=$(cat Cargo.toml | rg '^\s*version\s*=\s*"([^"]*)"\s*$' -or '$1')
echo ">>>>>>>> PUBLISHING RELEASE FOR REPO"
bash scripts/release.sh
echo ">>>>>>>> PUBLISHING TO CRATES.IO NEXT"