-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
80 lines (68 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
BLACK = black
BLACK_ARGS = --line-length 79
ISORT = isort
ISORT_ARGS = -rc
image := us-docker.pkg.dev/genuine-polymer-165712/codecov/codecov-slack-app
release_version := `cat VERSION`
sha := $(shell git rev-parse --short=7 HEAD)
build_date ?= $(shell git show -s --date=iso8601-strict --pretty=format:%cd $$sha)
REQUIREMENTS_TAG := requirements-v1-$(shell sha1sum requirements.txt | cut -d ' ' -f 1)-$(shell sha1sum Dockerfile.requirements | cut -d ' ' -f 1)
ENV ?= local
.PHONY: gcr.auth
gcr.auth: # Used to run the tests
gcr.auth:
gcloud auth configure-docker us-docker.pkg.dev
.PHONY: gcr.login
gcr.login: # Used to run the tests
gcr.login:
gcloud auth login
$(MAKE) gcr.auth
.PHONY: format
format: # Used to run formatting
format:
pip3 install black==22.3.0 isort
$(BLACK) $(BLACK_ARGS) .
$(ISORT) $(ISORT_ARGS) .
.PHONY: test
test: # Used to run the tests
test:
python3 -m pytest
.PHONY: build-requirements
build-requirements: # Used to build requirements image if needed
build-requirements:
# if docker pull succeeds, we have already build this version of
# requirements.txt. Otherwise, build and push a version tagged
# with the hash of this requirements.txt
docker pull ${image}:${REQUIREMENTS_TAG} || DOCKER_BUILDKIT=1 docker build \
-f Dockerfile.requirements . \
-t ${image}:${REQUIREMENTS_TAG} \
&& docker push ${image}:${REQUIREMENTS_TAG}; true
.PHONY: build
build: # Used to build the app
build:
DOCKER_BUILDKIT=1 docker build -f Dockerfile . -t ${image}:${ENV}-${release_version}-${sha} \
--build-arg REQUIREMENTS_IMAGE=${image}:${REQUIREMENTS_TAG} \
--label "org.label-schema.build-date"="$(build_date)" \
--label "org.label-schema.name"="Codecov Slack App" \
--label "org.label-schema.vendor"="Codecov" \
--label "org.label-schema.version"="${release_version}-${sha}"
.PHONY: local
local: # Used to build the local app
local:
docker pull ${image}:${REQUIREMENTS_TAG} || DOCKER_BUILDKIT=1 docker build \
-f Dockerfile.requirements . \
-t ${image}:${REQUIREMENTS_TAG}
$(MAKE) build
docker tag ${image}:${ENV}-${release_version}-${sha} ${image}:latest
.PHONY: up
up: # Used to bring up the local app
up:
touch .env
docker image inspect ${image}:${ENV}-${release_version}-${sha} &>/dev/null || $(MAKE) local
docker-compose up -d
.PHONY: push
push: # Used to build the app
push:
docker tag ${image}:${ENV}-${release_version}-${sha} ${image}:${ENV}-${release_version}-latest
docker push ${image}:${ENV}-${release_version}-${sha}
docker push ${image}:${ENV}-${release_version}-latest