From 54f17cbf4e6e625905aa1e59166085d40147c626 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 24 Jun 2026 12:01:04 +0300 Subject: [PATCH] =?UTF-8?q?chore(dev):=20justfile=20(=D1=8F=D0=B4=D1=80?= =?UTF-8?q?=D0=BE)=20+=20CI-=D0=B3=D0=B5=D0=B9=D1=82=20(lint/test/deny)=20?= =?UTF-8?q?+=20rustfmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit just ci зелёный: fmt + clippy(-D warnings) + 6 unit-тестов common + cargo-deny. Co-Authored-By: Claude Opus 4.8 Signed-off-by: Alexander --- .github/workflows/ci.yml | 29 ++++++++++++++++++++++++++++ crates/shturman-common/src/atomic.rs | 10 ++++++++-- crates/shturman-common/src/paths.rs | 5 ++++- justfile | 26 +++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 justfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..48f6384 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI +on: + push: + branches: [main] + pull_request: + +jobs: + lint: + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + - run: cargo fmt --all --check + - run: cargo clippy --workspace --all-targets -- -D warnings + + test: + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo test --workspace + + license: + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@v2 diff --git a/crates/shturman-common/src/atomic.rs b/crates/shturman-common/src/atomic.rs index 2223809..5d1e03e 100644 --- a/crates/shturman-common/src/atomic.rs +++ b/crates/shturman-common/src/atomic.rs @@ -23,7 +23,10 @@ pub fn tmp_path(path: &Path) -> PathBuf { /// Атомарно и durable записать `contents` в `path`. pub fn write_atomic(path: &Path, contents: &[u8]) -> io::Result<()> { let dir = path.parent().ok_or_else(|| { - io::Error::new(io::ErrorKind::InvalidInput, "путь без родительского каталога") + io::Error::new( + io::ErrorKind::InvalidInput, + "путь без родительского каталога", + ) })?; let tmp = tmp_path(path); @@ -61,7 +64,10 @@ mod tests { write_atomic(&p, b"old").unwrap(); write_atomic(&p, b"new").unwrap(); assert_eq!(fs::read(&p).unwrap(), b"new"); - assert!(!tmp_path(&p).exists(), "осиротевший .tmp не должен оставаться"); + assert!( + !tmp_path(&p).exists(), + "осиротевший .tmp не должен оставаться" + ); } // Целостность основного файла не зависит от постороннего .tmp (rename атомарен на одной ФС). diff --git a/crates/shturman-common/src/paths.rs b/crates/shturman-common/src/paths.rs index 9a45872..e1e8be9 100644 --- a/crates/shturman-common/src/paths.rs +++ b/crates/shturman-common/src/paths.rs @@ -58,6 +58,9 @@ mod tests { assert_eq!(l.settings(), Path::new("/tmp/x/settings")); assert_eq!(l.state(), Path::new("/tmp/x/state")); assert_eq!(l.log(), Path::new("/tmp/x/log")); - assert_eq!(l.provisioned_marker(), Path::new("/tmp/x/.shturman-provisioned")); + assert_eq!( + l.provisioned_marker(), + Path::new("/tmp/x/.shturman-provisioned") + ); } } diff --git a/justfile b/justfile new file mode 100644 index 0000000..052c47e --- /dev/null +++ b/justfile @@ -0,0 +1,26 @@ +# Штурман — единые dev-команды (расширяется по планам реализации). +set shell := ["bash", "-uc"] + +# список целей +default: + @just --list + +# собрать весь воркспейс +build: + cargo build --workspace + +# тесты (unit + integration) +test: + cargo test --workspace + +# линт: формат + clippy (warnings = ошибки) +lint: + cargo fmt --all --check + cargo clippy --workspace --all-targets -- -D warnings + +# лицензии + advisories +deny: + cargo deny check + +# полный локальный гейт +ci: lint test deny