Skip to content

Commit 5986766

Browse files
committed
Switch from pipenv to poetry
- 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
1 parent ee362a7 commit 5986766

File tree

11 files changed

+939
-555
lines changed

11 files changed

+939
-555
lines changed

.github/workflows/ci.yml

+14-30
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,29 @@ jobs:
1414
- uses: actions/setup-python@v1
1515
with:
1616
python-version: 3.7
17-
- uses: dschep/install-pipenv-action@v1
17+
- uses: Gr1N/setup-poetry@v2
1818
- name: Install dependencies
19-
run: |
20-
pipenv install --dev --python ${pythonLocation}/python
19+
run: make setup
2120
- name: Run black
22-
run: |
23-
pipenv run black . --check --diff --exclude tests/output_
21+
run: make check-style
2422

2523
run-tests:
2624
runs-on: ubuntu-latest
2725

28-
strategy:
29-
matrix:
30-
python-version: [ '3.6', '3.7' ]
31-
32-
name: Python ${{ matrix.python-version }} test
26+
name: Run tests with tox
3327

3428
steps:
3529
- uses: actions/checkout@v1
3630
- uses: actions/setup-python@v1
3731
with:
38-
python-version: ${{ matrix.python-version }}
39-
- uses: dschep/install-pipenv-action@v1
32+
python-version: 3.7
33+
- uses: Gr1N/setup-poetry@v2
4034
- name: Install dependencies
4135
run: |
4236
sudo apt install protobuf-compiler libprotobuf-dev
43-
pipenv install --dev --python ${pythonLocation}/python
37+
make setup
4438
- name: Run tests
45-
run: |
46-
cp .env.default .env
47-
pipenv run pip install -e .
48-
pipenv run generate
49-
pipenv run test
39+
run: make full-test
5040

5141
build-release:
5242
runs-on: ubuntu-latest
@@ -56,17 +46,11 @@ jobs:
5646
- uses: actions/setup-python@v1
5747
with:
5848
python-version: 3.7
59-
- uses: dschep/install-pipenv-action@v1
60-
- name: Install dependencies
61-
run: |
62-
sudo apt install protobuf-compiler libprotobuf-dev
63-
pipenv install --dev --python ${pythonLocation}/python
49+
- uses: Gr1N/setup-poetry@v2
6450
- name: Build package
51+
run: poetry build
52+
- name: Publish package to PyPI
6553
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
66-
run: pipenv run python setup.py sdist
67-
- name: Publish package
68-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
69-
uses: pypa/[email protected]
70-
with:
71-
user: __token__
72-
password: ${{ secrets.pypi }}
54+
run: poetry publish -n
55+
env:
56+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.pypi }}

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.coverage
2+
.DS_Store
13
.env
24
.vscode/settings.json
35
.mypy_cache
@@ -9,4 +11,5 @@ betterproto/tests/output_*
911
dist
1012
**/*.egg-info
1113
output
12-
.idea
14+
.idea
15+
.tox

Makefile

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
help: ## - Show this help.
2+
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
3+
4+
# Dev workflow tasks
5+
6+
setup: ## - Setup the virtualenv with poetry
7+
poetry install -E compiler
8+
9+
generate: ## - Generate test cases (do this once before running test)
10+
poetry run ./betterproto/tests/generate.py
11+
12+
test: ## - Run tests
13+
poetry run pytest --cov betterproto
14+
15+
types: ## - Check types with mypy
16+
poetry run mypy betterproto --ignore-missing-imports
17+
18+
format: ## - Apply black formatting to source code
19+
poetry run black . --exclude tests/output_
20+
21+
clean: ## - Clean out generated files from the workspace
22+
rm -rf .coverage \
23+
.mypy_cache \
24+
.pytest_cache \
25+
dist \
26+
**/__pycache__ \
27+
betterproto/tests/output_*
28+
29+
# Manual testing
30+
31+
# By default write plugin output to a directory called output
32+
o=output
33+
plugin: ## - Execute the protoc plugin, with output writte to `output` or the value passed to `-o`
34+
mkdir -p $(o)
35+
protoc --plugin=protoc-gen-custom=betterproto/plugin.py $(i) --custom_out=$(o)
36+
37+
# CI tasks
38+
39+
full-test: generate ## - Run full testing sequence
40+
poetry run tox
41+
42+
check-style: ## - Check if code style is correct
43+
poetry run black . --check --diff --exclude tests/output_

Pipfile

-32
This file was deleted.

0 commit comments

Comments
 (0)