-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
71 lines (51 loc) · 2.54 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
all: format lint
-include .env
GS_REST_SERVICE_VERSIONM ?= "25.01.5"
GS_REST_SERVICE_VERSION ?= "1.9.5"
GS_REST_DEV_PORT ?= 9000
NUM_WORKERS ?= 1
NUM_THREADS ?= 1
test:
uv run pytest -x -rx -vv
test-all-env:
uv run tox
lint:
uv run ruff check .
format:
uv run ruff check --select I --fix
uv run ruff format
install-dev:
uv sync --all-extras --dev
pre-commit:
uv run pre-commit run --all-files
serve-old:
uv run python -m aiohttp.web -H localhost -P ${GS_REST_DEV_PORT} gsrest:main
serve:
uv run adev runserver -p ${GS_REST_DEV_PORT} --root . --app-factory main gsrest/__init__.py
build-docker:
docker build -t graphsense-rest .
serve-docker:
docker run -rm -it --network='host' -e NUM_THREADS=1 -e NUM_WORKERS=1 -v "${PWD}/instance/config.yaml:/config.yaml:Z" -e CONFIG_FILE=/config.yaml localhost/graphsense-rest:latest
generate-openapi-server: update-package-version
docker run --rm \
-v "${PWD}:/build:Z" \
-v "${PWD}/openapi_spec/templates:/templates" \
-v "${PWD}/openapi_spec/:/graphsense:Z" \
openapitools/openapi-generator-cli:v5.2.1 \
generate -i "/graphsense/graphsense.yaml" \
-g python-aiohttp \
-o /build \
-t /templates \
--additional-properties=packageVersion=$(GS_REST_SERVICE_VERSION)
yq -i 'del(.components.schemas.search_result_level1.example,.components.schemas.search_result_level2.example,.components.schemas.search_result_level3.example,.components.schemas.search_result_level4.example,.components.schemas.search_result_level5.example,.components.schemas.search_result_level6.example,.components.schemas.search_result_leaf.example)' openapi_server/openapi/openapi.yaml
run-designer:
docker run --rm -d -p 8080:8080 swaggerapi/swagger-editor
echo 'Designer UI is running on port 8080'
update-package-version: update-openapi-version
sed -i -r 's/(version = ).*/\1$(GS_REST_SERVICE_VERSION)/' pyproject.toml
update-openapi-version:
sed -i '/^info:/,/^ version:/s/^\(\s*version:\s*\).*/\1$(GS_REST_SERVICE_VERSION)/' openapi_spec/graphsense.yaml
tag-version:
-git diff --exit-code && git diff --staged --exit-code && git tag -a v$(GS_REST_SERVICE_VERSIONM) -m 'Release v$(GS_REST_SERVICE_VERSION)' || (echo "Repo is dirty please commit first" && exit 1)
git diff --exit-code && git diff --staged --exit-code && git tag -a v$(GS_REST_SERVICE_VERSION) -m 'Release v$(GS_REST_SERVICE_VERSION)' || (echo "Repo is dirty please commit first" && exit 1)
.PHONY: format lint test test-all-env serve generate-openapi-server get-openapi-spec-from-upstream serve-docker pre-commit install-dev update-openapi-version tag-version