Skip to content

Commit

Permalink
Replace makefile with poe tasks & update CONTRIBUTING.md
Browse files Browse the repository at this point in the history
The new `[tool.poe.tasks]` section and new poetry based workflow are a complete
replacement for the makefile which has also been removed. copier-org#129

Also:
- add devtasks for python functions to be referenced as poe tasks
- update CONTRIBUTING.MD copier-org#154 to keep things coherent
  - remove reference to tox
- update ci to work with more expressive toml syntax (upgrade pip)
  - and use poe tasks in ci
  • Loading branch information
nat-n committed Aug 21, 2020
1 parent df33b29 commit 0163efe
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 80 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
shell: bash
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: generate cache key PY
Expand All @@ -61,21 +61,23 @@ jobs:
key:
cache|${{ runner.os }}|${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: python -m pip install poetry poetry-dynamic-versioning
shell: bash
- run: poetry install
- name: Install dependencies
shell: bash
run: |
python -m pip install poetry poetry-dynamic-versioning poethepoet
poetry run python -m pip install pip -U
poetry install
- name: Run pre-commit
shell: bash
run: poetry run pre-commit run --all-files --color=always
run: poe lint --color=always
# FIXME Make pre-commit pass reliably on Windows, and remove this
continue-on-error: ${{ runner.os == 'Windows' }}
- name: Run mypy
shell: bash
run: poetry run mypy --ignore-missing-imports .
run: poe types
- name: Run pytest
shell: bash
run: poetry run pytest -n auto --color=yes --verbose .
run: poe test --verbose .

publish:
if: github.event_name == 'release'
Expand All @@ -84,7 +86,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: generate cache key PY
Expand All @@ -99,8 +101,10 @@ jobs:
key:
cache|${{ runner.os }}|${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: python -m pip install poetry poetry-dynamic-versioning
- run: poetry install
- name: Install dependencies
shell: bash
run: |
python -m pip install poetry poetry-dynamic-versioning
- name: Build dist
run: |
poetry build
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ pip-wheel-metadata
# Tests artifacts
.coverage*
htmlcov/

# macOS
.DS_Store
23 changes: 15 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ If you are proposing a feature:
- Remember that this is a volunteer-driven project, and that contributions are welcome
:)

## Dev environment setup

We use some tools as part of our development workflow which you'll need to install into
your host environment:

- [poetry](https://python-poetry.org/) for packaging and dependency management
- [poethepoet](https://github.com/nat-n/poethepoet) for running development tasks

## Get Started!

Ready to contribute? Here's how to set up the project for local development.
Expand All @@ -51,12 +59,11 @@ Ready to contribute? Here's how to set up the project for local development.
git clone git@github.com:copier-org/copier.git
```

3. Install your local copy into a virtualenv.
3. Use poetry to setup a virtualenv to develop in

```bash
python -m virtualenv .venv
source .venv/bin/activate
make install
poetry install # create's a virtualenv with all dependencies from pyproject.toml
poetry shell # creates a new shell with the virtualenv activated
```

5. Create a branch for local development:
Expand All @@ -70,8 +77,8 @@ Now you can make your changes locally.
6. When you're done making changes, check that your changes pass all tests

```bash
pytest -x .
flake8 .
poe test
poe lint
```

To have multiple Python versions on the same machine for running `tox`, I recommend
Expand All @@ -92,10 +99,10 @@ git push origin name-of-your-bugfix-or-feature
Before you submit a pull request, check that it meets these guidelines:

1. The pull request has code, it should include tests.
2. Run `tox` and make sure that the tests pass for all supported Python versions.
2. Check that all checks pass on GitHub CI

## Tips

To run a subset of tests:

$ pytest tests/the-tests-file.py
$ poe test tests/the-tests-file.py
42 changes: 0 additions & 42 deletions Makefile

This file was deleted.

30 changes: 30 additions & 0 deletions devtasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import shutil
from pathlib import Path


def clean():
"""
Clean build, test or other process artefacrts from the project workspace
"""
build_artefacts = (
"build/",
"dist/",
"*.egg-info",
"pip-wheel-metadata",
)
python_artefacts = (
".pytest_cache",
"htmlcov",
".coverage",
"**/__pycache__",
"**/*.pyc",
"**/*.pyo",
)
project_dir = Path(".").resolve()
for pattern in build_artefacts + python_artefacts:
for matching_path in project_dir.glob(pattern):
print(f"Deleting {matching_path}")
if matching_path.is_dir():
shutil.rmtree(matching_path)
else:
matching_path.unlink()
Loading

0 comments on commit 0163efe

Please sign in to comment.