Skip to content

Commit

Permalink
Switch from pipenv to poetry
Browse files Browse the repository at this point in the history
- dropped dev dependency on rope, isort & flake
- poetry doesn't support dev scripts like pipenv, so create a makefile instead
- Add pytest-cov
- Use tox for testing multiple python versions in CI
- Update README

Update ci workflow
  • Loading branch information
nat-n committed Jun 12, 2020
1 parent a46979c commit 8edec81
Show file tree
Hide file tree
Showing 11 changed files with 939 additions and 555 deletions.
44 changes: 14 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,29 @@ jobs:
- uses: actions/setup-python@v1
with:
python-version: 3.7
- uses: dschep/install-pipenv-action@v1
- uses: Gr1N/setup-poetry@v2
- name: Install dependencies
run: |
pipenv install --dev --python ${pythonLocation}/python
run: make setup
- name: Run black
run: |
pipenv run black . --check --diff --exclude tests/output_
run: make check-style

run-tests:
runs-on: ubuntu-latest

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

name: Python ${{ matrix.python-version }} test
name: Run tests with tox

steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- uses: dschep/install-pipenv-action@v1
python-version: 3.7
- uses: Gr1N/setup-poetry@v2
- name: Install dependencies
run: |
sudo apt install protobuf-compiler libprotobuf-dev
pipenv install --dev --python ${pythonLocation}/python
make setup
- name: Run tests
run: |
cp .env.default .env
pipenv run pip install -e .
pipenv run generate
pipenv run test
run: make full-test

build-release:
runs-on: ubuntu-latest
Expand All @@ -56,17 +46,11 @@ jobs:
- uses: actions/setup-python@v1
with:
python-version: 3.7
- uses: dschep/install-pipenv-action@v1
- name: Install dependencies
run: |
sudo apt install protobuf-compiler libprotobuf-dev
pipenv install --dev --python ${pythonLocation}/python
- uses: Gr1N/setup-poetry@v2
- name: Build package
run: poetry build
- name: Publish package to PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
run: pipenv run python setup.py sdist
- name: Publish package
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@v1.0.0a0
with:
user: __token__
password: ${{ secrets.pypi }}
run: poetry publish -n
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.pypi }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.coverage
.DS_Store
.env
.vscode/settings.json
.mypy_cache
Expand All @@ -9,4 +11,5 @@ betterproto/tests/output_*
dist
**/*.egg-info
output
.idea
.idea
.tox
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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
poetry install -E compiler

generate: ## - Generate test cases (do this once before running test)
poetry run ./betterproto/tests/generate.py

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

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

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

clean: ## - Clean out generated files from the workspace
rm -rf .coverage \
.mypy_cache \
.pytest_cache \
dist \
**/__pycache__ \
betterproto/tests/output_*

# Manual testing

# 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`
mkdir -p $(o)
protoc --plugin=protoc-gen-custom=betterproto/plugin.py $(i) --custom_out=$(o)

# CI tasks

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

check-style: ## - Check if code style is correct
poetry run black . --check --diff --exclude tests/output_
32 changes: 0 additions & 32 deletions Pipfile

This file was deleted.

Loading

0 comments on commit 8edec81

Please sign in to comment.