-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathMakefile
More file actions
163 lines (133 loc) · 5.91 KB
/
Makefile
File metadata and controls
163 lines (133 loc) · 5.91 KB
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
154
155
156
157
158
159
160
161
162
163
# (C) 2021 GoodData Corporation
# Load .env if it exists (staging secrets, gitignored)
-include .env
# list all full paths to files and directories in CWD containing "gooddata", filter out ones ending by "client"
NO_CLIENT_GD_PROJECTS_ABS = $(filter-out %client, $(wildcard $(CURDIR)/packages/*gooddata*))
# for each path, take only the base name of the path
NO_CLIENT_GD_PROJECTS_DIRS = $(foreach dir, $(NO_CLIENT_GD_PROJECTS_ABS), $(notdir $(dir)))
# TODO: replace API_VERSION in the future by call to API
API_VERSION="v1"
# Default: generate from localhost; use `make api-client STAGING=1` to download from remote
ifdef STAGING
BASE_URL="https://demo-cicd.cloud.gooddata.com"
else
BASE_URL="http://localhost:3000"
endif
URL="${BASE_URL}/api/${API_VERSION}/schemas"
include ci_tests.mk
# Common command components
RUFF = .venv/bin/ruff
all:
echo "Nothing here yet."
.PHONY: dev
dev:
uv sync --all-groups
.venv/bin/pre-commit install
.PHONY: lint
lint:
$(RUFF) check .
.PHONY: lint-fix
lint-fix:
$(RUFF) check . --fix
.PHONY: format
format:
$(RUFF) format --check .
.PHONY: format-fix
format-fix:
$(RUFF) format .
.PHONY: format-diff
format-diff:
$(RUFF) format --diff .
define download_client
curl "${URL}/$(1)" | jq --sort-keys > schemas/gooddata-$(1)-client.json
endef
define generate_client
./scripts/generate_client.sh gooddata-$(1)-client -f "/local/schemas/gooddata-$(1)-client.json"
endef
.PHONY: _api-client-generate
_api-client-generate:
rm -f schemas/gooddata-api-client.json
# Merge per-domain specs and strip literal NUL bytes that jq decoded from
# escapes in the source (the previous `sed '/.../d'` pattern was a no-op:
# sed BRE/ERE doesn't interpret \uNNNN, so it never matched anything).
cat schemas/gooddata-*.json | jq -S -s 'reduce .[] as $$item ({}; . * $$item) + { tags : ( reduce .[].tags as $$item (null; . + $$item) | unique_by(.name) ) }' | tr -d '\000' > "schemas/gooddata-api-client.json"
# Break the DashboardCompoundConditionItem ↔ children oneOf/allOf cycle that
# crashes openapi-generator-cli v6.6.0 with StackOverflowError in
# recursiveGetDiscriminator (its walker has no visited-set). Parent has no
# own properties, so dropping the redundant `allOf: [{$$ref: parent}]` from
# each child is semantically a no-op.
jq '(.components.schemas.DashboardCompoundComparisonCondition.allOf) |= map(select(.["$$ref"] != "#/components/schemas/DashboardCompoundConditionItem")) | (.components.schemas.DashboardCompoundRangeCondition.allOf) |= map(select(.["$$ref"] != "#/components/schemas/DashboardCompoundConditionItem"))' schemas/gooddata-api-client.json > schemas/gooddata-api-client.json.tmp && mv schemas/gooddata-api-client.json.tmp schemas/gooddata-api-client.json
$(call generate_client,api)
# Repair regex patterns of the form ^[^\x00]*$ that openapi-generator mangles
# in two ways: sometimes it drops the NUL (leaving the invalid `^[^]*$`),
# sometimes it embeds a literal NUL byte (producing a Python source that
# fails to import with SyntaxError). The helper handles both shapes.
./scripts/postprocess_api_client.py gooddata-api-client/gooddata_api_client
.PHONY: api-client
api-client: download _api-client-generate
.PHONY: api-client-local
api-client-local: _api-client-generate
.PHONY: download
download:
$(call download_client,afm)
$(call download_client,metadata)
$(call download_client,scan)
$(call download_client,"export")
$(call download_client,automation)
$(call download_client,result)
.PHONY: type-check
type-check:
RESULT=0; \
for project in $(NO_CLIENT_GD_PROJECTS_DIRS); do $(MAKE) -C packages/$${project} type-check || RESULT=$$?; done; \
exit $$RESULT
.PHONY: types
types: type-check
.PHONY: test
test:
RESULT=0; \
for project in $(NO_CLIENT_GD_PROJECTS_DIRS); do $(MAKE) -C packages/$${project} test || RESULT=$$?; done; \
exit $$RESULT
.PHONY: test-staging
test-staging:
@test -n "$(STAGING_ADMIN_TOKEN)" || (echo "ERROR: STAGING_ADMIN_TOKEN is required. Set it in .env or pass on CLI." && exit 1)
@test -n "$(STAGING_DS_PASSWORD)" || (echo "ERROR: STAGING_DS_PASSWORD is required. Set it in .env or pass on CLI." && exit 1)
$(MAKE) -C packages/gooddata-sdk test-staging TOKEN=$(STAGING_ADMIN_TOKEN) DS_PASSWORD=$(STAGING_DS_PASSWORD)
.PHONY: clean-staging
clean-staging:
@test -n "$(STAGING_ADMIN_TOKEN)" || (echo "ERROR: STAGING_ADMIN_TOKEN is required. Set it in .env or pass on CLI." && exit 1)
@test -n "$(STAGING_DS_PASSWORD)" || (echo "ERROR: STAGING_DS_PASSWORD is required. Set it in .env or pass on CLI." && exit 1)
cd packages/tests-support && STAGING=1 TOKEN="$(STAGING_ADMIN_TOKEN)" DS_PASSWORD="$(STAGING_DS_PASSWORD)" python clean_staging.py
.PHONY: load-staging
load-staging:
@test -n "$(STAGING_ADMIN_TOKEN)" || (echo "ERROR: STAGING_ADMIN_TOKEN is required. Set it in .env or pass on CLI." && exit 1)
@test -n "$(STAGING_DS_PASSWORD)" || (echo "ERROR: STAGING_DS_PASSWORD is required. Set it in .env or pass on CLI." && exit 1)
cd packages/tests-support && STAGING=1 TOKEN="$(STAGING_ADMIN_TOKEN)" DS_PASSWORD="$(STAGING_DS_PASSWORD)" python upload_demo_layout.py
.PHONY: release
release:
if [ -z "$(VERSION)" ]; then echo "Usage: 'make release VERSION=X.Y.Z'"; false; else \
uv run tbump $(VERSION) --no-tag --no-push ; fi
.PHONY: release-ci
release-ci:
if [ -z "$(VERSION)" ]; then echo "Usage: 'make release-ci VERSION=X.Y.Z'"; false; else \
uv run tbump $(VERSION) --only-patch --non-interactive && uv lock ; fi
.PHONY: check-copyright
check-copyright:
uv run ./scripts/check_copyright.py FOLDER
.PHONY: docs
docs:
RESULT=0; \
for project in gooddata-fdw gooddata-pandas; do $(MAKE) -C packages/$${project} $@ || RESULT=$$?; done; \
exit $$RESULT
.PHONY: remove-cassettes
remove-cassettes:
RESULT=0; \
for project in $(NO_CLIENT_GD_PROJECTS_DIRS); do $(MAKE) -C packages/$${project} $@ || RESULT=$$?; done; \
exit $$RESULT
.PHONY: test-docs-scripts
test-docs-scripts:
uv run pytest scripts/docs/tests/ -v
.PHONY: new-docs
new-docs:
cd docs; \
npm install; \
hugo server