Skip to content

Commit 5fb4b4b

Browse files
Merge pull request #75 from nat-n/add_poetry
Switch from pipenv to poetry
2 parents 1ecbf1a + 4f820b4 commit 5fb4b4b

File tree

11 files changed

+1136
-559
lines changed

11 files changed

+1136
-559
lines changed

.github/workflows/ci.yml

+34-32
Original file line numberDiff line numberDiff line change
@@ -10,63 +10,65 @@ 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
17-
- uses: dschep/install-pipenv-action@v1
17+
- 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
19-
run: |
20-
pipenv install --dev --python ${pythonLocation}/python
25+
run: poetry install
2126
- name: Run black
22-
run: |
23-
pipenv run black . --check --diff --exclude tests/output_
27+
run: make check-style
2428

2529
run-tests:
2630
runs-on: ubuntu-latest
2731

32+
name: Run tests with tox
33+
2834
strategy:
2935
matrix:
30-
python-version: [ '3.6', '3.7' ]
31-
32-
name: Python ${{ matrix.python-version }} test
36+
python-version: [ '3.6', '3.7', '3.8']
3337

3438
steps:
35-
- uses: actions/checkout@v1
36-
- uses: actions/setup-python@v1
39+
- uses: actions/checkout@v2
40+
- uses: actions/setup-python@v2
3741
with:
3842
python-version: ${{ matrix.python-version }}
39-
- uses: dschep/install-pipenv-action@v1
43+
- 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-
4050
- name: Install dependencies
4151
run: |
4252
sudo apt install protobuf-compiler libprotobuf-dev
43-
pipenv install --dev --python ${pythonLocation}/python
53+
poetry install
4454
- name: Run tests
4555
run: |
46-
cp .env.default .env
47-
pipenv run pip install -e .
48-
pipenv run generate
49-
pipenv run test
56+
make generate
57+
make test
5058
5159
build-release:
5260
runs-on: ubuntu-latest
5361

5462
steps:
55-
- uses: actions/checkout@v1
56-
- uses: actions/setup-python@v1
63+
- uses: actions/checkout@v2
64+
- uses: actions/setup-python@v2
5765
with:
5866
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
67+
- uses: Gr1N/setup-poetry@v2
6468
- name: Build package
69+
run: poetry build
70+
- name: Publish package to PyPI
6571
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 }}
72+
run: poetry publish -n
73+
env:
74+
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

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

Pipfile

-32
This file was deleted.

0 commit comments

Comments
 (0)