mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-03-29 10:25:44 +00:00
Add changelog command to Makefile
This commit is contained in:
parent
c45ff5665b
commit
b5ae070c37
2 changed files with 108 additions and 15 deletions
6
Makefile
6
Makefile
|
@ -14,7 +14,7 @@ DOCKERC:=$(DOCKERCLI) compose
|
|||
DOCKER_SPLIT_CONF:=-f docker-compose.yml -f docker-compose.dev.yml
|
||||
|
||||
.PHONY: install build .callsubcmd $(SUBDIRS) help package-build test tests\
|
||||
lint lint-fix docker-lint\
|
||||
lint lint-fix docker-lint changelog\
|
||||
docker-status docker-build docker-start docker-clean docker-stop docker-kill \
|
||||
deps deps-upgrade \
|
||||
clean clean-all
|
||||
|
@ -26,6 +26,7 @@ help:
|
|||
@echo " make package-build - build packages locally"
|
||||
@echo " make lint - check code style"
|
||||
@echo " make test - run test suite"
|
||||
@echo " make changelog - add a new changelog entry"
|
||||
@echo " make clean-all - remove docker images, venv and frontend node_modules dir"
|
||||
@echo " "
|
||||
@echo "targets that are executed at top-dir level:"
|
||||
|
@ -76,6 +77,9 @@ test: .subcmd
|
|||
|
||||
tests: test
|
||||
|
||||
changelog:
|
||||
$(MAKE) -C changelog add
|
||||
|
||||
.docker-build: .env
|
||||
$(DOCKERC) $(DOCKER_CONFIG_FILES) build
|
||||
|
||||
|
|
|
@ -1,18 +1,107 @@
|
|||
install-dependencies:
|
||||
pip install -r requirements.txt
|
||||
# 'realpath' command may be not available in Mac OS.
|
||||
# In that case we use 'grealpath' from 'coreutils' package.
|
||||
ifeq ($(shell uname -s),Darwin)
|
||||
REALPATH := grealpath -em
|
||||
else
|
||||
REALPATH := realpath -em
|
||||
endif
|
||||
|
||||
lint:
|
||||
flake8 src tests && \
|
||||
black . --extend-exclude='/generated/' --check && \
|
||||
isort --check --skip generated --profile black src tests && \
|
||||
bandit -r src/ \
|
||||
|| exit;
|
||||
# Get the Python interpreter path
|
||||
PYTHON:=$(shell which python3.11 || which python3 || which python)
|
||||
|
||||
format:
|
||||
black . || exit;
|
||||
# Get the directory of the current Makefile.
|
||||
# If the Makefile is executed from another directory (e.g, using the '-C') flag
|
||||
# $(WORKDIR) will contain the absolute path to the current Makefile directory,
|
||||
# in this case '..../baserow/changelog/' (with the trailing '/')
|
||||
WORKDIR := $(dir $($(REALPATH) $(lastword $(MAKEFILE_LIST))))
|
||||
ARGS := $(filter-out $(firstword $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
||||
REQUIREMENTS := $(WORKDIR)requirements.txt
|
||||
VENV := $(WORKDIR)venv
|
||||
PIP := $(VENV)/bin/python -m pip
|
||||
|
||||
sort:
|
||||
isort --skip generated --profile black src tests || exit;
|
||||
# Executables
|
||||
CHANGELOG := $(VENV)/bin/python $(WORKDIR)src/changelog.py
|
||||
BANDIT := $(VENV)/bin/bandit
|
||||
BLACK := $(VENV)/bin/black
|
||||
FLAKE8 := $(VENV)/bin/flake8
|
||||
ISORT := $(VENV)/bin/isort
|
||||
PYTEST := $(VENV)/bin/pytest
|
||||
|
||||
test:
|
||||
pytest tests || exit;
|
||||
# Display the help message.
|
||||
# If no targets are specified this will be executed by default.
|
||||
help:
|
||||
@echo "make commands available"
|
||||
@echo " add add a new changelog entry"
|
||||
@echo " release add a new release. Usage: 'make release -- 1.2.3'"
|
||||
@echo " purge delete all changelog entries"
|
||||
@echo " generate generate a new 'changelog.md' file without making a new release"
|
||||
@echo ""
|
||||
@echo " lint run lint/style tools"
|
||||
@echo " format run black to reformat the code"
|
||||
@echo " sort sort the imports"
|
||||
@echo " test run the test suite"
|
||||
@echo ""
|
||||
@echo " clean remove Python virtual environment directory"
|
||||
|
||||
# Create a new Python virtual environment and install the dependencies.
|
||||
# When finished, the 'touch' command updates the modified date of the 'VENV'
|
||||
# folder, avoiding unneeded rebuilds
|
||||
$(VENV) $(PIP): $(PYTHON) $(REQUIREMENTS)
|
||||
$(PYTHON) -m venv $(VENV)
|
||||
$(PIP) install -r $(REQUIREMENTS)
|
||||
$(PIP) install .
|
||||
touch $(VENV)
|
||||
|
||||
$(BANDIT) $(BLACK) $(FLAKE8) $(ISORT) $(PYTEST): $(VENV)
|
||||
|
||||
# Add a new changelog entry
|
||||
.PHONY: add
|
||||
add: $(VENV)
|
||||
$(CHANGELOG) add $(ARGS)
|
||||
|
||||
# Add a new release
|
||||
.PHONY: release
|
||||
release: $(VENV)
|
||||
$(CHANGELOG) release $(ARGS)
|
||||
|
||||
# Delete all changelog entries
|
||||
.PHONY: purge
|
||||
purge: $(VENV)
|
||||
$(CHANGELOG) purge $(ARGS)
|
||||
|
||||
# Generate a new 'changelog.md' file
|
||||
.PHONY: generate
|
||||
generate: $(VENV)
|
||||
$(CHANGELOG) generate $(ARGS)
|
||||
|
||||
# Check the code for linting errors
|
||||
.PHONY: lint
|
||||
lint: $(BANDIT) $(BLACK) $(FLAKE8) $(ISORT)
|
||||
$(FLAKE8) src tests
|
||||
$(BLACK) . --extend-exclude='/generated/' --check
|
||||
$(ISORT) --check --skip generated --profile black src tests
|
||||
$(BANDIT) -r src
|
||||
|
||||
# Reformat the code according to black style
|
||||
.PHONY: format
|
||||
format: $(BLACK)
|
||||
$(BLACK) . || exit;
|
||||
|
||||
# Sort the Python import statements
|
||||
.PHONY: sort
|
||||
sort: $(ISORT)
|
||||
$(ISORT) --skip generated --profile black src tests || exit;
|
||||
|
||||
# Run the test suite
|
||||
.PHONY: test
|
||||
test: $(PYTEST)
|
||||
$(PYTEST) tests || exit;
|
||||
|
||||
# Remove the virtual environment directory
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -r $(VENV)
|
||||
|
||||
# Prevent make from interpreting the arguments as targets
|
||||
%:
|
||||
@:
|
||||
|
|
Loading…
Add table
Reference in a new issue