-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (69 loc) · 1.98 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
83
84
85
# Default Go linker flags.
GO_LDFLAGS ?= -ldflags="-s -w"
# Build files.
FILE_PURGE := bin/filepurge
SAM_TEMPLATE := sam_template.yaml
# Default stack settings.
# Override these by exporting them as environment variables.
ACCOUNT_ID ?= $(shell aws sts get-caller-identity --output text --query 'Account')
AWS_REGION ?= us-west-2
STACK_NAME ?= slack-file-purge
ARTIFACTS_BUCKET ?= $(STACK_NAME)-$(ACCOUNT_ID)-$(AWS_REGION)
.PHONY: all
all: clean $(FILE_PURGE)
$(FILE_PURGE):
GOOS=linux GOARCH=arm64 go build -buildvcs=false -trimpath -tags lambda.norpc $(GO_LDFLAGS) $(BUILDARGS) -o ./bin/bootstrap ./...
chkenv-%:
@if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi
.PHONY: artifacts-bucket
artifacts-bucket:
@aws s3 mb s3://$(ARTIFACTS_BUCKET)
.PHONY: update-oauth-token
update-oauth-token: chkenv-SLACK_OAUTH_TOKEN
@aws ssm put-parameter \
--description "Insurrection Slack OAuth token" \
--name "/insurrection-slack-team/oauth-token" \
--value $(SLACK_OAUTH_TOKEN) \
--type SecureString \
--overwrite
.PHONY: package
package: clean all
aws cloudformation package \
--template-file template.yaml \
--output-template-file $(SAM_TEMPLATE) \
--s3-bucket $(ARTIFACTS_BUCKET)
.PHONY: deploy
deploy:
aws cloudformation deploy \
--stack-name $(STACK_NAME) \
--template-file $(SAM_TEMPLATE) \
--capabilities CAPABILITY_NAMED_IAM
.PHONY: vendor
vendor:
go mod tidy
go mod vendor
.PHONY: test
test:
go test -buildvcs=false -race -timeout=30s $(TESTARGS) ./...
@$(MAKE) vet
@$(MAKE) lint
.PHONY: vet
vet:
go vet -buildvcs=false $(VETARGS) ./...
.PHONY: lint
lint:
staticcheck -tags -buildvcs=false $(LINTARGS) ./...
.PHONY: install-staticcheck
install-staticcheck:
go install honnef.co/go/tools/cmd/staticcheck@latest
.PHONY: cover
cover:
@$(MAKE) test TESTARGS="-tags test -race -coverprofile=coverage.out"
@go tool cover -html=coverage.out
@rm -f coverage.out
.PHONY: clean
clean:
@rm -rf ./bin sam_template.yaml