From 49af9400df27a749b2b3f489bf7bd8dbd46fdc24 Mon Sep 17 00:00:00 2001 From: Laurence de Bruxelles Date: Wed, 30 Dec 2020 10:14:32 +0000 Subject: [PATCH] Replace make with invoke We want to be able to reduce duplication of code across our repos; one of the places we have a lot of duplicated code is in our Makefiles; all of our repos have very similar Makefiles with small historical differences. This commit replaces Make with invoke, using the tasks from alphagov/digitalmarketplace-developer-tools. See alphagov/digitalmarketplace-developer-tools#1 for more details. --- .flake8 | 1 + .github/workflows/test.yml | 7 ++++-- Makefile | 49 +++++++++++++++----------------------- tasks.py | 1 + 4 files changed, 26 insertions(+), 32 deletions(-) create mode 100644 tasks.py diff --git a/.flake8 b/.flake8 index bcd402de..75072017 100644 --- a/.flake8 +++ b/.flake8 @@ -11,3 +11,4 @@ max-complexity = 12 max-line-length = 120 per-file-ignores = **/__init__.py : F401 + tasks.py: F401 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 122e1222..ef5b5db2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,8 +21,11 @@ jobs: path: venv key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }} + - name: Install developer tools + run: make bootstrap + - name: Install dependencies - run: make requirements-dev + run: invoke requirements-dev - name: Run tests - run: make test + run: invoke test diff --git a/Makefile b/Makefile index 120e9081..f551f2aa 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,20 @@ -SHELL := /bin/bash -VIRTUALENV_ROOT := $(shell [ -z $$VIRTUAL_ENV ] && echo $$(pwd)/venv || echo $$VIRTUAL_ENV) - -.PHONY: virtualenv -virtualenv: - [ -z $$VIRTUAL_ENV ] && [ ! -d venv ] && python3 -m venv venv || true - -.PHONY: requirements-dev -requirements-dev: virtualenv requirements-dev.txt - ${VIRTUALENV_ROOT}/bin/pip install -Ur requirements-dev.txt - -.PHONY: test -test: show-environment test-flake8 test-mypy test-python - -.PHONY: test-flake8 -test-flake8: virtualenv - ${VIRTUALENV_ROOT}/bin/flake8 . - -.PHONY: test-mypy -test-mypy: virtualenv requirements-dev - ${VIRTUALENV_ROOT}/bin/mypy dmutils/ - -.PHONY: test-python -test-python: virtualenv requirements-dev - ${VIRTUALENV_ROOT}/bin/py.test ${PYTEST_ARGS} - -.PHONY: show-environment -show-environment: - @echo "Environment variables in use:" - @env | grep DM_ || true +.DEFAULT_GOAL := bootstrap + +%: + @[ -z $$TERM ] || tput setaf 1 # red + @echo 2>1 warning: calling '`make`' is being deprecated in this repo, you should use '`invoke` (https://pyinvoke.org)' instead. + @[ -z $$TERM ] || tput setaf 9 # default + @# pass goals to '`invoke`' + invoke $(or $(MAKECMDGOALS), $@) + +help: + invoke --list + +.PHONY: bootstrap +bootstrap: + pip install digitalmarketplace-developer-tools + @echo done + @[ -z $$TERM ] || tput setaf 2 # green + @echo 2>1 dmdevtools has been installed globally, run developer tasks with '`invoke`' + @[ -z $$TERM ] || tput setaf 9 # default diff --git a/tasks.py b/tasks.py new file mode 100644 index 00000000..fc489852 --- /dev/null +++ b/tasks.py @@ -0,0 +1 @@ +from dmdevtools.invoke_tasks import library_tasks as ns