-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
82 lines (65 loc) · 2.49 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
export GO111MODULE=on
BUILD_TAG = $(shell git describe --abbrev=0 master)
BUILD_HASH = $(shell git rev-parse HEAD)
BUILD_HASH_SHORT = $(shell git rev-parse --short HEAD)
LDFLAGS += -X "github.com/mattermost/mattermost-marketplace/internal/api.buildTag=$(BUILD_TAG)"
LDFLAGS += -X "github.com/mattermost/mattermost-marketplace/internal/api.buildHash=$(BUILD_HASH)"
LDFLAGS += -X "github.com/mattermost/mattermost-marketplace/internal/api.buildHashShort=$(BUILD_HASH_SHORT)"
LDFLAGS += -X "main.upstreamURL=$(BUILD_UPSTREAM_URL)"
SLS_STAGE ?= "dev"
$(shell cp plugins.json ./cmd/lambda/)
## Checks the code style, tests, builds and bundles.
all: check-style test build
## Runs go vet and golangci-lint against all packages.
.PHONY: check-style
check-style:
go vet ./...
# https://stackoverflow.com/a/677212/1027058 (check if a command exists or not)
@if ! [ -x "$$(command -v golangci-lint)" ]; then \
echo "golangci-lint is not installed. Please see https://github.com/golangci/golangci-lint#install for installation instructions."; \
exit 1; \
fi; \
golangci-lint run ./...
## Runs test against all packages.
.PHONY: test
test:
go test -ldflags="$(LDFLAGS)" ./...
## Build builds the various commands
.PHONY: build
build: build-server build-lambda
## Compile the server for the current platform.
.PHONY: build-server
build-server:
go build -ldflags="$(LDFLAGS)" -o dist/marketplace ./cmd/marketplace/
## Run the Plugin Marketplace
.PHONY: run
run: run-server
## Run the Plugin Marketplace
.PHONY: run-server
run-server:
go run -ldflags="$(LDFLAGS)" ./cmd/marketplace server
## Compile the server as a lambda function
.PHONY: build-lambda
build-lambda:
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w $(LDFLAGS)" -tags lambda.norpc -o dist/bootstrap ./cmd/lambda/
## Package the lambda binary into a .zip artifact
.PHONY: package-artifact
package-artifact:
zip -j dist/mattermost-marketplace.zip dist/bootstrap
## Deploy the lambda stack
.PHONY: deploy-lambda
deploy-lambda: clean build-lambda package-artifact
serverless deploy --verbose --stage $(SLS_STAGE)
## Deploy the lambda function only to an existing stack
.PHONY: deploy-lambda-fast
deploy-lambda-fast: clean build-lambda package-artifact
serverless deploy function -f server --stage $(SLS_STAGE)
## Update plugins.json
.PHONY: plugins.json
plugins.json:
@echo "This command is deprecated. Use go run ./cmd/generator/ add instead."
go run ./cmd/generator --database plugins.json --debug
## Clean all generated files
.PHONY: clean
clean:
rm -rf ./dist