-
-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathmakefile
More file actions
186 lines (151 loc) · 6.99 KB
/
makefile
File metadata and controls
186 lines (151 loc) · 6.99 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
.PHONY: help install run build push push-dev push-branch tidy clean hard_reset format check sort test coverage pr-ready update
# Detect operating system
ifeq ($(OS),Windows_NT)
# For Windows
DATA_PATH := $(shell echo %cd%)\data
else
# For Linux
DATA_PATH := $(PWD)/data
endif
BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]')
COMMIT_HASH := $(shell git rev-parse --short HEAD)
help:
@echo "make install - Install dependencies"
@echo "make run - Run the application"
@echo "make build - Build the application image"
@echo "make push - Build and push the application image to Docker Hub"
@echo "make push-dev - Build and push the dev image to Docker Hub"
@echo "make push-branch - Build and push the branch image to Docker Hub"
@echo "make tidy - Remove unused Docker images"
@echo "make clean - Clean up temporary files"
@echo "make hard_reset - Hard reset the database"
@echo "make format - Format the code"
@echo "make check - Check the code for errors"
@echo "make sort - Sort the imports"
@echo "make test - Run the tests"
@echo "make coverage - Run the tests with coverage"
@echo "make pr-ready - Run the linter and tests"
@echo "make update - Update dependencies"
# Ensure the Buildx builder is set up and support multi-arch builds
setup-builder:
@echo "Setting up Buildx builder..."
@if ! docker buildx ls | grep -q "mybuilder"; then \
echo "Creating Buildx builder..."; \
docker buildx create --use --name mybuilder --driver docker-container; \
else \
echo "Using existing Buildx builder..."; \
fi
build: setup-builder
@echo "Building application image..."
@docker buildx build --platform linux/amd64,linux/arm64 -t riven --load .
push-dev: setup-builder
@echo "Building and pushing dev image to Docker Hub..."
@docker buildx build --platform linux/amd64,linux/arm64 -t spoked/riven:dev --push .
@echo "Image 'spoked/riven:dev' pushed to Docker Hub"
push-branch: setup-builder
@echo "Building and pushing branch '${BRANCH_NAME}' image to Docker Hub..."
@docker buildx build --platform linux/amd64,linux/arm64 -t spoked/riven:${BRANCH_NAME} --push .
@echo "Image 'spoked/riven:${BRANCH_NAME}' pushed to Docker Hub"
tidy:
@echo "Removing unused Docker images..."
@docker rmi $(docker images | awk '$1 == "<none>" || $1 == "riven" {print $3}') -f
# Project environment & quality commands (uv-based)
clean:
@echo "Cleaning up temporary files..."
@find . -type f -name '*.pyc' -exec rm -f {} +
@find . -type d -name '__pycache__' -exec rm -rf {} +
@find . -type d -name '.pytest_cache' -exec rm -rf {} +
@find . -type d -name '.ruff_cache' -exec rm -rf {} +
@echo "Temporary files cleaned up"
hard_reset: clean
@echo "Hard resetting the database..."
@uv run python src/main.py --hard_reset_db
@echo "Database hard reset complete"
install:
@echo "Installing dependencies..."
@uv sync --group dev
@echo "Dependencies installed"
update:
@echo "Updating dependencies..."
@uv lock --upgrade
@uv sync --group dev
@echo "Dependencies updated"
diff:
@echo "Diffing against previous commit..."
@git diff HEAD~1 HEAD
# Run the application
run:
@uv run python src/main.py
# Code quality commands
format:
@uv run black .
check:
@uv run pyright
lint:
@uv run ruff check src
@uv run isort --check-only src
sort:
@uv run isort src
test:
@uv run pytest src
coverage: clean
@uv run pytest src --cov=src --cov-report=xml --cov-report=term
# Run the linter and tests
pr-ready: clean lint test
# OAPI generation
generate-listrr-schema:
@echo "Generating Listrr schema from OpenAPI specification..."
@rm -rf src/schemas/listrr
@uv run openapi-generator-cli generate -g python -i https://listrr.pro/swagger/v1/swagger.json -o src --skip-validate-spec --additional-properties=generateSourceCodeOnly=true,packageName=schemas.listrr,lazyImports=true
@uv run black src/schemas/listrr
@echo "Listrr schema generated"
generate-mdblist-schema:
@echo "Generating MDBList schema from API blueprint specification..."
@curl -s https://raw.githubusercontent.com/linaspurinis/api.mdblist.com/refs/heads/main/apiary.apib -o /tmp/mdblist.apib
@npx -y apib2openapi -i /tmp/mdblist.apib -o /tmp/mdblist_openapi.json
@rm -rf src/schemas/mdblist
@uv run openapi-generator-cli generate -g python -i /tmp/mdblist_openapi.json -o src --skip-validate-spec --additional-properties=generateSourceCodeOnly=true,packageName=schemas.mdblist,lazyImports=true
@uv run black src/schemas/mdblist
@echo "MDBList schema generated"
generate-overseerr-schema:
@echo "Generating Overseerr schema from OpenAPI specification..."
@rm -rf src/schemas/overseerr
@uv run openapi-generator-cli generate -g python -i https://api-docs.overseerr.dev/overseerr-api.yml -o src --skip-validate-spec --additional-properties=generateSourceCodeOnly=true,packageName=schemas.overseerr,lazyImports=true
@uv run black src/schemas/overseerr
@echo "MDBList schema generated"
generate-tmdb-schema:
@echo "Generating TMDB schema from OpenAPI specification..."
@rm -rf src/schemas/tmdb
@uv run openapi-generator-cli generate -g python -i https://developer.themoviedb.org/openapi/tmdb-api.json -o src --skip-validate-spec --additional-properties=generateSourceCodeOnly=true,packageName=schemas.tmdb,lazyImports=true
@uv run black src/schemas/tmdb
@echo "TMDB schema generated"
generate-trakt-schema:
@echo "Generating Trakt schema from API blueprint specification..."
@curl -s -L https://trakt.docs.apiary.io/api-description-document -o /tmp/trakt.apib
@npx -y apib2openapi -i /tmp/trakt.apib -o /tmp/trakt_openapi.json
@rm -rf src/schemas/trakt
@uv run openapi-generator-cli generate -g python -i /tmp/trakt_openapi.json -o src --skip-validate-spec --additional-properties=generateSourceCodeOnly=true,packageName=schemas.trakt,lazyImports=true
@uv run black src/schemas/trakt
@echo "Trakt schema generated"
generate-tvdb-schema:
@echo "Generating TVDB schema from OpenAPI specification..."
@rm -rf src/schemas/tvdb
@uv run openapi-generator-cli generate -g python -i https://thetvdb.github.io/v4-api/swagger.yml -o src --skip-validate-spec --additional-properties=generateSourceCodeOnly=true,packageName=schemas.tvdb,lazyImports=true
@uv run black src/schemas/tvdb
@echo "TVDB schema generated"
generate-prowlarr-schema:
@echo "Generating Prowlarr schema from OpenAPI specification..."
@rm -rf src/schemas/prowlarr
@uv run openapi-generator-cli generate -g python -i https://raw.githubusercontent.com/Prowlarr/Prowlarr/develop/src/Prowlarr.Api.V1/openapi.json -o src --skip-validate-spec --additional-properties=generateSourceCodeOnly=true,packageName=schemas.prowlarr,lazyImports=true
@uv run black src/schemas/prowlarr
@echo "Prowlarr schema generated"
generate-schemas:
@echo "Generating all schemas..."
@make generate-listrr-schema
@make generate-mdblist-schema
@make generate-overseerr-schema
@make generate-tmdb-schema
@make generate-trakt-schema
@make generate-tvdb-schema
@make generate-prowlarr-schema
@echo "All schemas generated"