-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathMakefile
More file actions
197 lines (171 loc) · 7.07 KB
/
Copy pathMakefile
File metadata and controls
197 lines (171 loc) · 7.07 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Paude build and release automation
#
# Usage:
# make build - Build images locally (dev/testing)
# make publish - Build multi-arch and push to registry
# make release VERSION=x.y.z - Tag, update version, build, and push
# make clean - Remove local images
REGISTRY ?= quay.io/bbrowning
IMAGE_NAME = paude-base-centos10
PROXY_IMAGE_NAME = paude-proxy-centos10
# Get version from git tag, or use 'dev' if not on a tag
VERSION ?= $(shell git describe --tags --exact-match 2>/dev/null || echo "dev")
FULL_IMAGE = $(REGISTRY)/$(IMAGE_NAME):$(VERSION)
FULL_PROXY_IMAGE = $(REGISTRY)/$(PROXY_IMAGE_NAME):$(VERSION)
LATEST_IMAGE = $(REGISTRY)/$(IMAGE_NAME):latest
LATEST_PROXY_IMAGE = $(REGISTRY)/$(PROXY_IMAGE_NAME):latest
# Architectures for multi-arch builds
PLATFORMS = linux/amd64,linux/arm64
.PHONY: build run publish release clean login help test test-all test-integration test-podman install install-hooks lint format typecheck pypi-build pypi-publish
help:
@echo "Paude build targets:"
@echo " make build - Build images locally for current arch"
@echo " make run - Run paude in dev mode (builds locally)"
@echo " make test - Run all tests (unit + integration)"
@echo " make publish - Build multi-arch images and push to registry"
@echo " make release VERSION=x.y.z - Full release: tag git, update version, build, push"
@echo " make clean - Remove local paude images"
@echo " make login - Authenticate with container registry"
@echo " make pypi-build - Build Python package for PyPI"
@echo " make pypi-publish - Upload Python package to PyPI"
@echo ""
@echo "Testing targets:"
@echo " make test - Run unit tests only (default, fast)"
@echo " make test-all - Run all tests (unit + integration)"
@echo " make test-integration - Run all integration tests"
@echo " make test-podman - Run Podman integration tests (requires podman)"
@echo ""
@echo "Development targets:"
@echo " make install - Install Python package with dev dependencies"
@echo " make install-hooks - Install pre-commit hooks"
@echo " make lint - Run ruff linter"
@echo " make format - Format code with ruff"
@echo " make typecheck - Run mypy type checker"
@echo ""
@echo "Current settings:"
@echo " REGISTRY=$(REGISTRY)"
@echo " VERSION=$(VERSION)"
# Detect native architecture for builds
NATIVE_ARCH := $(shell uname -m | sed 's/x86_64/amd64/')
PYTEST := env -u NO_COLOR FORCE_COLOR=1 TERM=xterm-256color uv run pytest
# Build images locally (native arch, for development)
build:
podman build --platform linux/$(NATIVE_ARCH) -t $(IMAGE_NAME):latest ./containers/paude
podman build --platform linux/$(NATIVE_ARCH) -t $(PROXY_IMAGE_NAME):latest ./containers/proxy
# Run paude in dev mode (builds images locally)
run:
PAUDE_DEV=1 paude
# Run unit tests (default, fast - integration tests excluded via pyproject.toml)
test:
$(PYTEST) --cov=paude --cov-report=term-missing
# Run all integration tests (requires infrastructure)
test-integration:
$(PYTEST) tests/integration/ -v -m integration
# Run all tests (unit + integration, for CI)
test-all:
$(PYTEST) -o "addopts=-v" --cov=paude --cov-report=term-missing
# Run Podman integration tests
test-podman:
$(PYTEST) tests/integration/ -v -m podman
# Development targets
install:
uv sync
install-hooks:
uv run pre-commit install
lint:
uv run ruff check src tests
format:
uv run ruff format src tests
typecheck:
uv run mypy src tests
# Login to container registry
login:
@echo "Logging in to $(REGISTRY)..."
podman login quay.io
# Build and push multi-arch images
publish: check-version
@echo "Building and pushing $(FULL_IMAGE) and $(FULL_PROXY_IMAGE)..."
@echo ""
# Build and push paude image (remove any existing image/manifest first)
-podman rmi -f $(FULL_IMAGE) 2>/dev/null
-podman manifest rm $(FULL_IMAGE) 2>/dev/null
podman manifest create $(FULL_IMAGE)
podman build --platform $(PLATFORMS) --manifest $(FULL_IMAGE) ./containers/paude
podman manifest push --all $(FULL_IMAGE) $(FULL_IMAGE)
# Tag as latest
-podman rmi -f $(LATEST_IMAGE) 2>/dev/null
-podman manifest rm $(LATEST_IMAGE) 2>/dev/null
podman manifest create $(LATEST_IMAGE)
podman build --platform $(PLATFORMS) --manifest $(LATEST_IMAGE) ./containers/paude
podman manifest push --all $(LATEST_IMAGE) $(LATEST_IMAGE)
@echo ""
# Build and push proxy image
-podman rmi -f $(FULL_PROXY_IMAGE) 2>/dev/null
-podman manifest rm $(FULL_PROXY_IMAGE) 2>/dev/null
podman manifest create $(FULL_PROXY_IMAGE)
podman build --platform $(PLATFORMS) --manifest $(FULL_PROXY_IMAGE) ./containers/proxy
podman manifest push --all $(FULL_PROXY_IMAGE) $(FULL_PROXY_IMAGE)
# Tag as latest
-podman rmi -f $(LATEST_PROXY_IMAGE) 2>/dev/null
-podman manifest rm $(LATEST_PROXY_IMAGE) 2>/dev/null
podman manifest create $(LATEST_PROXY_IMAGE)
podman build --platform $(PLATFORMS) --manifest $(LATEST_PROXY_IMAGE) ./containers/proxy
podman manifest push --all $(LATEST_PROXY_IMAGE) $(LATEST_PROXY_IMAGE)
@echo ""
@echo "Published:"
@echo " $(FULL_IMAGE)"
@echo " $(FULL_PROXY_IMAGE)"
@echo " $(LATEST_IMAGE)"
@echo " $(LATEST_PROXY_IMAGE)"
check-version:
@if [ "$(VERSION)" = "dev" ]; then \
echo "Error: VERSION is 'dev'. Tag a release first or set VERSION=x.y.z"; \
exit 1; \
fi
# Strip leading 'v' from VERSION for release (accepts both "0.8.0" and "v0.8.0")
RELEASE_VERSION = $(patsubst v%,%,$(VERSION))
# Full release process
release:
@if [ "$(RELEASE_VERSION)" = "dev" ]; then \
echo "Usage: make release VERSION=x.y.z"; \
echo "Example: make release VERSION=0.2.0"; \
exit 1; \
fi
@echo "=== Releasing v$(RELEASE_VERSION) ==="
@echo ""
# Update version in pyproject.toml
sed -i.bak 's/^version = .*/version = "$(RELEASE_VERSION)"/' pyproject.toml && rm -f pyproject.toml.bak
# Update version in src/paude/__init__.py
sed -i.bak 's/^__version__ = .*/__version__ = "$(RELEASE_VERSION)"/' src/paude/__init__.py && rm -f src/paude/__init__.py.bak
# Regenerate lock file with new version
uv lock
# Commit the version change (only if there are changes)
git add pyproject.toml src/paude/__init__.py uv.lock
git diff --cached --quiet || git commit --no-verify -m "Release v$(RELEASE_VERSION)"
# Create git tag
git tag -a "v$(RELEASE_VERSION)" -m "Release v$(RELEASE_VERSION)"
@echo ""
@echo "Version updated and tagged. Now run:"
@echo " git push origin main --tags"
@echo ""
@echo "GitHub Actions will automatically:"
@echo " - Run tests"
@echo " - Build and push container images to Quay.io"
@echo " - Publish Python package to PyPI"
@echo " - Create a GitHub release"
# Build Python package for PyPI
pypi-build:
rm -rf dist/
python -m build
# Upload Python package to PyPI
pypi-publish:
python -m twine upload dist/*
# Remove local images
clean:
-podman rmi $(IMAGE_NAME):latest 2>/dev/null
-podman rmi $(PROXY_IMAGE_NAME):latest 2>/dev/null
-podman manifest rm $(FULL_IMAGE) 2>/dev/null
-podman manifest rm $(FULL_PROXY_IMAGE) 2>/dev/null
-podman manifest rm $(LATEST_IMAGE) 2>/dev/null
-podman manifest rm $(LATEST_PROXY_IMAGE) 2>/dev/null
@echo "Cleaned up local images"