From d69807a74d90a9bae47b6a7b5d162e40d8302c22 Mon Sep 17 00:00:00 2001 From: orlowskilp Date: Tue, 15 Oct 2024 09:26:49 +0800 Subject: [PATCH] fix: Cleaned up Makefile, fixed broken directives and added `clippy` --- .github/workflows/build-and-test.yml | 15 ++++++++------- Makefile | 22 ++++++++++++++++------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4a22e80..2ef8bd8 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -26,8 +26,10 @@ jobs: runs-on: ubuntu-latest env: LCOV_OUT: test-coverage.lcov + KMS_KEY_ID: ${{ secrets.KMS_KEY_ID }} steps: - - uses: actions/checkout@v4 + - name: Checkout codebase + uses: actions/checkout@v4 - name: Install llvm-cov for code coverage uses: taiki-e/install-action@cargo-llvm-cov @@ -43,13 +45,10 @@ jobs: - name: Run unit and integration tests env: LLVM_COV_ARGS: --lcov --output-path ${{ env.LCOV_OUT }} - KMS_KEY_ID: ${{ secrets.KMS_KEY_ID }} run: make test-coverage - name: Run doc tests - env: - KMS_KEY_ID: ${{ secrets.KMS_KEY_ID }} - run: make test-doc + run: make doc-test - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 @@ -62,7 +61,8 @@ jobs: name: Build for x86_64-unknown-linux-gnu runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout codebase + uses: actions/checkout@v4 - name: Build for x86_64-unknown-linux-gnu run: make build @@ -73,7 +73,8 @@ jobs: TOOL_CHAIN : x86_64-unknown-linux-musl runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout codebase + uses: actions/checkout@v4 - name: Install musl toolchain run: | diff --git a/Makefile b/Makefile index 5329152..424c23d 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +# Build the library with the specified tool chain. Default is x86_64-unknown-linux-gnu .PHONY: build TOOL_CHAIN = ifndef TOOL_CHAIN @@ -5,41 +6,50 @@ ifndef TOOL_CHAIN endif build: cargo fmt + cargo clippy cargo build --target=$(TOOL_CHAIN) --release +# Build documentation for the library .PHONY: doc doc: cargo fmt --check - cargo doc --no-deps --open + cargo doc --no-deps +# Run all tests (no coverage) .PHONY: test test: check-env cargo fmt - cargo test --lib --tests + cargo test +# Run unit and integration tests and measure coverage. Additional flags can be passed with LLVM_COV_ARGS .PHONY: test-coverage test-coverage: check-env cargo llvm-cov $(LLVM_COV_ARGS) -.PHONY: test-doc -test-doc: check-env +# Run only documentation tests (shorthand for developers) +.PHONY: doc-test +test-test: check-env cargo fmt cargo test --doc +# Run only unit tests (shorthand for developers) .PHONY: unit-test unit-test: cargo fmt cargo test --lib -.PHONY: integration-tests +# Run only integration tests (shorthand for developers) +.PHONY: integration-test integration-test: check-env cargo fmt cargo test --tests +# Clean up .PHONY: clean clean: cargo clean +# Check if the environment variables are set and STS token is valid .PHONY: check-env check-env: ifndef KMS_KEY_ID @@ -49,4 +59,4 @@ ifndef AWS_REGION $(error AWS_REGION is not set) endif @aws --version &> /dev/null || (echo "AWS CLI not installed" && exit 1) - @aws sts get-caller-identity &> /dev/null || (echo "AWS CLI not configured" && exit 1) \ No newline at end of file + @aws sts get-caller-identity &> /dev/null || (echo "AWS CLI could not assume role. Did the token expire?" && exit 1) \ No newline at end of file