-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (82 loc) · 3.23 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
SHELL := /bin/bash
FOLDER = /app
CONTAINER=dev-app
TEST_CONTAINER=test-app
BUILD_CONTAINER=platformics
MAKE_TEST_APP=$(MAKE) -C test_app
### DOCKER ENV VARS #################################################
export DOCKER_BUILDKIT:=1
export COMPOSE_DOCKER_CLI_BUILD:=1
export docker_compose:=docker compose
export docker_compose_run:=docker compose run --rm
### HELPFUL #################################################
.PHONY: help
help: ## display help for this makefile
@echo "### SHARED FUNCTIONS ###"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo "### SHARED FUNCTIONS END ###"
.PHONY: codegen
codegen: build-docker-base ## Run codegen to convert the LinkML schema to a GQL API
$(docker_compose_run) $(BUILD_CONTAINER) api generate --schemafile ./schema/schema.yaml --output-prefix .
$(docker_compose_run) $(CONTAINER) black .
#$(docker_compose_run) $(CONTAINER) ruff check --fix .
.PHONY: rm-pycache
rm-pycache: ## remove all __pycache__ files (run if encountering issues with pycharm debugger (containers exiting prematurely))
find . -name '__pycache__' | xargs rm -rf
### DOCKER LOCAL DEV #########################################
.PHONY: start
start: ## Start the local dev environment.
$(MAKE_TEST_APP) start || true
cd test_app; docker compose stop graphql-api
$(docker_compose) start
.PHONY: stop
stop: ## Stop the local dev environment.
$(docker_compose) stop
$(MAKE_TEST_APP) stop
.PHONY: fix-poetry-lock
fix-poetry-lock: ## Fix poetry lockfile after merge conflict & repairing pyproject.toml
git checkout --theirs poetry.lock
$(docker_compose_run) $(CONTAINER) poetry lock --no-update
.PHONY: update-python-deps
update-python-deps: ## Update poetry.lock to reflect pyproject.toml file changes.
$(docker_compose) exec $(CONTAINER) poetry update
.PHONY: check-lint
lint: ## Check for / fix bad linting
pre-commit run --all-files
.PHONY: codegen-tests
codegen-tests: codegen ## Run tests
$(docker_compose) up -d
$(docker_compose_run) $(CONTAINER) pytest
### GitHub Actions ###################################################
.PHONY: gha-setup
gha-setup: ## Set up the environment in CI
docker swarm init
touch test_app/.moto_recording
.PHONY: build-wheel ## Create python packages and export requirements.
build-wheel:
rm -rf dist/*.whl
poetry build
# Export poetry dependency list as a requirements.txt, which makes Docker builds
# faster by not having to reinstall all dependencies every time we build a new wheel.
poetry export --without-hashes --format=requirements.txt > requirements.txt
.PHONY: build-docker-base ## Build the base docker image
build-docker-base: build-wheel
$(docker_compose) build
rm requirements.txt
.PHONY: build ## Build the base docker image and the test app docker image
build: build-docker-base
$(MAKE_TEST_APP) build
.PHONY: dev ## Launch a container suitable for developing the platformics library
dev:
$(MAKE_TEST_APP) init
cd test_app; docker compose stop graphql-api
docker compose up -d
.PHONY: clean
clean: ## Remove all build artifacts
rm -rf dist
rm -rf test_app/.moto_recording
$(docker_compose) down
$(MAKE_TEST_APP) clean
.PHONY: %
%: ## Forward all other targets to the test app
$(MAKE_TEST_APP) $@