diff --git a/snakedeploy/scaffold_plugins/common.py b/snakedeploy/scaffold_plugins/common.py index f321b7f..f0a1385 100644 --- a/snakedeploy/scaffold_plugins/common.py +++ b/snakedeploy/scaffold_plugins/common.py @@ -65,6 +65,17 @@ def save_pyproject(pyproject): # the python dependency should be in line with the dependencies pyproject["project"]["requires-python"] = ">=3.11,<4.0" + # configure coverage + pyproject["tool"]["coverage"] = { + "report": { + "exclude_lines": [ + "pass", + "\\.\\.\\.", + ], + "fail_under": 90.0, + } + } + save_pyproject(pyproject) # add dependencies @@ -79,8 +90,9 @@ def save_pyproject(pyproject): "--feature", "dev", "ruff", - "coverage", "pytest", + "pytest-cov", + "pyrefly", "twine", "build", ] @@ -93,11 +105,19 @@ def save_pyproject(pyproject): save_pyproject(pyproject) sp.run( - ["pixi", "task", "add", "--feature", "dev", "lint", "ruff check"], + ["pixi", "task", "add", "--feature", "dev", "lint", "ruff check src tests"], + check=True, + ) + sp.run( + ["pixi", "task", "add", "--feature", "dev", "format", "ruff format src tests"], + check=True, + ) + sp.run( + ["pixi", "task", "add", "--feature", "dev", "typecheck", "pyrefly check src tests"], check=True, ) sp.run( - ["pixi", "task", "add", "--feature", "dev", "format", "ruff format"], + ["pixi", "task", "add", "--feature", "dev", "coverage-report", "coverage report -m"], check=True, ) sp.run( @@ -109,10 +129,10 @@ def save_pyproject(pyproject): "dev", "test", "pytest " - f"--cov={package_name} " + f"--cov={package_name.replace('-', '_')} " "--cov-report=xml:coverage-report/coverage.xml " "--cov-report=term-missing " - "tests/tests.py", + "tests/test_plugin.py", ], check=True, ) @@ -157,7 +177,6 @@ def render_template(name, dest: Path): (tests_path / "__init__.py").unlink(missing_ok=True) - render_template("setup.cfg.j2", Path("setup.cfg")) render_template("release_please.yml.j2", workflows_path / "release-please.yml") render_template("ci.yml.j2", workflows_path / "ci.yml") render_template( diff --git a/snakedeploy/templates/plugins/ci.yml.j2 b/snakedeploy/templates/plugins/ci.yml.j2 index ea12ced..3e3bc74 100644 --- a/snakedeploy/templates/plugins/ci.yml.j2 +++ b/snakedeploy/templates/plugins/ci.yml.j2 @@ -6,65 +6,53 @@ on: - main pull_request: -env: - PYTHON_VERSION: 3.11 - jobs: - linting: + format: runs-on: ubuntu-latest steps: - name: Check out the code - uses: actions/checkout@v3 + uses: actions/checkout@v6 - - uses: actions/setup-python@v4 - with: - python-version: {{ "${{ env.PYTHON_VERSION }}" }} + - name: Setup pixi + uses: prefix-dev/setup-pixi@v0 - - name: Install poetry - run: pip install poetry + - name: Check formatting + run: pixi run format --check - - name: Determine dependencies - run: poetry lock + lint: + runs-on: ubuntu-latest + steps: + - name: Check out the code + uses: actions/checkout@v6 - - uses: actions/setup-python@v4 - with: - python-version: {{ "${{ env.PYTHON_VERSION }}" }} - cache: poetry + - name: Setup pixi + uses: prefix-dev/setup-pixi@v0 - - name: Install Dependencies using Poetry - run: poetry install + - name: Check code + run: pixi run lint - - name: Check formatting - run: poetry run ruff format --check . - - - name: Lint - run: poetry run ruff check . - - testing: + typecheck: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 - with: - python-version: {{ "${{ env.PYTHON_VERSION }}" }} + - name: Check out the code + uses: actions/checkout@v6 - - name: Install poetry - run: pip install poetry + - name: Setup pixi + uses: prefix-dev/setup-pixi@v0 - - name: Determine dependencies - run: poetry lock + - name: Check code + run: pixi run typecheck - - uses: actions/setup-python@v4 - with: - python-version: {{ "${{ env.PYTHON_VERSION }}" }} - cache: poetry + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 - - name: Install dependencies - run: poetry install + - name: Setup pixi + uses: prefix-dev/setup-pixi@v0 - name: Run pytest - run: poetry run coverage run -m pytest + run: pixi run test -v - name: Run Coverage - run: poetry run coverage report -m + run: pixi run coverage-report diff --git a/snakedeploy/templates/plugins/setup.cfg.j2 b/snakedeploy/templates/plugins/setup.cfg.j2 deleted file mode 100644 index 43a5b43..0000000 --- a/snakedeploy/templates/plugins/setup.cfg.j2 +++ /dev/null @@ -1,7 +0,0 @@ -[flake8] -# Recommend matching the black line length (default 88), -# rather than using the flake8 default of 79: -max-line-length = 88 -extend-ignore = - # See https://github.com/PyCQA/pycodestyle/issues/373 - E203, \ No newline at end of file