Skip to content

Commit afb8b7b

Browse files
committed
Tweak matrix testing & makefile
1 parent 0c2822e commit afb8b7b

File tree

5 files changed

+220
-24
lines changed

5 files changed

+220
-24
lines changed

.github/workflows/ci.yml

+26-8
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ jobs:
1010
name: Consult black on python formatting
1111

1212
steps:
13-
- uses: actions/checkout@v1
14-
- uses: actions/setup-python@v1
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-python@v2
1515
with:
1616
python-version: 3.7
1717
- uses: Gr1N/setup-poetry@v2
18+
- uses: actions/cache@v2
19+
with:
20+
path: ~/.cache/pypoetry/virtualenvs
21+
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
22+
restore-keys: |
23+
${{ runner.os }}-poetry-
1824
- name: Install dependencies
1925
run: make setup
2026
- name: Run black
@@ -25,25 +31,37 @@ jobs:
2531

2632
name: Run tests with tox
2733

34+
strategy:
35+
matrix:
36+
python-version: [ '3.6', '3.7', '3.8']
37+
2838
steps:
29-
- uses: actions/checkout@v1
30-
- uses: actions/setup-python@v1
39+
- uses: actions/checkout@v2
40+
- uses: actions/setup-python@v2
3141
with:
32-
python-version: 3.7
42+
python-version: ${{ matrix.python-version }}
3343
- uses: Gr1N/setup-poetry@v2
44+
- uses: actions/cache@v2
45+
with:
46+
path: ~/.cache/pypoetry/virtualenvs
47+
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
48+
restore-keys: |
49+
${{ runner.os }}-poetry-
3450
- name: Install dependencies
3551
run: |
3652
sudo apt install protobuf-compiler libprotobuf-dev
3753
make setup
3854
- name: Run tests
39-
run: make full-test
55+
run: |
56+
make generate
57+
make test
4058
4159
build-release:
4260
runs-on: ubuntu-latest
4361

4462
steps:
45-
- uses: actions/checkout@v1
46-
- uses: actions/setup-python@v1
63+
- uses: actions/checkout@v2
64+
- uses: actions/setup-python@v2
4765
with:
4866
python-version: 3.7
4967
- uses: Gr1N/setup-poetry@v2

Makefile

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
help: ## - Show this help.
1+
.PHONY: help setup generate test types format clean plugin full-test check-style
2+
3+
help: ## - Show this help.
24
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
35

46
# Dev workflow tasks
57

6-
setup: ## - Setup the virtualenv with poetry
8+
setup: ## - Setup the virtualenv with poetry
79
poetry install -E compiler
810

9-
generate: ## - Generate test cases (do this once before running test)
11+
test_o = ./betterproto/tests/output_*/
12+
13+
${test_o}:
1014
poetry run ./betterproto/tests/generate.py
1115

12-
test: ## - Run tests
16+
generate: ${test_o} ## - Generate test cases (do this once before running test)
17+
18+
test: generate ## - Run tests
1319
poetry run pytest --cov betterproto
1420

15-
types: ## - Check types with mypy
21+
types: ## - Check types with mypy
1622
poetry run mypy betterproto --ignore-missing-imports
1723

18-
format: ## - Apply black formatting to source code
24+
format: ## - Apply black formatting to source code
1925
poetry run black . --exclude tests/output_
2026

21-
clean: ## - Clean out generated files from the workspace
27+
clean: ## - Clean out generated files from the workspace
2228
rm -rf .coverage \
2329
.mypy_cache \
2430
.pytest_cache \
@@ -30,14 +36,14 @@ clean: ## - Clean out generated files from the workspace
3036

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

3743
# CI tasks
3844

39-
full-test: generate ## - Run full testing sequence
45+
full-test: generate ## - Run full testing sequence with multiple pythons
4046
poetry run tox
4147

42-
check-style: ## - Check if code style is correct
48+
check-style: ## - Check if code style is correct
4349
poetry run black . --check --diff --exclude tests/output_

README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,7 @@ Custom tests are found in `tests/test_*.py` and are run with pytest.
348348
Here's how to run the tests.
349349

350350
```sh
351-
# Generate assets from sample .proto files
352-
make generate
353-
354-
# Run all tests
351+
# Generate assets from sample .proto files and run all tests
355352
make test
356353
```
357354

0 commit comments

Comments
 (0)