-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
76 lines (57 loc) · 2.06 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
SHELL := /bin/bash
IMG ?= policy-server:latest
BINDIR ?= bin
SBOM_GENERATOR_TOOL_VERSION ?= v0.0.15
CONTAINER_PLATFORM?=linux/amd64 # or linux/arm64
SOURCE_FILES := $(shell test -e src/ && find src -type f)
target/release/policy-server: $(SOURCE_FILES) Cargo.*
cargo build --release
.PHONY: build
build: target/release/policy-server
.PHONY: fmt
fmt:
cargo fmt --all -- --check
.PHONY: lint
lint:
cargo clippy -- -D warnings
.PHONY: test
test: fmt lint
cargo test --workspace
.PHONY: unit-tests
unit-tests: fmt lint
cargo test --workspace --lib
.PHONY: integration-test
integration-tests: fmt lint
cargo test --test '*'
.PHONY: coverage
coverage: coverage-unit-tests coverage-integration-tests
.PHONY: coverage-unit-tests
coverage-unit-tests:
cargo tarpaulin --verbose --skip-clean --engine=llvm \
--all-features --lib --bin --implicit-test-threads \
--out xml --out html --output-dir coverage/unit-tests
.PHONY: coverage-integration-tests
coverage-integration-tests:
cargo tarpaulin --verbose --skip-clean --engine=llvm \
--all-features --implicit-test-threads --test integration_test \
--out xml --out html --output-dir coverage/integration-tests
.PHONY: clean
clean:
cargo clean
make -C e2e-tests clean
.PHONY: tag
tag:
@git tag "${TAG}" || (echo "Tag ${TAG} already exists. If you want to retag, delete it manually and re-run this command" && exit 1)
@git tag -s -a -m "${TAG}" "${TAG}"
.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker build --platform $(CONTAINER_PLATFORM) -t ${IMG} .
bin:
mkdir $(BINDIR)
.PHONY: download-spdx-sbom-generator
download-spdx-sbom-generator: bin
curl -L -o $(BINDIR)/spdx-sbom-generator-$(SBOM_GENERATOR_TOOL_VERSION)-linux-amd64.tar.gz https://github.com/opensbom-generator/spdx-sbom-generator/releases/download/$(SBOM_GENERATOR_TOOL_VERSION)/spdx-sbom-generator-$(SBOM_GENERATOR_TOOL_VERSION)-linux-amd64.tar.gz
tar -xf ./$(BINDIR)/spdx-sbom-generator-$(SBOM_GENERATOR_TOOL_VERSION)-linux-amd64.tar.gz --directory $(BINDIR)
.PHONY: sbom
sbom:
./$(BINDIR)/spdx-sbom-generator -f json