-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Makefile
75 lines (59 loc) · 2.86 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
all: clean dist
PACKAGE_VERSION := `cat version.txt | tr -d '\n'`
BUILD_TAG := $(shell git describe --always --dirty)
DOCKER_TEST_IMAGE := harbor.h2o.ai/h2ogpt/test-image:$(BUILD_TAG)
PYTHON_BINARY ?= `which python`
DEFAULT_MARKERS ?= "not need_tokens and not need_gpu"
.PHONY: venv dist test publish docker_build build_info.txt
clean:
rm -rf dist build h2ogpt.egg-info
venv:
$(PYTHON_BINARY) -m virtualenv -p $(PYTHON_BINARY) venv
install:
$(PYTHON_BINARY) -m pip install dist/h2ogpt-$(PACKAGE_VERSION)-py3-none-any.whl
install-%:
$(PYTHON_BINARY) -m pip install dist/h2ogpt-$(PACKAGE_VERSION)-py3-none-any.whl[$*]
dist:
$(PYTHON_BINARY) setup.py bdist_wheel
test:
$(PYTHON_BINARY) -m pip install requirements-parser
$(PYTHON_BINARY) -m pytest tests --disable-warnings --junit-xml=test_report.xml -m "$(DEFAULT_MARKERS)"
test_imports:
$(PYTHON_BINARY) -m pytest tests/test_imports.py --disable-warnings --junit-xml=test_report.xml -m "$(DEFAULT_MARKERS)"
publish:
echo "Publishing not implemented yet."
build_info.txt:
@rm -rf build_info.txt
@echo "commit=\"$(shell git rev-parse HEAD)\"" >> $@
@echo "branch=\"`git rev-parse HEAD | git branch -a --contains | grep -v detached | sed -e 's~remotes/origin/~~g' -e 's~^ *~~' | sort | uniq | tr '*\n' ' '`\"" >> $@
@echo "describe=\"`git describe --always --dirty`\"" >> $@
@echo "build_os=\"`uname -a`\"" >> $@
@echo "build_machine=\"`hostname`\"" >> $@
@echo "build_date=\"$(shell date "+%Y%m%d")\"" >> $@
@echo "build_user=\"`id -u -n`\"" >> $@
@echo "base_version=\"$(PACKAGE_VERSION)\"" >> $@
git_hash.txt:
@echo "$(shell git rev-parse HEAD)" >> $@
docker_build: build_info.txt git_hash.txt
ifeq ($(shell curl --connect-timeout 4 --write-out %{http_code} -sS --output /dev/null -X GET http://harbor.h2o.ai/api/v2.0/projects/h2ogpt/repositories/test-image/artifacts/$(BUILD_TAG)/tags),200)
@echo "Image already pushed to Harbor: $(DOCKER_TEST_IMAGE)"
else
DOCKER_BUILDKIT=1 docker build -t $(DOCKER_TEST_IMAGE) -f Dockerfile .
docker push $(DOCKER_TEST_IMAGE)
endif
just_docker_build: build_info.txt git_hash.txt
DOCKER_BUILDKIT=1 docker build -t $(DOCKER_TEST_IMAGE) -f Dockerfile .
docker_build_runner: docker_build
-docker pull $(DOCKER_TEST_IMAGE)
docker tag $(DOCKER_TEST_IMAGE) gcr.io/vorvan/h2oai/h2ogpt-runtime:$(BUILD_TAG)
docker tag $(DOCKER_TEST_IMAGE) gcr.io/vorvan/h2oai/h2ogpt-runtime:$(PACKAGE_VERSION)
docker tag $(DOCKER_TEST_IMAGE) gcr.io/vorvan/h2oai/h2ogpt-runtime:latest
docker push gcr.io/vorvan/h2oai/h2ogpt-runtime:$(BUILD_TAG)
docker push gcr.io/vorvan/h2oai/h2ogpt-runtime:$(PACKAGE_VERSION)
docker push gcr.io/vorvan/h2oai/h2ogpt-runtime:latest
ifdef BUILD_ID
docker tag $(DOCKER_TEST_IMAGE) gcr.io/vorvan/h2oai/h2ogpt-runtime:$(PACKAGE_VERSION)-$(BUILD_ID)
docker push gcr.io/vorvan/h2oai/h2ogpt-runtime:$(PACKAGE_VERSION)-$(BUILD_ID)
endif
print-%:
@echo $($*)