mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-08-10 07:20:39 -04:00
Makefile improvements + pre-commit hook (#340)
* Makefile improvements + pre-commit hook * update make target in CI * fix CI more * .gitignore update * couple more Makefile refinements * make target-version explicit on ruff import sorting
This commit is contained in:
parent
f64db214d4
commit
65b0b5f50b
4 changed files with 71 additions and 10 deletions
8
.github/workflows/python-formatting.yml
vendored
8
.github/workflows/python-formatting.yml
vendored
|
@ -20,12 +20,12 @@ jobs:
|
||||||
with:
|
with:
|
||||||
python-version: '3.8'
|
python-version: '3.8'
|
||||||
- name: Create virtual environment
|
- name: Create virtual environment
|
||||||
run: python -m venv venv
|
run: python -m venv .venv
|
||||||
|
|
||||||
- name: Install ruff
|
- name: Install ruff
|
||||||
run: |
|
run: |
|
||||||
./venv/bin/pip install --upgrade pip
|
./.venv/bin/pip install --upgrade pip
|
||||||
./venv/bin/pip install ruff
|
./.venv/bin/pip install ruff
|
||||||
|
|
||||||
- name: Run formatting check
|
- name: Run formatting check
|
||||||
run: make ck-format
|
run: make check-format
|
||||||
|
|
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -1,6 +1,13 @@
|
||||||
*.pyc
|
*.pyc
|
||||||
*.diff
|
*.diff
|
||||||
.*.sw*
|
.*.sw*
|
||||||
/brozzler.egg-info/
|
|
||||||
venv
|
venv
|
||||||
|
.venv
|
||||||
|
|
||||||
|
# build artifacts
|
||||||
|
build/
|
||||||
|
brozzler.egg-info/
|
||||||
|
|
||||||
|
# editor config
|
||||||
.idea
|
.idea
|
||||||
|
.vscode
|
||||||
|
|
53
Makefile
53
Makefile
|
@ -1,7 +1,50 @@
|
||||||
|
# Build constants
|
||||||
|
PYTHON_VERSION = 3.12
|
||||||
|
VIRTUAL_ENV_DIR = .venv
|
||||||
|
BROZZLER_EGG_LINK = ./brozzler.egg-info
|
||||||
|
# Where's the Makefile running? Valid options: LOCAL, CI
|
||||||
|
ENV ?= LOCAL
|
||||||
|
# Which package manager to use? Valid options: UV, PIP
|
||||||
|
PACKAGE_MANAGER ?= UV
|
||||||
|
|
||||||
|
$(VIRTUAL_ENV_DIR):
|
||||||
|
ifeq ($(PACKAGE_MANAGER),UV)
|
||||||
|
uv venv -p python$(PYTHON_VERSION) $@
|
||||||
|
else ifeq ($(PACKAGE_MANAGER),PIP)
|
||||||
|
python$(PYTHON_VERSION) -m venv $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: venv
|
||||||
|
venv: $(VIRTUAL_ENV_DIR)
|
||||||
|
|
||||||
|
$(BROZZLER_EGG_LINK): $(VIRTUAL_ENV_DIR) pyproject.toml
|
||||||
|
ifeq ($(PACKAGE_MANAGER),UV)
|
||||||
|
VIRTUAL_ENV=$(shell pwd)/$(VIRTUAL_ENV_DIR) uv build
|
||||||
|
else ifeq ($(PACKAGE_MANAGER),PIP)
|
||||||
|
VIRTUAL_ENV=$(shell pwd)/$(VIRTUAL_ENV_DIR) pip$(PYTHON_VERSION) wheel --no-deps --wheel-dir dist .
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: $(BROZZLER_EGG_LINK)
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean: $(BROZZLER_EGG_LINK)
|
||||||
|
rm -rf $(BROZZLER_EGG_LINK)
|
||||||
|
rm -rf $(shell pwd)/dist
|
||||||
|
|
||||||
|
.git/hooks/pre-commit:
|
||||||
|
ln -s $(realpath ./dev/pre-commit) $@
|
||||||
|
|
||||||
|
.PHONY: check
|
||||||
|
check:
|
||||||
|
$(VIRTUAL_ENV_DIR)/bin/ruff check --target-version py37 .
|
||||||
|
|
||||||
|
.PHONY: check-format
|
||||||
|
check-format:
|
||||||
|
$(VIRTUAL_ENV_DIR)/bin/ruff check --select I --target-version py37 .
|
||||||
|
$(VIRTUAL_ENV_DIR)/bin/ruff format --check --target-version py37 .
|
||||||
|
|
||||||
.PHONY: format
|
.PHONY: format
|
||||||
format:
|
format:
|
||||||
venv/bin/ruff format --target-version py37 .
|
$(VIRTUAL_ENV_DIR)/bin/ruff check --select I --target-version py37 --fix .
|
||||||
|
$(VIRTUAL_ENV_DIR)/bin/ruff format --target-version py37 .
|
||||||
.PHONY: ck-format
|
|
||||||
ck-format:
|
|
||||||
venv/bin/ruff format --check --target-version py37 .
|
|
||||||
|
|
11
dev/pre-commit
Normal file
11
dev/pre-commit
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# pre-commit.sh
|
||||||
|
# -------------
|
||||||
|
# An optional script which runs checks on code before commits.
|
||||||
|
|
||||||
|
make check
|
||||||
|
make check-format
|
Loading…
Add table
Add a link
Reference in a new issue