-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
153 lines (101 loc) · 4.3 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
# Copyright (c) 2017-2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
cache_dir=.cache
proto_dir := $(cache_dir)/protos
python := poetry run python3
version := $(strip $(shell cat VERSION))
docs_src := $(shell find docs -name '*.rst') $(py_src)
docs_html_dir := dist/dazl-docs-$(version)-html
docs_html_tgz := $(docs_html_dir).tar.gz
docs_markdown_dir := dist/dazl-docs-$(version)-markdown
docs_markdown_tgz := $(docs_markdown_dir).tar.gz
packages := $(py_bdist) $(py_sdist) $(docs_html_tgz) $(docs_markdown_tgz)
####################################################################################################
# general targets
.PHONY: generate
generate: .venv/poetry.lock .cache/bin/protoc-gen-go .cache/bin/protoc-gen-go-grpc
$(python) -m _dazl update 2.9.1
####################################################################################################
# Go
.cache/bin/protoc-gen-go:
GOBIN=$(shell pwd)/.cache/bin go install google.golang.org/protobuf/cmd/[email protected]
.cache/bin/protoc-gen-go-grpc:
GOBIN=$(shell pwd)/.cache/bin go install google.golang.org/grpc/cmd/[email protected]
####################################################################################################
# Python
py_root := python
py_src_gen_root := python/dazl/_gen
py_src_core := $(shell find python/dazl -path $(py_src_gen_root) -prune -false -o -name '*.py' -o -name '*.pyi')
py_src = $(py_src_core) $(proto_gen_python_src)
py_bdist := dist/dazl-$(version)-py3-none-any.whl
py_sdist := dist/dazl-$(version).tar.gz
.PHONY: python-deps
python-deps: .venv/poetry.lock
# python: reformat all of our files
.PHONY: python-format
python-format: .venv/poetry.lock
poetry run isort python $(protos)
poetry run black python $(protos)
# python: check if files are formatted properly
.PHONY: python-format-test
python-format-test: .venv/poetry.lock
poetry run isort python $(protos) --check-only
poetry run black python $(protos) --check
# python: run mypy
.PHONY: python-typecheck
python-typecheck: .venv/poetry.lock
poetry run python3 -m mypy python $(protos) --exclude='.*_py3_10\.py$$'
# python: build BOTH $(py_bdist) and $(py_sdist)
$(py_sdist) $(py_bdist) &: $(py_src)
poetry build
# python: witness that makes sure the current venv is up to date with our lock file
.venv/poetry.lock: poetry.lock
poetry run pip install --no-color --disable-pip-version-check -U pip
poetry install --no-ansi -E pygments -E tls-testing
cp $< $@
####################################################################################################
# DAR test fixtures
_fixture_dars := $(shell scripts/make/dars -o)
.cache/make/dars.mk: scripts/make/dars $(shell scripts/make/dars -d)
@mkdir -p $(@D)
@$< -M > $@
.PHONY: dars
dars: $(_fixture_dars)
include .cache/make/dars.mk
####################################################################################################
.PHONY: help
help: ## Show list of available make targets
@cat Makefile | grep -e "^[a-zA-Z_\-]*: *.*## *" | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: clean
clean: ## Clean everything.
rm -fr .cache dist target .venv $(shell find python -name '__pycache__' -type d)
.PHONY: deps
deps: python-deps
.PHONY: build
build: $(packages) # Build everything.
.PHONY: test
test: python-format-test python-typecheck python-unit-test ## Run all tests.
.PHONY: local-ci
local-ci: ## Run the build as if it were running on CI.
circleci local execute
.PHONY: publish
publish: $(packages) ## Publish everything.
scripts/publish.sh $^
.PHONY: format
format: python-format
.PHONY: python-unit-test
python-unit-test: .venv/poetry.lock $(_fixture_dars)
poetry run pytest --log-cli-level=INFO --junitxml=target/test-results/junit.xml
.PHONY: typecheck
typecheck: python-typecheck
.PHONY: docs
docs: $(docs_html_tgz) $(docs_markdown_tgz)
.PHONY: docs-server
docs-server:
poetry run sphinx-autobuild -a -b html docs .cache/docs
$(docs_html_tgz): .venv/poetry.lock $(docs_src)
poetry run sphinx-build -b html docs $(docs_html_dir)
(cd dist && tar czf $(@F) $(notdir $(docs_html_dir)))
$(docs_markdown_tgz): .venv/poetry.lock $(docs_src)
poetry run sphinx-build -b markdown docs $(docs_markdown_dir)
(cd dist && tar czf $(@F) $(notdir $(docs_markdown_dir)))