This repository has been archived by the owner on Sep 16, 2022. It is now read-only.
forked from ghostunnel/ghostunnel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
65 lines (54 loc) · 2.02 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
SOURCE_FILES := $(shell find . \( -name '*.go' -not -path './vendor/*' \))
INTEGRATION_TESTS := $(shell find tests -name 'test-*.py' -exec basename {} .py \;)
VERSION := $(shell git describe --always --dirty)
# Ghostunnel binary
ghostunnel: $(SOURCE_FILES)
go build -ldflags '-X main.version=${VERSION}' -o ghostunnel .
# Ghostunnel binary with certstore enabled
ghostunnel.certstore: $(SOURCE_FILES)
go build -tags certstore -ldflags '-X main.version=${VERSION}' -o ghostunnel.certstore .
# Man page
ghostunnel.man: ghostunnel
./ghostunnel --help-custom-man > $@
# Test binary with coverage instrumentation
ghostunnel.test: $(SOURCE_FILES)
go test -c -covermode=count -coverpkg .,./auth,./certloader,./proxy,./wildcard,./socket
# Clean build output
clean:
rm -rf ghostunnel *.out */*.out ghostunnel.test tests/__pycache__
.PHONY: clean
# Run all tests (unit + integration tests)
test: unit $(INTEGRATION_TESTS)
gocovmerge *.out */*.out > coverage-merged.out
@echo "PASS"
.PHONY: test
# Run unit tests
unit:
go test -v -covermode=count -coverprofile=coverage-unit-test.out ./...
.PHONY: unit
# Run integration tests
$(INTEGRATION_TESTS): ghostunnel.test
@cd tests && ./runner.py $@
.PHONY: $(INTEGRATION_TESTS)
# Import test keys into SoftHSM (v2)
softhsm-import:
softhsm2-util --init-token --slot 0 \
--label ${GHOSTUNNEL_TEST_PKCS11_LABEL} \
--so-pin ${GHOSTUNNEL_TEST_PKCS11_PIN} \
--pin ${GHOSTUNNEL_TEST_PKCS11_PIN}
softhsm2-util --id 01 \
--token ${GHOSTUNNEL_TEST_PKCS11_LABEL} \
--label ${GHOSTUNNEL_TEST_PKCS11_LABEL} \
--so-pin ${GHOSTUNNEL_TEST_PKCS11_PIN} \
--pin ${GHOSTUNNEL_TEST_PKCS11_PIN} \
--import test-keys/server-pkcs8.pem
.PHONY: softhsm-import
# Build Docker image
docker-build:
docker build -t squareup/ghostunnel .
.PHONY: docker-build
# Run unit and integration tests in Docker container
docker-test:
docker build --build-arg GO_VERSION=${GO_VERSION} -t squareup/ghostunnel-test -f Dockerfile-test .
docker run -v ${PWD}:/go/src/github.com/square/ghostunnel squareup/ghostunnel-test
.PHONY: docker-test