Skip to content

Commit

Permalink
fix: Cleaned up Makefile, fixed broken directives and added clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
orlowskilp committed Oct 15, 2024
1 parent 181591f commit d69807a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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: |
Expand Down
22 changes: 16 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,45 +1,55 @@
# Build the library with the specified tool chain. Default is x86_64-unknown-linux-gnu
.PHONY: build
TOOL_CHAIN =
ifndef TOOL_CHAIN
TOOL_CHAIN = x86_64-unknown-linux-gnu
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
Expand All @@ -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)
@aws sts get-caller-identity &> /dev/null || (echo "AWS CLI could not assume role. Did the token expire?" && exit 1)

0 comments on commit d69807a

Please sign in to comment.