chore(dev): justfile (ядро) + CI-гейт (lint/test/deny) + rustfmt
just ci зелёный: fmt + clippy(-D warnings) + 6 unit-тестов common + cargo-deny. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Alexander <akotenev2003@gmail.com>
This commit is contained in:
@@ -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
|
||||
@@ -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 атомарен на одной ФС).
|
||||
|
||||
@@ -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")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user