-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (51 loc) · 1.92 KB
/
Makefile
File metadata and controls
71 lines (51 loc) · 1.92 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
ROOT_DIR := ../..
OS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
BIN_EXTENSION :=
ifeq ($(OS), windows)
BIN_EXTENSION := .exe
endif
BIN := conftest$(BIN_EXTENSION)
IMAGE := openpolicyagent/conftest
DOCKER := DOCKER_BUILDKIT=1 docker
DOCKER_PLATFORMS := linux/amd64,linux/arm64
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
## All of the directories that contain tests to be executed
## e.g. echo $(TEST_DIRS) prints tests/foo tests/bar
TEST_DIRS := $(patsubst tests/%/, tests/%, $(dir $(wildcard tests/**/.)))
#
##@ Development
#
.PHONY: build
build: ## Builds Conftest.
@go build -ldflags="-X github.com/open-policy-agent/conftest/internal/version.Version=${GIT_VERSION}"
.PHONY: test
test: ## Tests Conftest.
@go test -v ./...
.PHONY: test-examples
test-examples: build ## Runs the tests for the examples.
@bats acceptance.bats
.PHONY: test-acceptance
test-acceptance: build install-test-deps ## Runs the tests in the test folder.
@for testdir in $(TEST_DIRS) ; do \
echo Testing $$testdir; \
cd $(CURDIR)/$$testdir && CONFTEST=$(ROOT_DIR)/$(BIN) bats test.bats || exit 1; \
done
.PHONY: install-test-deps
install-test-deps: ## Installs dependencies required for testing.
@command -v pre-commit >/dev/null 2>&1 || python3 -m pip install -r requirements-dev.txt
.PHONY: test-oci
test-oci: ## Runs the OCI integration test for push and pull.
@./scripts/push-pull-e2e.sh
.PHONY: lint
lint: ## Lints Conftest.
@golangci-lint run --fix
.PHONY: ratchet-update
ratchet-update:
@ratchet update .github/workflows/*.yaml
.PHONY: format-docs
format-docs:
@mdformat --wrap 80 docs
.PHONY: all
all: lint build test test-examples test-acceptance ## Runs all linting and tests.
help:
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)