-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
44 lines (37 loc) · 1.28 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
SAM := venv/bin/sam
AWS_REGION := eu-central-1
S3_BUCKET := personio-oss-sar-rds-audit-logs-s3-$(AWS_REGION)
PACKAGED_TEMPLATE_FILE := packaged.yaml
CFN_LINT := venv/bin/cfn-lint
# Install sam & cfn-lint from requirements.txt
$(CFN_LINT): venv
$(SAM): venv
venv: requirements.txt
python3 -m venv venv
venv/bin/pip install -r requirements.txt
touch venv
# Run unit tests of Lamba function code
.PHONY: test
test:
cd lambda && go test ./... -v -race -count=1 -cover $(PACKAGES) -coverprofile=coverage.out
cd lambda && go tool cover -func=coverage.out
# Build Lambda function code
.PHONY: build
build: $(SAM)
$(SAM) build
# Lint the cloudformation template
.PHONY: cfn-lint
cfn-lint: $(CFN_LINT)
$(CFN_LINT) template.yaml
# Package AWS SAM application
.PHONY: package
package: build $(SAM)
$(SAM) package --s3-bucket $(S3_BUCKET) --region $(AWS_REGION) --output-template-file $(PACKAGED_TEMPLATE_FILE)
# Publish packaged AWS SAM template to the AWS Serverless Application Repository
.PHONY: publish
publish: guard-VERSION $(SAM)
$(SAM) publish --semantic-version $(VERSION) --template-file $(PACKAGED_TEMPLATE_FILE)
# Guard to make sure a variable is set
.PHONY: guard-%
guard-%:
$(if $(value ${*}),,$(error "Variable ${*} not set!"))