Skip to content

Commit

Permalink
Merge branch 'main' into swithc-project-poetry-to-non-package-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
denys-chura authored Oct 11, 2024
2 parents 86e7917 + 90f89ae commit 11aa137
Show file tree
Hide file tree
Showing 8 changed files with 761 additions and 692 deletions.
39 changes: 24 additions & 15 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,33 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.12.5
- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: 3.12.5
- name: Install Python dependencies
run: |
python3 -m venv venv
source ./venv/bin/activate
pip install -U pip
pip install -r ./requirements.txt
- name: Run tests on hooks
run: |
source ./venv/bin/activate
inv test.hooks
- name: Run tests on building project
python-version: 3.13
- name: Install & configure poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-path: .venv
installer-parallel: true
- name: Load cached venv if exists
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies if cache doesn't exist
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction
# NOTE: there are nothing to test yet, unless we add some hooks, just check that it runs
- name: Run tests on skeleton code
run: poetry run inv test.hooks
- name: Build default project from skeleton and run tests
run: |
source ./venv/bin/activate
cookiecutter --no-input --overwrite-if-exists --output-dir build .
poetry run cookiecutter --no-input --overwrite-if-exists --output-dir build .
cd build/awesome
cp ./api/.env.example ./api/.env
make api-test
22 changes: 0 additions & 22 deletions contrib/docker/docker-compose-local.yml

This file was deleted.

723 changes: 723 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool.poetry]
package-mode = false

[tool.poetry.dependencies]
python = "^3.13"
cookiecutter = "^2.6.0"
pytest = "^8.3.3"
pytest-cov = "^5.0.0"
invoke = "^2.2.0"

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["tests.py", "test_*.py", "*_tests.py"]
3 changes: 0 additions & 3 deletions pytest.ini

This file was deleted.

8 changes: 0 additions & 8 deletions requirements.in

This file was deleted.

597 changes: 0 additions & 597 deletions requirements.txt

This file was deleted.

48 changes: 1 addition & 47 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,11 @@
import os
from shutil import rmtree

from invoke import Collection, task


def path(*args):
current_dir = os.path.dirname(os.path.abspath(__file__))
return os.path.join(current_dir, *args)


@task()
def compose_up(ctx, daemon=False):
with ctx.cd(path("contrib", "docker")):
command = "docker-compose --file docker-compose-local.yml --project-name=awesome up"
if daemon:
command = f"{command} -d"
ctx.run(command, pty=True, replace_env=False)


@task()
def compose_down(ctx, volumes=False):
with ctx.cd(path("contrib", "docker")):
command = "docker-compose --file docker-compose-local.yml --project-name=awesome down"
if volumes:
command = f"{command} -v"
ctx.run(command, pty=True, replace_env=False)


@task()
def pip_compile(ctx):
command = (
"pip-compile --upgrade --generate-hashes --allow-unsafe "
"-o ./requirements.txt ./requirements.in"
)
ctx.run(command, pty=True)


@task()
def pip_sync(ctx):
ctx.run("pip-sync ./requirements.txt", pty=True)


@task()
def test_hooks(ctx):
ctx.run("pytest -s --cov=hooks --cov-report=html", pty=True, replace_env=False)


compose_collection = Collection("compose")
compose_collection.add_task(compose_up, name="up")
compose_collection.add_task(compose_down, name="down")
pip_collection = Collection("pip")
pip_collection.add_task(pip_compile, name="compile")
pip_collection.add_task(pip_sync, name="sync")
test_collection = Collection("test")
test_collection.add_task(test_hooks, name="hooks")
namespace = Collection(compose_collection, pip_collection, test_collection, )
namespace = Collection(test_collection)

0 comments on commit 11aa137

Please sign in to comment.