-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
119 lines (88 loc) · 4.02 KB
/
Makefile
File metadata and controls
119 lines (88 loc) · 4.02 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
ENGINE_DIR = .
PACKAGE_DIR = ${ENGINE_DIR}/relay
CLI_DIR = ./cli
DOCS_DIR = ./docs
PYPROJECT_CONFIG_FILE = ${ENGINE_DIR}/pyproject.toml
DOCKERFILE = ${ENGINE_DIR}/Dockerfile
PYTHON_REQ_FILE = /tmp/requirements.txt
REPO_OWNER ?= relaycli
REPO_NAME ?= relay
DOCKER_NAMESPACE ?= ghcr.io/${REPO_OWNER}
DOCKER_TAG ?= latest
DOCKER_PLATFORM ?= linux/amd64
.PHONY: help install install-quality lint-check lint-format precommit typing-check deps-check quality style init-gh-labels init-gh-settings install-mintlify start-mintlify
help: ## Show this help message
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
########################################################
# Code checks
########################################################
install: ${ENGINE_DIR} ${PYPROJECT_CONFIG_FILE} ## Install the core library
uv pip install --system -e ${ENGINE_DIR}
install-quality: ${ENGINE_DIR} ${PYPROJECT_CONFIG_FILE} ## Install with quality dependencies
uv pip install --system -e '${ENGINE_DIR}[quality]'
lint-check: ${PYPROJECT_CONFIG_FILE} ## Check code formatting and linting
ruff format --check . --config ${PYPROJECT_CONFIG_FILE}
ruff check . --config ${PYPROJECT_CONFIG_FILE}
lint-format: ${PYPROJECT_CONFIG_FILE} ## Format code and fix linting issues
ruff format . --config ${PYPROJECT_CONFIG_FILE}
ruff check --fix . --config ${PYPROJECT_CONFIG_FILE}
precommit: ${PYPROJECT_CONFIG_FILE} .pre-commit-config.yaml ## Run pre-commit hooks
pre-commit run --all-files
typing-check: ${PYPROJECT_CONFIG_FILE} ## Check type annotations
uvx ty check . --project ${ENGINE_DIR}
deps-check: .github/verify_deps_sync.py ## Check dependency synchronization
uv run .github/verify_deps_sync.py
# this target runs checks on all files
quality: lint-check typing-check deps-check ## Run all quality checks
style: lint-format precommit ## Format code and run pre-commit hooks
########################################################
# Builds
########################################################
set-version: ${PYPROJECT_CONFIG_FILE} ## Set the version in the pyproject.toml file
uv version --frozen --no-build ${BUILD_VERSION}
build: ${PYPROJECT_CONFIG_FILE} ## Build the package
uv build ${ENGINE_DIR}
publish: ${ENGINE_DIR} ## Publish the package to PyPI
uv publish --trusted-publishing always
lock: ${PYPROJECT_CONFIG_FILE}
uv lock --project ${ENGINE_DIR}
docker: ${DOCKERFILE}
docker buildx build --platform ${DOCKER_PLATFORM} -f ${DOCKERFILE} -t ${DOCKER_NAMESPACE}/${REPO_NAME}:${DOCKER_TAG} ${ENGINE_DIR}
# Docker login
docker-login:
$(eval PAT := $(shell gh auth token))
echo "${PAT}" | docker login ghcr.io -u ${REPO_OWNER} --password-stdin
docker-push: docker
docker push ${DOCKER_NAMESPACE}/${REPO_NAME}:${DOCKER_TAG}
########################################################
# Tests
########################################################
install-test: ${ENGINE_DIR} ${PYPROJECT_CONFIG_FILE} ## Install with test dependencies
uv pip install --system -e '${ENGINE_DIR}[test]'
test: ${PYPROJECT_CONFIG_FILE} ## Run the tests
pytest --cov-report xml
########################################################
# Setup GitHub
########################################################
# Clone GH labels
init-gh-labels: ## Initialize GitHub labels
gh label clone frgfm/fastemplate --repo ${REPO_OWNER}/${REPO_NAME} --force
# GitHub repo settings
init-gh-settings: ## Configure GitHub repository settings
gh repo edit ${REPO_OWNER}/${REPO_NAME} \
--delete-branch-on-merge
--enable-squash-merge
--enable-rebase-merge=false
--enable-merge-commit=false
# Push secrets to GH for deployment
push-secrets: .env
gh secret set -f .env --app actions
gh secret set -f .env --app dependabot
########################################################
# Mintlify docs
########################################################
install-mintlify: ## Install Mintlify globally
pnpm i -g mint
start-mintlify: ## Start Mintlify development server
cd ${DOCS_DIR} && mint dev