mirror of
https://github.com/imjasonh/krust
synced 2026-07-21 14:48:39 +00:00
refactor: Centralize test flags and commands in Makefile
- Add TEST_FLAGS variable for single-threaded test execution - Create verbose targets for CI usage - Update pre-commit hooks to use make targets - Update CI workflow to use make targets - This ensures consistency between local and CI test execution 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c5b7bc1236
commit
e15bd1df8c
3 changed files with 33 additions and 24 deletions
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
|
|
@ -44,17 +44,7 @@ jobs:
|
|||
with:
|
||||
path: target
|
||||
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Setup cargo config for cross-compilation
|
||||
run: |
|
||||
mkdir -p .cargo
|
||||
cat > .cargo/config.toml << 'EOF'
|
||||
[target.x86_64-unknown-linux-musl]
|
||||
linker = "x86_64-linux-musl-gcc"
|
||||
|
||||
[target.aarch64-unknown-linux-musl]
|
||||
linker = "aarch64-linux-gnu-gcc"
|
||||
EOF
|
||||
- name: Verify cross-compilation setup (Unix)
|
||||
- name: Verify cross-compilation setup
|
||||
run: |
|
||||
echo "Installed targets:"
|
||||
rustup target list --installed
|
||||
|
|
@ -71,11 +61,11 @@ jobs:
|
|||
echo "Cargo config:"
|
||||
cat .cargo/config.toml || echo "No cargo config found"
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
run: make build-verbose
|
||||
- name: Run unit tests
|
||||
run: cargo test --verbose -- --test-threads=1
|
||||
run: make test-verbose
|
||||
- name: Run e2e tests
|
||||
run: cargo test --test '*' --verbose -- --test-threads=1
|
||||
run: make test-e2e-verbose
|
||||
|
||||
fmt:
|
||||
name: Rustfmt
|
||||
|
|
@ -88,7 +78,7 @@ jobs:
|
|||
toolchain: stable
|
||||
components: rustfmt
|
||||
- name: Check formatting
|
||||
run: cargo fmt -- --check
|
||||
run: make check-fmt
|
||||
|
||||
clippy:
|
||||
name: Clippy
|
||||
|
|
@ -101,7 +91,7 @@ jobs:
|
|||
toolchain: stable
|
||||
components: clippy
|
||||
- name: Run clippy
|
||||
run: cargo clippy -- -D warnings
|
||||
run: make lint
|
||||
|
||||
security-audit:
|
||||
name: Security Audit
|
||||
|
|
|
|||
|
|
@ -4,35 +4,35 @@ repos:
|
|||
hooks:
|
||||
- id: rustfmt
|
||||
name: rustfmt
|
||||
entry: cargo fmt -- --check
|
||||
entry: make check-fmt
|
||||
language: system
|
||||
types: [rust]
|
||||
pass_filenames: false
|
||||
|
||||
- id: clippy
|
||||
name: clippy
|
||||
entry: cargo clippy -- -D warnings
|
||||
entry: make lint
|
||||
language: system
|
||||
types: [rust]
|
||||
pass_filenames: false
|
||||
|
||||
- id: cargo-check
|
||||
name: cargo check
|
||||
entry: cargo check
|
||||
entry: make check-code
|
||||
language: system
|
||||
types: [rust]
|
||||
pass_filenames: false
|
||||
|
||||
- id: cargo-test
|
||||
name: cargo test
|
||||
entry: cargo test -- --test-threads=1
|
||||
entry: make test-unit
|
||||
language: system
|
||||
types: [rust]
|
||||
pass_filenames: false
|
||||
|
||||
- id: cargo-test-e2e
|
||||
name: cargo e2e tests
|
||||
entry: cargo test --test '*' -- --test-threads=1
|
||||
entry: make test-e2e
|
||||
language: system
|
||||
types: [rust]
|
||||
pass_filenames: false
|
||||
|
|
|
|||
25
Makefile
25
Makefile
|
|
@ -1,9 +1,16 @@
|
|||
.PHONY: test test-unit test-e2e build run clean fmt lint
|
||||
.PHONY: test test-unit test-e2e build run clean fmt lint check-fmt check test-verbose
|
||||
|
||||
# Test flags - run single-threaded to avoid env var races
|
||||
TEST_FLAGS := -- --test-threads=1
|
||||
|
||||
# Build the project
|
||||
build:
|
||||
cargo build
|
||||
|
||||
# Build verbosely
|
||||
build-verbose:
|
||||
cargo build --verbose
|
||||
|
||||
# Run the project
|
||||
run:
|
||||
cargo run
|
||||
|
|
@ -11,13 +18,21 @@ run:
|
|||
# Run all tests
|
||||
test: test-unit test-e2e
|
||||
|
||||
# Run all tests verbosely (for CI)
|
||||
test-verbose:
|
||||
cargo test --verbose $(TEST_FLAGS)
|
||||
|
||||
# Run unit tests only
|
||||
test-unit:
|
||||
cargo test --lib --bins
|
||||
cargo test --lib --bins $(TEST_FLAGS)
|
||||
|
||||
# Run e2e tests only
|
||||
test-e2e:
|
||||
cargo test --test '*'
|
||||
cargo test --test '*' $(TEST_FLAGS)
|
||||
|
||||
# Run e2e tests verbosely (for CI)
|
||||
test-e2e-verbose:
|
||||
cargo test --test '*' --verbose $(TEST_FLAGS)
|
||||
|
||||
# Clean build artifacts
|
||||
clean:
|
||||
|
|
@ -35,5 +50,9 @@ lint:
|
|||
check-fmt:
|
||||
cargo fmt -- --check
|
||||
|
||||
# Check code (for pre-commit)
|
||||
check-code:
|
||||
cargo check
|
||||
|
||||
# Run all checks (format, lint, test)
|
||||
check: check-fmt lint test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue