This repository was archived by the owner on Jan 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (41 loc) · 1.66 KB
/
Makefile
File metadata and controls
55 lines (41 loc) · 1.66 KB
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
# Binary directory
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
BIN_DIR := $(abspath $(ROOT_DIR)/bin)
SOURCE_FILES := $(shell find . -type f -name '*.go')
VERSION ?= $(shell git describe | cut -c2-)
GOLANGCI_LINT_VER := v2.5.0
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(BIN_DIR)/$(GOLANGCI_LINT_BIN)
E2E_TEST_ANNONATION_METADATA ?= "test_data/annotation-metadata.yml"
policy.wasm: $(SOURCE_FILES) go.mod go.sum
GOOS=wasip1 GOARCH=wasm go build -gcflags=all="-l -B -wb=false" -ldflags="-w -s" -o policy.wasm
wasm-opt --enable-bulk-memory -Oz -o policy.wasm policy.wasm
annotated-policy.wasm: policy.wasm metadata.yml
kwctl annotate -m metadata.yml -u README.md -o annotated-policy.wasm policy.wasm
golangci-lint: $(GOLANGCI_LINT) ## Install a local copy of golang ci-lint.
$(GOLANGCI_LINT): ## Install golangci-lint.
GOBIN=$(BIN_DIR) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VER)
.PHONY: lint
lint: $(GOLANGCI_LINT)
go vet ./...
$(GOLANGCI_LINT) run
.PHONY: lint-fix
lint-fix: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --fix
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: test
test:
go test -v ./...
.PHONY: clean
clean:
go clean
rm -f policy.wasm annotated-policy.wasm
.PHONY: e2e-tests
e2e-tests: policy.wasm
# The policy annonation uses a different metadata file for testing because the
# e2e tests require access to ConfigMap to test the parameters feature.
yq eval-all 'select(fileIndex == 0) *+? select(fileIndex == 1)' metadata.yml test_data/metadata.yml > $(E2E_TEST_ANNONATION_METADATA)
kwctl annotate -m $(E2E_TEST_ANNONATION_METADATA) -u README.md -o annotated-policy.wasm policy.wasm
bats e2e.bats