-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (79 loc) · 3.32 KB
/
Makefile
File metadata and controls
99 lines (79 loc) · 3.32 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
GO_BIN?=$(shell pwd)/.bin
BINARY_DIR=bin
BINARY_NAME=doco-cd
.PHONY: test test-verbose test-coverage test-run build fmt lint update update-all wiki-commit download tools compose-up compose-down
ifneq (,$(wildcard ./.env))
include .env
export
endif
BUILD_FLAGS:=
ifeq ($(shell uname), Linux)
BUILD_FLAGS:=-linkmode external -extldflags '-static -Wl,-unresolved-symbols=ignore-all'
COMPILER=CGO_ENABLED=1 CC=musl-gcc
else ifeq ($(shell uname), Darwin)
BUILD_FLAGS:=""
COMPILER=CGO_ENABLED=1 CC=clang CXX=clang++
endif
BUILD_FLAGS:=-ldflags="-X main.Version=dev $(BUILD_FLAGS)"
test:
@echo "Running tests..."
@WEBHOOK_SECRET="test_Secret1" API_SECRET="test_apiSecret1" ${COMPILER} go test ${BUILD_FLAGS} -cover ./... -timeout 10m
test-nobitwarden:
@echo "Running tests without bitwarden integration..."
@WEBHOOK_SECRET="test_Secret1" API_SECRET="test_apiSecret1" ${COMPILER} go test -ldflags="-X main.Version=dev" -tags nobitwarden -cover ./... -timeout 10m
test-verbose:
@echo "Running tests..."
@WEBHOOK_SECRET="test_Secret1" API_SECRET="test_apiSecret1" ${COMPILER} go test ${BUILD_FLAGS} -v -cover ./... -timeout 10m
test-coverage:
@echo "Running tests with coverage..."
@WEBHOOK_SECRET="test_Secret1" API_SECRET="test_apiSecret1" ${COMPILER} go test ${BUILD_FLAGS} -v -coverprofile cover.out ./...
@go tool cover -html cover.out -o cover.html
# Run specified tests from arguments
test-run:
@echo "Running tests: $(filter-out $@,$(MAKECMDGOALS))"
@WEBHOOK_SECRET="test_Secret1" API_SECRET="test_apiSecret1" ${COMPILER} go test ${BUILD_FLAGS} -cover ./... -timeout 10m -run $(filter-out $@,$(MAKECMDGOALS))
build:
mkdir -p $(BINARY_DIR)
${COMPILER} go build ${BUILD_FLAGS} -o $(BINARY_DIR) ./...
lint fmt:
${GO_BIN}/golangci-lint run --fix ./...
update:
git pull origin main
git submodule update --recursive --remote
update-all: update
git submodule foreach git pull origin master
git submodule foreach git checkout master
wiki-commit:
git submodule foreach "git add . && git commit -m 'docs: update wiki' && git push"
git add docs/ && git commit -m 'docs: update wiki' && git push
download:
@echo Download go.mod dependencies
@go mod download
tools:
mkdir -p ${GO_BIN}
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b ${GO_BIN} latest
GOBIN=${GO_BIN} go install tool
compose-up:
@echo "Starting dev docker-compose..."
@docker compose -f dev.compose.yaml up --build
compose-down:
@echo "Stopping dev docker-compose..."
@docker compose -f dev.compose.yaml down --volumes
cleanup:
@CONTAINERS=$$(docker container ls --format "{{.ID}}" --filter "label=cd.doco.metadata.manager"); \
if [ -n "$$CONTAINERS" ]; then \
for PROJECT in $$(for ID in $$CONTAINERS; do docker container inspect --format '{{ index .Config.Labels "com.docker.compose.project" }}' $$ID; done | sort | uniq); do \
docker compose -p $$PROJECT down -v; \
done; \
else \
echo "No containers to clean up."; \
fi
clean-testcache:
go clean -testcache
webhook:
@SIGNATURE=$$(openssl dgst -sha256 -hmac "test_Secret1" < cmd/doco-cd/testdata/github_payload.json | sed 's/^.* //'); \
curl -X POST -H "X-Hub-Signature-256: sha256=$$SIGNATURE" \
-H "Content-Type: application/json" \
-H "X-GitHub-Event: push" \
--data @cmd/doco-cd/testdata/github_payload.json \
http://localhost/v1/webhook