Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 98 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,83 @@ concurrency:
cancel-in-progress: true

jobs:
# --------------------------------------------------------------------------
# LINT (Ruff)
# --------------------------------------------------------------------------
lint:
name: Lint (Ruff)
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Install dependencies
run: |
poetry install --no-interaction --no-ansi --with dev

- name: Run Ruff
run: |
poetry run ruff format --check .
poetry run ruff check .

# --------------------------------------------------------------------------
# TYPE CHECK (Mypy)
# --------------------------------------------------------------------------
typecheck:
name: Type Check (Mypy)
runs-on: ubuntu-latest
needs: lint

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Install dependencies
run: |
poetry install --no-interaction --no-ansi --with dev

- name: Run Mypy
run: |
poetry run mypy --install-types --non-interactive || true
poetry run mypy src/ tests/ --ignore-missing-imports --disable-error-code=call-overload

# --------------------------------------------------------------------------
# TESTS (Pytest + Coverage)
# --------------------------------------------------------------------------
test:
name: Lint • Type Check • Test Coverage (Python ${{ matrix.python-version }})
name: Test & Coverage (Pytest)
runs-on: ubuntu-latest
needs: typecheck

strategy:
fail-fast: false
matrix:
include:
- python-version: "3.11"
experimental: false
- python-version: "3.12"
experimental: false
- python-version: "3.13"
experimental: false
continue-on-error: ${{ matrix.experimental }}
python-version: ["3.11", "3.12", "3.13"]

steps:
- name: Checkout
Expand All @@ -52,7 +115,7 @@ jobs:
path: .venv
key: v1-poetry-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies (with dev group)
- name: Install dependencies (with dev)
if: steps.cache.outputs.cache-hit != 'true'
run: |
poetry env use "${{ steps.py.outputs.python-path }}"
Expand All @@ -64,29 +127,36 @@ jobs:
poetry env use "${{ steps.py.outputs.python-path }}"
poetry install --no-interaction --no-ansi --with dev

- name: Show tool versions
- name: Run Pytest
run: |
poetry run python -V
poetry run ruff --version
poetry run mypy --version
poetry run pytest --version
poetry run pytest -q --cov=change_me --cov-report=term-missing --cov-report=xml --cov-fail-under=85

- name: Ruff (format & lint)
run: |
poetry run ruff format --check .
poetry run ruff check .
- name: Upload coverage XML artifact
if: ${{ matrix.python-version == '3.12' }}
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml

- name: Mypy (type check)
run: |
poetry run mypy --install-types --non-interactive || true
poetry run mypy src/ tests/ --ignore-missing-imports --disable-error-code=call-overload
# --------------------------------------------------------------------------
# COVERALLS (upload coverage)
# --------------------------------------------------------------------------
coveralls:
name: Coverage Upload (Coveralls)
runs-on: ubuntu-latest
needs: test

- name: Pytest (with coverage)
run: |
poetry run pytest -q --cov=change_me --cov-report=term-missing --cov-report=xml --cov-fail-under=85
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Upload coverage to Coveralls
if: ${{ matrix.python-version == '3.12' }}
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-xml
path: .

- name: Upload to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ We welcome issues, bug reports, feature requests, and pull requests.
* Follow the existing code style in the project.
* Use descriptive names for variables, functions, and classes.
* Add docstrings or comments where needed for clarity.
```bash
make format # easy command for quick formatting help
```

### Testing
* Ensure that your code runs without errors.
* Add or update tests if applicable.
* Run all tests before submitting:
```bash
make test
make test # easy command to run all the tests
```

### Pull Requests
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := /bin/bash

init:
python3 -m venv .venv
poetry install
poetry install --with dev
pre-commit install
poetry env info
@echo "Created virtual environment"
Expand Down Expand Up @@ -30,7 +30,6 @@ update:
poetry cache clear pypi --all
poetry update


docker:
docker build --no-cache -f Dockerfile -t change_me-smoke .
docker run --rm change_me-smoke
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,26 @@ Simple README.md for a Python project template.
## Install
To install the library run:

```pip install change-me```
```pip install <your-package-name>```

OR

```pip install git+https://github.com/TUM-Aries-Lab/template-python.git@<specific-tag>```
```pip install git+https://github.com/TUM-Aries-Lab/<your-package-name>.git@<specific-tag>```

## Development
0. Install [Poetry](https://python-poetry.org/docs/#installing-with-the-official-installer)
1. `make init` to create the virtual environment and install dependencies
2. `make format` to format the code and check for errors
3. `make test` to run the test suite
4. `make clean` to delete the temporary files and directories
5. `poetry publish --build` to build and publish to https://pypi.org/project/change-me

## Publishing
It's super easy to publish your own packages on PyPI. To build and publish this package run:

```bash
poetry publish --build
```
The package can then be found at: https://pypi.org/project/change-me

## Module Usage
```
Expand Down
Loading