Skip to content

Commit

Permalink
Replace make with invoke
Browse files Browse the repository at this point in the history
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 Crown-Commercial-Service/digitalmarketplace-developer-tools#1 for more details.
  • Loading branch information
lfdebrux committed Feb 26, 2021
1 parent 548dfba commit 49af940
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 32 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ max-complexity = 12
max-line-length = 120
per-file-ignores =
**/__init__.py : F401
tasks.py: F401
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
49 changes: 19 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from dmdevtools.invoke_tasks import library_tasks as ns

0 comments on commit 49af940

Please sign in to comment.