-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
86 lines (71 loc) · 2.58 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
86
.DEFAULT_GOAL := help
# Define the project directory
PROJECT_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# Define the version tag
TAG = $(shell python get_version.py)
$(info TAG = $(TAG))
# Replace +, /, _ with - to normalize the tag
# in case the tag includes a branch name
override TAG := $(subst +,-,$(TAG))
override TAG := $(subst /,-,$(TAG))
override TAG := $(subst _,-,$(TAG))
$(info TAG (Normalized) = $(TAG))
# Define the complete docker image tag
IMAGE_TAG = $(if $(CI_REGISTRY),$(CI_REGISTRY)/hip/datahipy:$(TAG),datahipy:$(TAG))
# Define the build date and vcs reference
BUILD_DATE = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
VCS_REF = $(shell git rev-parse --short HEAD)
# Define the user and user id for the docker container
USER = $(shell whoami)
USER_ID = $(shell id -u $(USER))
# Force to use buildkit for building the Docker image
export DOCKER_BUILDKIT=1
#test: @ Run all tests
.PHONY: test
test:
@echo "Running pytest tests..."
docker run -t --rm \
--entrypoint "/entrypoint_pytest.sh" \
-v $(PROJECT_DIR)/test:/test \
-v $(PROJECT_DIR)/datahipy:/apps/datahipy/datahipy \
$(IMAGE_TAG) \
$(USER) \
$(USER_ID) \
/test
@echo "Fix path in coverage xml report..."
sed -i -r \
"s|/apps/datahipy/datahipy|$(PROJECT_DIR)/datahipy|g" \
$(PROJECT_DIR)/test/report/cov.xml
#build-docker: @ Builds the Docker image
build-docker:
docker build \
-t $(IMAGE_TAG) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_REF=$(VCS_REF) \
--build-arg VERSION=$(TAG) .
#push-docker-ci: @ Push the Docker image with TAG to the CI registry
push-docker-ci:
docker push $(CI_REGISTRY)/hip/datahipy:$(TAG)
#rm-docker-ci: @ Remove the Docker image with TAG to the CI registry
# from https://docs.gitlab.com/ee/user/packages/container_registry/delete_container_registry_images.html#use-gitlab-cicd
rm-docker-ci:
./reg rm -d \
--auth-url $(CI_REGISTRY) \
-u $(CI_REGISTRY_USER) \
-p $(CI_REGISTRY_PASSWORD) \
$(CI_PROJECT_PATH):$(TAG)
#python-install: @ Installs the python package
install-python:
pip install -e .[all]
#install-python-wheel: @ Installs the python wheel
install-python-wheel: build-python-wheel
pip install datahipy
#build-python-wheel: @ Builds the python wheel
build-python-wheel:
python setup.py sdist bdist_wheel
#test-python-install: @ Tests the python package installation
test-python-install: install-python install-python-wheel
datahipy --version
#help: @ List available tasks on this project
help:
@grep -E '[a-zA-Z\.\-]+:.*?@ .*$$' $(MAKEFILE_LIST)| tr -d '#' | awk 'BEGIN {FS = ":.*?@ "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'