Include python 3.8 i ci test runs & optimise CI and make config

This commit is contained in:
Nat Noordanus 2020-06-22 19:38:41 +02:00
parent 75a4c230da
commit 4f820b4a6a
4 changed files with 39 additions and 20 deletions

View File

@ -10,11 +10,17 @@ jobs:
name: Consult black on python formatting name: Consult black on python formatting
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v2
- uses: actions/setup-python@v1 - uses: actions/setup-python@v2
with: with:
python-version: 3.7 python-version: 3.7
- uses: Gr1N/setup-poetry@v2 - 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 - name: Install dependencies
run: poetry install run: poetry install
- name: Run black - name: Run black
@ -25,25 +31,37 @@ jobs:
name: Run tests with tox name: Run tests with tox
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8']
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v2
- uses: actions/setup-python@v1 - uses: actions/setup-python@v2
with: with:
python-version: 3.7 python-version: ${{ matrix.python-version }}
- uses: Gr1N/setup-poetry@v2 - 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 - name: Install dependencies
run: | run: |
sudo apt install protobuf-compiler libprotobuf-dev sudo apt install protobuf-compiler libprotobuf-dev
poetry install poetry install
- name: Run tests - name: Run tests
run: make full-test run: |
make generate
make test
build-release: build-release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v2
- uses: actions/setup-python@v1 - uses: actions/setup-python@v2
with: with:
python-version: 3.7 python-version: 3.7
- uses: Gr1N/setup-poetry@v2 - uses: Gr1N/setup-poetry@v2

View File

@ -1,4 +1,6 @@
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/##//' @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
# Dev workflow tasks # Dev workflow tasks
@ -6,16 +8,16 @@ help: ## - Show this help.
generate: ## - Generate test cases (do this once before running test) generate: ## - Generate test cases (do this once before running test)
poetry run ./betterproto/tests/generate.py poetry run ./betterproto/tests/generate.py
test: ## - Run tests test: ## - Run tests
poetry run pytest --cov betterproto poetry run pytest --cov betterproto
types: ## - Check types with mypy types: ## - Check types with mypy
poetry run mypy betterproto --ignore-missing-imports 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_ 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 \ rm -rf .coverage \
.mypy_cache \ .mypy_cache \
.pytest_cache \ .pytest_cache \
@ -27,14 +29,14 @@ clean: ## - Clean out generated files from the workspace
# By default write plugin output to a directory called output # By default write plugin output to a directory called output
o=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) mkdir -p $(o)
protoc --plugin=protoc-gen-custom=betterproto/plugin.py $(i) --custom_out=$(o) protoc --plugin=protoc-gen-custom=betterproto/plugin.py $(i) --custom_out=$(o)
# CI tasks # CI tasks
full-test: generate ## - Run full testing sequence full-test: generate ## - Run full testing sequence with multiple pythons
poetry run tox 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_ poetry run black . --check --diff --exclude tests/output_

View File

@ -351,10 +351,9 @@ Custom tests are found in `tests/test_*.py` and are run with pytest.
Here's how to run the tests. Here's how to run the tests.
```sh ```sh
# Generate assets from sample .proto files # Generate assets from sample .proto files required by the tests
make generate make generate
# Run the tests
# Run all tests
make test make test
``` ```

View File

@ -47,7 +47,7 @@ omit = ["betterproto/tests/*"]
legacy_tox_ini = """ legacy_tox_ini = """
[tox] [tox]
isolated_build = true isolated_build = true
envlist = py36, py37 envlist = py36, py37, py38
[testenv] [testenv]
whitelist_externals = poetry whitelist_externals = poetry