forked from superduper-io/superduper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
154 lines (107 loc) · 5.53 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
PYTEST_ARGUMENTS ?=
DIRECTORIES = superduperdb test
##@ General
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'.
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
.DEFAULT_GOAL := help
help: ## Display this help
@cat ./apidocs/banner.txt
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
# RELEASE_VERSION defines the project version for the operator.
# Update this value when you upgrade the version of your project.
# The general flow is VERSION -> make new-release -> GITHUB_ACTIONS -> {make docker_push, ...}
RELEASE_VERSION=$(shell cat VERSION)
##@ Release Management
new-release: ## Release a new SuperDuperDB version
@ if [[ -z "${RELEASE_VERSION}" ]]; then echo "VERSION is not set"; exit 1; fi
@ if [[ "${RELEASE_VERSION}" == "${TAG}" ]]; then echo "no new release version. Please update VERSION file."; exit 1; fi
@echo "** Switching to branch release-${RELEASE_VERSION}"
@git checkout -b release-${RELEASE_VERSION}
@echo "** Change superduperdb/__init__.py to version $(RELEASE_VERSION:v%=%)"
@sed -ie "s/^__version__ = .*/__version__ = '$(RELEASE_VERSION:v%=%)'/" superduperdb/__init__.py
@git add superduperdb/__init__.py
@echo "** Change deploy/docker-compose/demo to version $(RELEASE_VERSION:v%=%)"
sed -ie "s/superduperdb\/superduperdb:.*/superduperdb\/superduperdb:$(RELEASE_VERSION:v%=%)/" deploy/docker-compose/demo.yaml
@git add deploy/docker-compose/demo.yaml
@echo "** Commit Bump Version and Tags"
@git add VERSION
@git commit -m "Bump Version $(RELEASE_VERSION:v%=%)"
@git tag ${RELEASE_VERSION}
@echo "** Push release-${RELEASE_VERSION}"
git push --set-upstream origin release-${RELEASE_VERSION} --tags
docker-build: ## Build minimal SuperDuperDB image.
echo "===> Build superduper:$(RELEASE_VERSION:v%=%)"; \
docker build ./deploy/images/superduperdb -t superduperdb/superduperdb:$(RELEASE_VERSION:v%=%) --progress=plain --no-cache
docker-push: ## Push the latest SuperDuperDB image
@echo "===> Set SuperDuperDB:$(RELEASE_VERSION:v%=%) as the latest <==="
docker tag superduperdb/superduperdb:$(RELEASE_VERSION:v%=%) superduperdb/superduperdb:latest
@echo "===> Release SuperDuperDB:$(RELEASE_VERSION:v%=%) Container <==="
docker push superduperdb/superduperdb:$(RELEASE_VERSION:v%=%)
@echo "===> Release SuperDuperDB:latest Container <==="
docker push superduperdb/superduperdb:latest
##@ CI Functions
mongo_init: ## Initialize a local MongoDB setup
docker compose -f test/material/docker-compose.yml up mongodb mongo-init -d $(COMPOSE_ARGUMENTS)
mongo_shutdown: ## Terminate the local MongoDB setup
docker compose -f test/material/docker-compose.yml down $(COMPOSE_ARGUMENTS)
test: mongo_init ## Perform unit testing
pytest $(PYTEST_ARGUMENTS)
clean-test: mongo_shutdown ## Clean-up unit testing environment
fix-and-test: mongo_init ## Lint before testing
isort $(DIRECTORIES)
black $(DIRECTORIES)
ruff check --fix $(DIRECTORIES)
mypy superduperdb
pytest $(PYTEST_ARGUMENTS)
interrogate superduperdb
test-and-fix: mongo_init ## Test before linting.
mypy superduperdb
pytest $(PYTEST_ARGUMENTS)
black $(DIRECTORIES)
ruff check --fix $(DIRECTORIES)
interrogate superduperdb
lint-and-type-check: ## Lint your code
mypy superduperdb
black --check $(DIRECTORIES)
ruff check $(DIRECTORIES)
interrogate superduperdb
test-notebooks: ## Test notebooks (arg: NOTEBOOKS=<path_to_files>)
@if [ -n "${NOTEBOOKS}" ]; then \
pytest --nbval ${NOTEBOOKS}; \
fi
##@ Local Testing
# sandbox is a bloated image that contains everything we will need.
# we don't need to expose this one to the tuser.
build-sandbox: ## Build a SuperDuperDB image with all the extras.
echo "===> Build superduper-full:$(RELEASE_VERSION:v%=%)"
docker build ./deploy/images/superduperdb -t superduperdb/sandbox:$(RELEASE_VERSION:v%=%) --progress=plain --build-arg SUPERDUPERDB_EXTRAS="apis,docs,lint,tests,typing,torch"
run-sandbox-pr: ## Run PR in sandbox (arg: PR_NUMBER=555)
@if [[ -z "${PR_NUMBER}" ]]; then echo "Usage: make run-sandbox-pr PR_NUMBER=<pull-request-number>"; exit -1; fi
@echo "===> Checkout Pull Request #"${PR_NUMBER}" <==="
# checkout remote repo.
git clone --depth 1 --single-branch [email protected]:SuperDuperDB/superduperdb.git /tmp/superduperdb_pr_$(PR_NUMBER)
# fetch specific pr
cd /tmp/superduperdb_pr_$(PR_NUMBER) && \
git fetch --depth 1 origin pull/$(PR_NUMBER)/head:pr_branch && \
git checkout pr_branch
# mount pr to sandbox
docker run -p 8888:8888 -v /tmp/superduperdb_pr_$(PR_NUMBER):/home/superduper/code superduperdb/sandbox:$(RELEASE_VERSION:v%=%)
# clean up the tmp directory
rm -rf /tmp/superduperdb_pr_$(PR_NUMBER)
##@ Demo
run-demo: ## Run SuperDuperDB demo on docker-compose
@echo "===> Run SuperDuperDB Demo <==="
# TODO: make it take as argument the TAG of desired image.
docker compose -f ./deploy/docker-compose/demo.yaml up
##@ Documentation
documentation: ## Generate Sphinx inline-API HTML documentation, including API docs
@echo "===> Generate Sphinx HTML documentation, including API docs <==="
rm -rf apidocs/source/
rm -rf docs/build/apidocs
sphinx-apidoc -f -o apidocs/source superduperdb
sphinx-build -a apidocs docs/build/apidocs
@echo "Build finished. The HTML pages are in docs/build/apidocs"