Skip to content

Commit

Permalink
Replace make with invoke
Browse files Browse the repository at this point in the history
Why
---

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-dev-tools.

See Crown-Commercial-Service/digitalmarketplace-developer-tools#1 for more details.
  • Loading branch information
lfdebrux committed Dec 30, 2020
1 parent 3abf28b commit 83cf1cf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 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
39 changes: 16 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +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
.DEFAULT_GOAL := bootstrap

.PHONY: requirements-dev
requirements-dev: virtualenv requirements-dev.txt
${VIRTUALENV_ROOT}/bin/pip install -Ur requirements-dev.txt
%:
@[ -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), $@)

.PHONY: test
test: show-environment test-flake8 test-python

.PHONY: test-flake8
test-flake8: virtualenv
${VIRTUALENV_ROOT}/bin/flake8 .

.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
help:
invoke --list

.PHONY: bootstrap
bootstrap:
pip install git+https://github.com/alphagov/digitalmarketplace-developer-tools.git#egg=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 83cf1cf

Please sign in to comment.