forked from 1dustindavis/gorilla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
157 lines (131 loc) · 6.04 KB
/
Makefile
File metadata and controls
157 lines (131 loc) · 6.04 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
all: build
.PHONY: build bootstrap bootstrap-run manual-test-server test ui-lint ui-test lint clean help
ifndef ($(GOPATH))
GOPATH = $(HOME)/go
endif
PATH := $(GOPATH)/bin:$(PATH)
VERSION = $(shell git describe --tags --always --dirty)
VERSION_NO_PREFIX = $(patsubst v%,%,$(VERSION))
MSI_VERSION = $(word 1,$(subst +, ,$(word 1,$(subst -, ,$(VERSION_NO_PREFIX)))))
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
REVISION = $(shell git rev-parse HEAD)
REVSHORT = $(shell git rev-parse --short HEAD)
APP_NAME = gorilla
MANUAL_TEST_DIR = build/manual-test
MANUAL_TEST_SERVER_ROOT = ${MANUAL_TEST_DIR}/server-root
MANUAL_TEST_VM_DIR = ${MANUAL_TEST_DIR}/vm
MANUAL_TEST_BASE_URL ?=
GO111MODULE = on
ifneq ($(OS), Windows_NT)
CURRENT_PLATFORM = linux
# If on macOS, set the shell to bash explicitly
ifeq ($(shell uname), Darwin)
SHELL := /bin/bash
CURRENT_PLATFORM = darwin
endif
# To populate version metadata, we use unix tools to get certain data
GOVERSION = $(shell go version | awk '{print $$3}')
NOW = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
else
CURRENT_PLATFORM = windows
# To populate version metadata, we use windows tools to get the certain data
GOVERSION_CMD = "(go version).Split()[2]"
GOVERSION = $(shell powershell $(GOVERSION_CMD))
NOW = $(shell powershell Get-Date -format s)
endif
BUILD_VERSION = "\
-X github.com/1dustindavis/gorilla/pkg/version.appName=${APP_NAME} \
-X github.com/1dustindavis/gorilla/pkg/version.version=${VERSION} \
-X github.com/1dustindavis/gorilla/pkg/version.branch=${BRANCH} \
-X github.com/1dustindavis/gorilla/pkg/version.buildDate=${NOW} \
-X github.com/1dustindavis/gorilla/pkg/version.revision=${REVISION} \
-X github.com/1dustindavis/gorilla/pkg/version.goVersion=${GOVERSION}"
define HELP_TEXT
Makefile commands
make deps - Install dependent programs and libraries
make clean - Delete all build artifacts
make build - Build the code
make msi - Build Windows MSI (requires WiX on Windows)
make bootstrap - Build manual-test assets/server and generate VM scripts
make bootstrap-run - Build manual-test assets/server and run local test server
make test - Run the Go tests
make ui-lint - Run Gorilla UI formatting/analyzer validation
make ui-test - Run the Gorilla UI (.NET) tests
make lint - Run the Go linters
endef
help:
$(info $(HELP_TEXT))
gomodcheck:
@go help mod > /dev/null || (@echo gorilla requires Go version 1.11 or higher && exit 1)
clean:
rm -rf build/
rm -rf gorilla-ui/src/Gorilla.UI.Client/bin/
rm -rf gorilla-ui/src/Gorilla.UI.Client/obj/
rm -rf gorilla-ui/tests/Gorilla.UI.Client.Tests/bin/
rm -rf gorilla-ui/tests/Gorilla.UI.Client.Tests/obj/
rm -rf gorilla-ui/tests/Gorilla.UI.Client.Tests/TestResults/
rm -rf gorilla-ui/tools/PipeHarness/bin/
rm -rf gorilla-ui/tools/PipeHarness/obj/
rm -rf gorilla-ui/src/Gorilla.UI.App/AppPackages/
rm -rf gorilla-ui/src/Gorilla.UI.App/bin/
rm -rf gorilla-ui/src/Gorilla.UI.App/obj/
.pre-build: gomodcheck
mkdir -p build/
build: .pre-build
GOOS=windows GOARCH=amd64 go build -o build/${APP_NAME}.exe -ldflags ${BUILD_VERSION} ./cmd/gorilla
msi: build
ifeq ($(OS), Windows_NT)
powershell -Command "$$env:PRODUCT_VERSION='${MSI_VERSION}'; cd wix; ./make-msi.bat"
else
@echo "msi target requires Windows and WiX"
@exit 1
endif
manual-test-server: .pre-build
cd utils/manual-test/server && go build -o ../../../build/manual-test-server .
bootstrap: build manual-test-server
mkdir -p ${MANUAL_TEST_SERVER_ROOT}/manifests
mkdir -p ${MANUAL_TEST_SERVER_ROOT}/catalogs
mkdir -p ${MANUAL_TEST_SERVER_ROOT}/packages
mkdir -p ${MANUAL_TEST_VM_DIR}
cp build/${APP_NAME}.exe ${MANUAL_TEST_SERVER_ROOT}/gorilla.exe
cp examples/example_manifest.yaml ${MANUAL_TEST_SERVER_ROOT}/manifests/example_manifest.yaml
cp examples/example_catalog.yaml ${MANUAL_TEST_SERVER_ROOT}/catalogs/example_catalog.yaml
cp utils/manual-test/bootstrap-vm.ps1 ${MANUAL_TEST_VM_DIR}/bootstrap-vm.ps1
cp utils/manual-test/bootstrap-vm-full.ps1 ${MANUAL_TEST_VM_DIR}/bootstrap-vm-full.ps1
cp utils/manual-test/templates/run-gorilla-check.bat ${MANUAL_TEST_VM_DIR}/run-gorilla-check.bat
cp utils/manual-test/run-release-integration.bat ${MANUAL_TEST_VM_DIR}/run-release-integration.bat
@BASE_URL="${MANUAL_TEST_BASE_URL}"; \
if [ -z "$$BASE_URL" ]; then \
if [ "$(CURRENT_PLATFORM)" = "darwin" ]; then \
IFACE=$$(route -n get default 2>/dev/null | awk '/interface:/{print $$2}' | head -n1); \
IP_ADDR=$$(ipconfig getifaddr "$$IFACE" 2>/dev/null || true); \
elif [ "$(CURRENT_PLATFORM)" = "linux" ]; then \
IP_ADDR=$$(hostname -I 2>/dev/null | awk '{print $$1}'); \
else \
IP_ADDR=""; \
fi; \
if [ -z "$$IP_ADDR" ]; then IP_ADDR="localhost"; fi; \
BASE_URL="http://$$IP_ADDR:8080/"; \
fi; \
sed 's#@DEFAULT_BASE_URL@#'"$$BASE_URL"'#g' utils/manual-test/templates/bootstrap-vm.bat > ${MANUAL_TEST_VM_DIR}/bootstrap-vm.bat; \
sed 's#@DEFAULT_BASE_URL@#'"$$BASE_URL"'#g' utils/manual-test/templates/bootstrap-vm-full.bat > ${MANUAL_TEST_VM_DIR}/bootstrap-vm-full.bat; \
echo "$$BASE_URL" > ${MANUAL_TEST_VM_DIR}/base-url.txt; \
echo "Using manual-test base URL: $$BASE_URL"
@echo "Prepared manual-test assets in ${MANUAL_TEST_SERVER_ROOT}"
@echo "Run: ./build/manual-test-server -root ${MANUAL_TEST_SERVER_ROOT} -addr :8080"
@echo "Generated VM scripts in ${MANUAL_TEST_VM_DIR}"
bootstrap-run: bootstrap
./build/manual-test-server -root ${MANUAL_TEST_SERVER_ROOT} -addr :8080
test: gomodcheck
go test -cover -race ./...
ui-lint:
dotnet build gorilla-ui/src/Gorilla.UI.Client/Gorilla.UI.Client.csproj -warnaserror
dotnet build gorilla-ui/tests/Gorilla.UI.Client.Tests/Gorilla.UI.Client.Tests.csproj -warnaserror
dotnet build gorilla-ui/tools/PipeHarness/PipeHarness.csproj -warnaserror
ui-test:
dotnet test gorilla-ui/tests/Gorilla.UI.Client.Tests/Gorilla.UI.Client.Tests.csproj
lint:
@if gofmt -l -s ./cmd/ ./pkg/ | grep .go; then \
echo "^- Repo contains improperly formatted go files; run gofmt -w -s *.go" && exit 1; \
else echo "All .go files formatted correctly"; fi
GOOS=windows GOARCH=amd64 go vet ./...