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
42 changes: 28 additions & 14 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
---
name: Codecov Coverage Report
name: "Codecov Coverage Report"

on: # yamllint disable-line rule:truthy
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Makes it reusable; called by other workflows
workflow_call:
secrets:
CODECOV_TOKEN:
description: "CODECOV Auth Token"
required: true

jobs:
run:
runs-on: ${{ matrix.os }}
# Adding 'timeout-minutes: 10' would prevent jobs from running
# indefinitely if something goes wrong
timeout-minutes: 10
strategy:
matrix:
os: [ubuntu-latest]
os: ["ubuntu-latest"]
python-version: ["3.12"]
steps:
- uses: actions/checkout@main
- name: Setup Python
uses: actions/setup-python@main
- uses: "actions/checkout@main"
- name: "Setup Python"
uses: "actions/setup-python@main"
with:
python-version: ${{ matrix.python-version }}
- name: Install prerequisites
- name: "Cache PIP Dependencies"
uses: "actions/cache@v4"
with:
path: ~/.cache/pip
key: |
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
- name: "Install prerequisites"
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
- name: Install pytest, pytest-cov
- name: "Install pytest, pytest-cov"
run: |
pip install pytest
pip install pytest-cov
Expand All @@ -33,12 +47,12 @@ jobs:
run: |
python -c "import os; print(os.getcwd())"
python -m pytest . --ignore=solutions --log-cli-level=INFO -v --cov-report term-missing --cov --cov-branch --cov-report=xml
- name: List test files
- name: "List test files"
run: |
ls *.xml
# yamllint enable rule:line-length
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5.5.1
- name: "Upload coverage to Codecov"
uses: "codecov/codecov-action@v5.5.1"
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
23 changes: 11 additions & 12 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
---
name: "Flake8"
name: "Flake8 Workflow"

on: # yamllint disable-line rule:truthy
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Makes it reusable; called by other workflows
workflow_call:

permissions:
contents: "read"
Expand All @@ -22,19 +20,20 @@ jobs:
python-version: ["3.12"]
steps:
- uses: "actions/checkout@v5"
- name: "Cache PIP Dependencies"
uses: "actions/cache@v4"
with:
path: "~/.cache/pip"
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python ${{ matrix.python-version }}
# This is the version of the action for setting up Python,
# not the Python version.
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: "Cache PIP Dependencies"
uses: "actions/cache@v4"
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
# You can test your matrix by printing the current
# Python version
- name: "Display Python Version"
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/lint_test_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: "Lint->Test->Report"

on: # yamllint disable-line rule:truthy
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions:
contents: "read"
pull-requests: "read"

jobs:
ruff:
name: "Ruff Lint and Format"
uses: "./.github/workflows/ruff.yml"
pylint:
name: "Pylint Workflow"
uses: "./.github/workflows/pylint.yml"
flake8:
name: "Flake8 Workflow"
uses: "./.github/workflows/flake8.yml"
pytest:
name: "Pytest Workflow"
needs:
- "ruff"
- "pylint"
- "flake8"
uses: "./.github/workflows/pytest.yml"
codecov:
name: "Codecov Coverage Report"
needs:
- "pytest"
uses: "./.github/workflows/codecov.yml"
secrets:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
31 changes: 21 additions & 10 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
name: Pylint
---
name: "Pylint Workflow"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Makes it reusable; called by other workflows
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
# Adding 'timeout-minutes: 10' would prevent jobs from running
# indefinitely if something goes wrong
timeout-minutes: 10
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v5
- uses: "actions/checkout@v5"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
uses: "actions/setup-python@v6"
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: "Cache PIP Dependencies"
uses: "actions/cache@v4"
with:
path: ~/.cache/pip
key: |
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install pylint
pip install -r requirements.txt
- name: Analysing the code with pylint
- name: "Analysing the code with pylint"
run: |
python -m pylint --verbose $(find . -name "*.py" ! -path "*/.venv/*" ! -path "*/venv/*") --rcfile=.pylintrc
44 changes: 26 additions & 18 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
name: Pytest Workflow
---
name: "Pytest Workflow"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Makes it reusable; called by other workflows
workflow_call:

jobs:
test:
runs-on: ubuntu-latest

runs-on: "ubuntu-latest"
# Adding 'timeout-minutes: 10' would prevent jobs from running
# indefinitely if something goes wrong
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Set up Python 3.12
uses: actions/setup-python@v6
- name: "Checkout code"
uses: "actions/checkout@v5"
- name: "Set up Python 3.12"
uses: "actions/setup-python@v6"
with:
python-version: '3.12'

- name: Install dependencies
python-version: "3.12"
- name: "Cache PIP Dependencies"
uses: "actions/cache@v4"
with:
path: ~/.cache/pip
key: |
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest

- name: Run pytest
run: pytest . --verbose --ignore=solutions --log-cli-level=INFO
- name: "Run pytest"
run: |
pytest . --verbose --ignore=solutions --log-cli-level=INFO
43 changes: 28 additions & 15 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
name: Ruff Lint and Format
---
name: "Ruff Lint and Format"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Makes it reusable; called by other workflows
workflow_call:

jobs:
ruff:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
# Adding 'timeout-minutes: 10' would prevent jobs from running
# indefinitely if something goes wrong
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
- name: Set up Python 3.12
uses: actions/setup-python@v6
- uses: "actions/checkout@v5"
- name: "Set up Python 3.12"
uses: "actions/setup-python@v6"
with:
python-version: '3.12'
- name: Install Ruff
python-version: "3.12"
- name: "Cache PIP Dependencies"
uses: "actions/cache@v4"
with:
path: ~/.cache/pip
key: |
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
- name: "Install Ruff"
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Ruff lint
run: ruff check --output-format=github .
- name: Run Ruff format check
run: ruff format --check .
- name: "Run Ruff lint"
run: |
ruff check --output-format=github .
- name: "Run Ruff format check"
run: |
ruff format --check .
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Use Ubuntu 24.04 as base, matching the GitHub Actions runner (ubuntu-latest is based on 22.04/24.04 variants)
FROM ubuntu:24.04

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies and Python 3.12
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.12 \
python3.12-venv \
python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Set Python 3.12 as default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1 \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1

# Create a virtual environment to avoid externally managed environment issues
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Upgrade pip and install wheel/setuptools in the venv
RUN python -m pip install --upgrade pip setuptools wheel

# Set working directory
WORKDIR /app

# Copy requirements.txt (if it exists) and install dependencies in the venv
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Install linting and testing tools in the venv
RUN pip install --no-cache-dir \
ruff \
flake8 \
pylint \
pytest \
pytest-cov

# Copy the rest of the code (including .pylintrc if present)
COPY . .

# Default command: bash shell for interactive use
CMD ["bash"]
Loading