-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add poetry for managing the repository
- Loading branch information
Showing
11 changed files
with
535 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[flake8] | ||
ignore = E203, E266 | ||
ignore = E203, E266, W503 | ||
max-line-length = 120 | ||
max-complexity = 18 | ||
select = B,C,E,F,W,T4,B9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,138 @@ | ||
name: Lint, Test and Release | ||
|
||
on: [push] | ||
|
||
jobs: | ||
|
||
lint: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install Python 3.9.10 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9.10 | ||
- name: Install Python Dependencies | ||
run: | | ||
pip install --upgrade pip setuptools | ||
pip install pre-commit==2.9.3 | ||
- name: Lint with pre-commit | ||
run: script -e -c "pre-commit run --all-files" | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Environment | ||
id: setup | ||
run: | | ||
echo "python-version=$(cat .tool-versions | grep -Po '(?<=python ).*')" >> $GITHUB_OUTPUT | ||
echo "poetry-version=$(cat .tool-versions | grep -Po '(?<=poetry ).*')" >> $GITHUB_OUTPUT | ||
if [ $GITHUB_REF == 'refs/heads/master' ]; then echo "ENV=prod"; else echo "ENV=staging"; fi >> $GITHUB_ENV | ||
- name: Install Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ steps.setup.outputs.python-version }} | ||
|
||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: ${{ steps.setup.outputs.poetry-version }} | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
|
||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.setup.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/.pre-commit-config.yaml') }} | ||
|
||
- name: Install dependencies | ||
run: poetry install | ||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
|
||
- name: Run linting pre-commit hooks | ||
run: script -e -c "poetry run pre-commit run --all-files" | ||
|
||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install Python 3.9.10 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9.10 | ||
- name: Install Python Dependencies | ||
run: | | ||
pip install --upgrade pip setuptools | ||
pip install pytest | ||
- name: Run Unit Tests | ||
env: | ||
ENV: test | ||
run: script -e -c "python -m pytest -v example/tests" | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Environment | ||
id: setup | ||
run: | | ||
echo "python-version=$(cat .tool-versions | grep -Po '(?<=python ).*')" >> $GITHUB_OUTPUT | ||
echo "poetry-version=$(cat .tool-versions | grep -Po '(?<=poetry ).*')" >> $GITHUB_OUTPUT | ||
if [ $GITHUB_REF == 'refs/heads/master' ]; then echo "ENV=prod"; else echo "ENV=staging"; fi >> $GITHUB_ENV | ||
- name: Install Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ steps.setup.outputs.python-version }} | ||
|
||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: ${{ steps.setup.outputs.poetry-version }} | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
|
||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/.pre-commit-config.yaml') }} | ||
|
||
- name: Install dependencies | ||
run: poetry install | ||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
|
||
- name: Run unit tests | ||
env: | ||
ENV: test | ||
run: script -e -c "poetry run python -m pytest -v example/tests" | ||
|
||
release: | ||
runs-on: ubuntu-20.04 | ||
needs: [lint, test] | ||
if: startsWith(github.ref, 'refs/tags/') | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install Python 3.8.5 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8.5 | ||
- name: Install Python Dependencies | ||
run: | | ||
pip install --upgrade pip setuptools | ||
pip install wheel twine | ||
- name: Build and Publish to Pypi | ||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: | | ||
python setup.py sdist | ||
twine upload dist/* | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Bump version and push tag | ||
uses: alexeyatbluescape/github-tag-action@bugfix/semver-empty-results | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
WITH_V: true | ||
DEFAULT_BUMP: patch | ||
|
||
- name: Setup Environment | ||
id: setup | ||
run: | | ||
echo "python-version=$(cat .tool-versions | grep -Po '(?<=python ).*')" >> $GITHUB_OUTPUT | ||
echo "poetry-version=$(cat .tool-versions | grep -Po '(?<=poetry ).*')" >> $GITHUB_OUTPUT | ||
if [ $GITHUB_REF == 'refs/heads/master' ]; then echo "ENV=prod"; else echo "ENV=staging"; fi >> $GITHUB_ENV | ||
- name: Install Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ steps.setup.outputs.python-version }} | ||
|
||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: ${{ steps.setup.outputs.poetry-version }} | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
|
||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/.pre-commit-config.yaml') }} | ||
|
||
# Installing twine in a separate step to prevent circular dependencies and conflicts with cache | ||
- name: Install pip twine | ||
run: pip install --upgrade pip twine | ||
|
||
- name: Install dependencies | ||
run: poetry install | ||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
|
||
- name: Build and publish to Pypi | ||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: | | ||
poetry version $(git describe --tags --abbrev=0) | ||
poetry build | ||
twine upload dist/* --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,47 @@ | ||
default_language_version: | ||
python: python3.9 | ||
python: python3.9 | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
- repo: https://github.com/myint/autoflake | ||
rev: v2.2.0 | ||
hooks: | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: flake8 | ||
- id: debug-statements | ||
- id: check-added-large-files | ||
- id: pretty-format-json | ||
- id: autoflake | ||
name: Autoflake removes unused imports | ||
args: | ||
- --autofix | ||
- --indent=2 | ||
- --no-ensure-ascii | ||
- --no-sort-keys | ||
- repo: https://github.com/asottile/reorder_python_imports.git | ||
rev: v3.9.0 | ||
[ | ||
'--in-place', | ||
'--remove-all-unused-imports', | ||
'--ignore-init-module-imports', | ||
] | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: reorder-python-imports | ||
- repo: https://github.com/psf/black | ||
rev: 22.10.0 | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: debug-statements | ||
- id: check-added-large-files | ||
- id: pretty-format-json | ||
args: | ||
- --autofix | ||
- --indent=2 | ||
- --no-ensure-ascii | ||
- --no-sort-keys | ||
- repo: https://github.com/asottile/reorder_python_imports.git | ||
rev: v3.10.0 | ||
hooks: | ||
- id: reorder-python-imports | ||
- repo: https://github.com/psf/black | ||
rev: 23.7.0 | ||
hooks: | ||
- id: black | ||
name: Black | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 6.1.0 | ||
hooks: | ||
- id: flake8 | ||
name: Flake8 | ||
- repo: https://github.com/ubersan/pylic | ||
rev: v3.5.0 | ||
hooks: | ||
- id: black | ||
language_version: python3.9 | ||
- id: pylic | ||
args: [--allow-extra-safe-licenses] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
python 3.9.10 | ||
poetry 1.3.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.