Use Makefile to centralize build/test commands

This Makefile is optional because the commands can be run independently,
it was added just to simplify and centralize all our commands. On Linux,
GNU Make is expected to almost universally be installed, but on Windows
it may need to be installed manually to use it. Fortunately the GitHub
Actions Windows image has it.
This commit is contained in:
Andrew Schwartzmeyer 2020-09-23 16:12:27 -07:00 коммит произвёл Andy Schwartzmeyer
Родитель cd037c286f
Коммит 0ca0798cc5
3 изменённых файлов: 68 добавлений и 16 удалений

Просмотреть файл

@ -37,27 +37,19 @@ jobs:
echo "::add-path::$env:USERPROFILE\.poetry\bin"
- name: Install Python dependencies
run: |
poetry install
run: make setup
- name: Run LISAv3 hello-world
run: |
poetry run coverage erase
poetry run coverage run lisa/main.py --debug
run: make run
- name: Run unittest
run: |
poetry run coverage run --append -m unittest discover lisa
- name: Run unit tests
run: make test
- name: calculate code coverage
run: |
poetry run coverage report --skip-empty --include=lisa*,examples*,testsuites* --omit=lisa/tests/* --precision 2
- name: Calculate code coverage
run: make coverage
- name: Run black/flake8/isort
run: poetry run flake8
- name: Run mypy static type checking
run: poetry run mypy --strict --namespace-packages .
- name: Run black/flake8/isort/mypy
run: make check
- name: Run ShellCheck
if: runner.os == 'Linux'

37
Makefile Normal file
Просмотреть файл

@ -0,0 +1,37 @@
# This Makefile simply automates all our tasks. Its use is optional.
all: setup run check
# Install Python packages
setup:
@poetry install --no-ansi --remove-untracked
# Run LISAv3
run:
@poetry run python lisa/main.py --debug
# Run unit tests
test:
@poetry run python -m unittest discover lisa
# Generate coverage report (slow, reruns LISAv3 and tests)
coverage:
@poetry run coverage erase
@poetry run coverage run lisa/main.py 2>/dev/null
@poetry run coverage run --append -m unittest discover lisa 2>/dev/null
@poetry run coverage report --skip-empty --include=lisa*,examples*,testsuites* --omit=lisa/tests/* --precision 2
# Run syntactic, semantic, formatting and type checkers
check: flake8 mypy
# This also runs Black and isort via plugins
flake8:
@poetry run flake8
# This runs the static type checking
mypy:
@poetry run mypy --strict --namespace-packages .
# Print current Python virtualenv
venv:
@poetry env list --no-ansi --full-path

Просмотреть файл

@ -76,6 +76,29 @@ Run LISAv3 using Poetrys environment:
poetry run python lisa/main.py
```
### Make
We now also have a GNU Makefile that automates some tasks. Try:
```bash
# Install Python packages
make setup
# Run LISAv3
make run
# Run unit tests
make test
# Run syntactic, semantic, formatting and type checkers
make check
# Generate coverage report (slow, reruns LISAv3 and tests)
make coverage
# Print current Python virtualenv
make venv
```
### Editor Setup
Install and enable [ShellCheck](https://github.com/koalaman/shellcheck) to find