Skip to content

Commit

Permalink
Merge pull request #594 from alphagov/ldeb-add-invoke
Browse files Browse the repository at this point in the history
Replace make with invoke
  • Loading branch information
lfdebrux authored Feb 26, 2021
2 parents 548dfba + 7835c31 commit 9cbb656
Show file tree
Hide file tree
Showing 4 changed files with 37 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
12 changes: 12 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from invoke import task

from dmdevtools.invoke_tasks import library_tasks as ns


@task(ns["virtualenv"], ns["requirements_dev"])
def test_mypy(c):
c.run("mypy dmutils/")


ns.add_task(test_mypy)
ns["test"].pre.insert(-1, test_mypy)

0 comments on commit 9cbb656

Please sign in to comment.