Skip to content

Commit ba07e39

Browse files
committed
chore: refactor Makefile to speed up development environment bootstrapping
[skip ci]
1 parent f1959a9 commit ba07e39

File tree

3 files changed

+73
-25
lines changed

3 files changed

+73
-25
lines changed

.pre-commit-config.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
default_stages:
3+
- pre-commit
4+
- pre-push
5+
repos:
6+
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
7+
rev: v5.0.0
8+
hooks:
9+
- id: check-json
10+
- id: check-merge-conflict
11+
- id: check-symlinks
12+
- id: check-yaml
13+
- repo: 'https://github.com/asottile/yesqa'
14+
rev: v1.5.0
15+
hooks:
16+
- id: yesqa
17+
- repo: 'https://github.com/adrienverge/yamllint'
18+
rev: v1.37.1
19+
hooks:
20+
- id: yamllint
21+
args: ['-d', 'relaxed']
22+
- repo: 'https://github.com/jorisroovers/gitlint.git'
23+
rev: v0.19.1
24+
hooks:
25+
- id: gitlint
26+
stages:
27+
- commit-msg
28+
- repo: local
29+
hooks:
30+
- id: check-dockerfile
31+
name: 'Check dockerfile'
32+
entry: 'bash -c "docker run --rm -i hadolint/hadolint < Dockerfile"'
33+
pass_filenames: false
34+
language: system
35+
types:
36+
- dockerfile

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

Makefile

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
1-
#!/usr/bin/make
2-
all: buildout
1+
VENV_FOLDER=.venv
32

4-
IMAGE_NAME=smartweb/events:latest
3+
ifeq (, $(shell which uv ))
4+
$(error "[ERROR] The 'uv' command is missing from your PATH. Install it from: https://docs.astral.sh/uv/getting-started/installation/")
5+
endif
56

6-
buildout.cfg:
7-
ln -fs dev.cfg buildout.cfg
7+
.PHONY: help
8+
help: ## Display this help message
9+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
810

9-
bin/buildout: bin/pip buildout.cfg
10-
bin/uv pip install -r requirements.txt
11+
.PHONY: install
12+
install: $(VENV_FOLDER)/bin/buildout .git/hooks/pre-commit ## Install development environment
13+
$(VENV_FOLDER)/bin/buildout
1114

12-
buildout: bin/instance
15+
.PHONY: start
16+
start: bin/instance .git/hooks/pre-commit ## Start the instance
17+
bin/instance fg
1318

14-
bin/instance: bin/buildout
15-
bin/buildout
19+
.PHONY: cleanall
20+
cleanall: ## Clean development environment
21+
rm -fr .git/hooks/pre-commit .installed.cfg .mr.developer.cfg .venv bin buildout.cfg develop-eggs downloads eggs include lib lib64 local parts pyvenv.cfg
1622

17-
bin/pip:
18-
python3.12 -m venv .
19-
bin/pip install uv
23+
.PHONY: upgrade-steps
24+
upgrade-steps: ## Run upgrade steps
25+
bin/instance -O Plone run scripts/run_portal_upgrades.py
2026

21-
run: bin/instance
22-
bin/instance fg
27+
.PHONY: lint
28+
lint: ## Run pre-commit hooks
29+
uvx pre-commit run --all
2330

24-
cleanall:
25-
rm -fr develop-eggs downloads eggs parts .installed.cfg lib lib64 include bin .mr.developer.cfg local/ share/
31+
.venv:
32+
@echo "Creating virtual environment with uv"
33+
uv venv
2634

27-
upgrade-steps:
28-
bin/instance -O plone run scripts/run_portal_upgrades.py
35+
buildout.cfg:
36+
ln -fs dev.cfg buildout.cfg
2937

30-
docker-image:
31-
docker build --pull --no-cache -t $(IMAGE_NAME) .
38+
$(VENV_FOLDER)/bin/buildout: .venv buildout.cfg
39+
@echo "Installing requirements with uv pip interface"
40+
uv pip install -r requirements.txt
3241

33-
test-image:
34-
echo "test to do"
42+
bin/instance: $(VENV_FOLDER)/bin/buildout
43+
@echo "Bootstrapping environment with buildout"
44+
$(VENV_FOLDER)/bin/buildout
3545

36-
lint:
37-
pre-commit run --all
46+
.git/hooks/pre-commit: .venv
47+
@echo "Installing pre-commit hooks"
48+
uvx pre-commit install

0 commit comments

Comments
 (0)