-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakefile
More file actions
130 lines (110 loc) · 4.27 KB
/
makefile
File metadata and controls
130 lines (110 loc) · 4.27 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
# Makefile
APP_NAME=jiaz
PYINSTALLER_IMAGE=jiaz-builder
PYINSTALLER_SPEC=jiaz.spec
# Automatically detect architecture
ARCH ?= $(shell uname -m)
PLATFORM = $(shell \
if [ "$(ARCH)" = "arm64" ] || [ "$(ARCH)" = "aarch64" ]; then \
echo "linux/arm64"; \
elif [ "$(ARCH)" = "x86_64" ]; then \
echo "linux/amd64"; \
elif [ "$(ARCH)" = "arm" ]; then \
echo "linux/arm"; \
else \
echo "linux/amd64"; \
fi)
.PHONY: help build clean docker-build test test-cov test-cov-missing lint-black lint-isort lint-flake8 quality fix-black fix-isort fix-flake8 prepare
help:
@echo "Available targets:"
@echo " build Build standalone binary using pip and pyinstaller"
@echo " clean Remove build artifacts"
@echo " docker-build Building binary in dockerised way (only for Linux) [WIP]"
@echo " ARCH=<arch> make build Override detected architecture if needed (e.g., ARCH=amd64) [WIP]"
@echo " test Run tests for all commands"
@echo " test-cov Run tests with coverage"
@echo " test-cov-missing Run tests with coverage and show missing coverage"
@echo " lint-black Check black formatting"
@echo " lint-isort Check import sorting"
@echo " lint-flake8 Check flake8 linting"
@echo " quality Check code quality with radon"
@echo " fix-black Fix black formatting issues"
@echo " fix-isort Fix import sorting issues"
@echo " fix-flake8 Fix unused imports for flake8"
@echo " prepare Prepare downloaded binary artifact [WIP]"
docker-build: # This is yet to be worked upon
@echo "Detected ARCH: $(ARCH)"
@echo "Using PLATFORM: $(PLATFORM)"
docker build --pull --platform=$(PLATFORM) -t $(PYINSTALLER_IMAGE) -f Dockerfile .
docker run --rm \
--platform=$(PLATFORM) \
-v $(CURDIR):/app \
-w /app \
$(PYINSTALLER_IMAGE) \
-c "pip install -r requirements.txt && pyinstaller --clean $(PYINSTALLER_SPEC)"
build:
@echo "Detected ARCH: $(ARCH)"
@echo "Using PLATFORM: $(PLATFORM)"
pip install -r requirements.txt && pyinstaller --clean $(PYINSTALLER_SPEC)
test:
@echo "🔍 Running tests for jiaz project..."
pytest jiaz
test-cov:
@echo "🔍 Running tests with coverage..."
pytest --cov=jiaz
test-cov-missing:
@echo "🔍 Running tests with coverage and showing missing coverage..."
pytest --cov=jiaz --cov-report=term-missing
clean:
rm -rf build dist .coverage .coverage.* .pytest_cache
find . -type d -name "__pycache__" -exec rm -r {} +
lint-black:
@echo "🔍 Running black check..."
black --check .
@echo "✅ Black check completed"
lint-isort:
@echo "🔍 Running isort check..."
isort --check-only --settings-path=utils/config/.isort.cfg .
@echo "✅ Isort check completed"
lint-flake8:
@echo "🔍 Running flake8 check..."
flake8 jiaz/ --config=utils/config/.flake8
@echo "✅ Flake8 check completed"
quality:
@echo "🔍 Running code quality check..."
radon cc jiaz/ -a -s
@echo "✅ Code quality check completed"
fix-black:
@echo "🔧 Fixing black formatting..."
black .
@echo "✅ Black formatting fixed"
fix-isort:
@echo "🔧 Fixing isort imports..."
isort --settings-path=utils/config/.isort.cfg .
@echo "✅ Isort imports fixed"
fix-flake8:
@echo "🔧 Fixing unused imports for flake8..."
@which autoflake > /dev/null || pip install autoflake
python -m autoflake --remove-all-unused-imports --in-place --recursive jiaz/
@echo "✅ Unused imports fixed"
prepare: # This is yet to be worked upon
@echo "🔧 Preparing downloaded binary artifact..."
ifeq ($(OS),Windows_NT)
@echo "📦 Detected Windows. Unzipping downloaded artifact..."
powershell -Command "Expand-Archive -Path jiaz-windows.zip -DestinationPath ."
@echo "✅ Ready to use: ./jiaz.exe"
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
@echo "🍏 Detected macOS. Unzipping and removing quarantine attribute..."
unzip -o jiaz-macos.zip -d .
xattr -d com.apple.quarantine ./jiaz || true
@echo "✅ Ready to use: ./jiaz"
@echo "💡 To re-apply quarantine: xattr -w com.apple.quarantine '00' ./jiaz"
else
@echo "🐧 Detected Linux. Unzipping artifact..."
unzip -o jiaz-linux.zip -d .
chmod +x ./jiaz
@echo "✅ Ready to use: ./jiaz"
endif
endif