-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (80 loc) · 2.43 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
#
# Main Makefile for project development and CI
#
# Default shell
SHELL := /bin/bash
# Fail on first error
.SHELLFLAGS := -ec
# Global variables
ICEAXE := ./
ICEAXE_NAME := iceaxe
# Ignore these directories in the local filesystem if they exist
.PHONY: lint test
# Main lint target
lint: lint-iceaxe
# Lint validation target
lint-validation: lint-validation-iceaxe
# Testing target
test: test-iceaxe
# Install all sub-project dependencies with poetry
install-deps: install-deps-iceaxe
install-deps-iceaxe:
@echo "Installing dependencies for $(ICEAXE)..."
@(cd $(ICEAXE) && poetry install)
# Clean the current poetry.lock files, useful for remote CI machines
# where we're running on a different base architecture than when
# developing locally
clean-poetry-lock:
@echo "Cleaning poetry.lock files..."
@rm -f $(ICEAXE)/poetry.lock
# Standard linting - local development, with fixing enabled
lint-iceaxe:
$(call lint-common,$(ICEAXE),$(ICEAXE_NAME))
# Lint intended for CI usage - will fail on any errors
lint-validation-iceaxe:
$(call lint-validation-common,$(ICEAXE),$(ICEAXE_NAME))
# Tests
test-iceaxe:
(docker compose -f docker-compose.test.yml up -d)
@$(call wait-for-postgres,30,5438)
@set -e; \
$(call test-common,$(ICEAXE),$(MOUNTAINEER_PLUGINS_NAME))
(docker compose -f docker-compose.test.yml down)
#
# Common helper functions
#
define test-common
echo "Running tests for $(2)..."
@(cd $(1) && poetry run pytest -W error -vv $(test-args) $(2))
endef
define lint-common
echo "Running linting for $(2)..."
@(cd $(1) && poetry run ruff format $(2))
@(cd $(1) && poetry run ruff check --fix $(2))
echo "Running pyright for $(2)..."
@(cd $(1) && poetry run pyright $(2))
endef
define lint-validation-common
echo "Running lint validation for $(2)..."
@(cd $(1) && poetry run ruff format --check $(2))
@(cd $(1) && poetry run ruff check $(2))
echo "Running mypy for $(2)..."
@(cd $(1) && poetry run mypy $(2))
echo "Running pyright for $(2)..."
@(cd $(1) && poetry run pyright $(2))
endef
# Function to wait for PostgreSQL to be ready
define wait-for-postgres
@echo "Waiting for PostgreSQL to be ready..."
@timeout=$(1); \
while ! nc -z localhost $(2) >/dev/null 2>&1; do \
timeout=$$((timeout-1)); \
if [ $$timeout -le 0 ]; then \
echo "Timed out waiting for PostgreSQL to start on port $(2)"; \
exit 1; \
fi; \
echo "Waiting for PostgreSQL to start..."; \
sleep 1; \
done; \
echo "PostgreSQL is ready on port $(2)."
endef