forked from mineiros-io/terraform-github-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (46 loc) · 1.67 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
# Set default shell to bash
SHELL := /bin/bash
MOUNT_TARGET_DIRECTORY = /app/src
BUILD_TOOLS_DOCKER_REPO = mineiros/build-tools
# Set default value for environment variable if there aren't set already
ifndef BUILD_TOOLS_VERSION
BUILD_TOOLS_VERSION := latest
endif
ifndef BUILD_TOOLS_DOCKER_IMAGE
BUILD_TOOLS_DOCKER_IMAGE := ${BUILD_TOOLS_DOCKER_REPO}:${BUILD_TOOLS_VERSION}
endif
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
## Display help for all targets
help:
@awk '/^[a-zA-Z_0-9%:\\\/-]+:/ { \
msg = match(lastLine, /^## (.*)/); \
if (msg) { \
cmd = $$1; \
msg = substr(lastLine, RSTART + 3, RLENGTH); \
gsub("\\\\", "", cmd); \
gsub(":+$$", "", cmd); \
printf " \x1b[32;01m%-35s\x1b[0m %s\n", cmd, msg; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST) | sort -u
.DEFAULT_GOAL := help
## Mounts the working directory inside a docker container and runs the pre-commit hooks
docker/pre-commit-hooks:
@echo "${GREEN}Start running the pre-commit hooks with docker${RESET}"
@docker run --rm \
-v ${PWD}:${MOUNT_TARGET_DIRECTORY} \
${BUILD_TOOLS_DOCKER_IMAGE} \
sh -c "pre-commit run -a"
## Mounts the working directory inside a new container and runs the Go tests. Requires $GITHUB_TOKEN and $GITHUB_ORGANIZATION to be set
docker/unit-tests:
@echo "${GREEN}Start running the unit tests with docker${RESET}"
@docker run --rm \
-e GITHUB_TOKEN \
-e GITHUB_ORGANIZATION \
-v ${PWD}:${MOUNT_TARGET_DIRECTORY} \
${BUILD_TOOLS_DOCKER_IMAGE} \
go test -v -timeout 10m -parallel 128 ./test
.PHONY: help docker/pre-commit-hooks docker/unit-tests