Skip to content

Commit

Permalink
Tweak matrix testing & makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
nat-n committed Jun 12, 2020
1 parent 8edec81 commit 25bc14c
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 24 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ jobs:
name: Consult black on python formatting

steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.7
- uses: Gr1N/setup-poetry@v2
- uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install dependencies
run: make setup
- name: Run black
Expand All @@ -25,25 +31,37 @@ jobs:

name: Run tests with tox

strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8']

steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: ${{ matrix.python-version }}
- uses: Gr1N/setup-poetry@v2
- uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install dependencies
run: |
sudo apt install protobuf-compiler libprotobuf-dev
make setup
- name: Run tests
run: make full-test
run: |
make generate
make test
build-release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.7
- uses: Gr1N/setup-poetry@v2
Expand Down
26 changes: 16 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
help: ## - Show this help.
.PHONY: help setup generate test types format clean plugin full-test check-style

help: ## - Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

# Dev workflow tasks

setup: ## - Setup the virtualenv with poetry
setup: ## - Setup the virtualenv with poetry
poetry install -E compiler

generate: ## - Generate test cases (do this once before running test)
test_o = ./betterproto/tests/output_*/

${test_o}:
poetry run ./betterproto/tests/generate.py

test: ## - Run tests
generate: ${test_o} ## - Generate test cases (do this once before running test)

test: generate ## - Run tests
poetry run pytest --cov betterproto

types: ## - Check types with mypy
types: ## - Check types with mypy
poetry run mypy betterproto --ignore-missing-imports

format: ## - Apply black formatting to source code
format: ## - Apply black formatting to source code
poetry run black . --exclude tests/output_

clean: ## - Clean out generated files from the workspace
clean: ## - Clean out generated files from the workspace
rm -rf .coverage \
.mypy_cache \
.pytest_cache \
Expand All @@ -30,14 +36,14 @@ clean: ## - Clean out generated files from the workspace

# By default write plugin output to a directory called output
o=output
plugin: ## - Execute the protoc plugin, with output writte to `output` or the value passed to `-o`
plugin: ## - Execute the protoc plugin, with output write to `output` or the value passed to `-o`
mkdir -p $(o)
protoc --plugin=protoc-gen-custom=betterproto/plugin.py $(i) --custom_out=$(o)

# CI tasks

full-test: generate ## - Run full testing sequence
full-test: generate ## - Run full testing sequence with multiple pythons
poetry run tox

check-style: ## - Check if code style is correct
check-style: ## - Check if code style is correct
poetry run black . --check --diff --exclude tests/output_
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,7 @@ Custom tests are found in `tests/test_*.py` and are run with pytest.
Here's how to run the tests.

```sh
# Generate assets from sample .proto files
make generate

# Run all tests
# Generate assets from sample .proto files and run all tests
make test
```

Expand Down
Loading

0 comments on commit 25bc14c

Please sign in to comment.