Skip to content
Closed

Make #649

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
39 changes: 0 additions & 39 deletions .github/ISSUE_TEMPLATE/workflows/main.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/actions/setup-project/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Action: Setup Project (composite action)
#
# Purpose: Bootstrap a Python project in GitHub Actions by:
# - Installing Task, uv, and uvx into a local ./bin directory
# - Detecting presence of pyproject.toml and exposing it as an output
# - Creating a virtual environment with uv and syncing dependencies
#
# Inputs:
# - python-version: Python version used for the virtual environment (default: 3.12)
#
# Outputs:
# - pyproject_exists: "true" if pyproject.toml exists, otherwise "false"
#
# Notes:
# - Safe to run in repositories without pyproject.toml; dependency sync will be skipped.
# - Used by workflows such as CI, Book, Marimo, and Release.

name: 'Setup Project'
description: 'Setup the project'

inputs:
python-version:
description: 'Python version to use'
required: false
default: '3.12'

outputs:
pyproject_exists:
description: 'Flag indicating whether pyproject.toml exists'
value: ${{ steps.check_pyproject.outputs.exists }}

runs:
using: 'composite'
steps:
- name: Set up task, uv, uvx and the venv
shell: bash
run: |
mkdir -p bin

# Add ./bin to the PATH
echo "Adding ./bin to PATH"
echo "$(pwd)/bin" >> $GITHUB_PATH

# Install Task
curl -fsSL https://taskfile.dev/install.sh | sh -s -- -d -b ./bin

# Install uv and uvx
curl -fsSL https://astral.sh/uv/install.sh | UV_INSTALL_DIR="./bin" sh

- name: Check version for task
shell: bash
run: |
task --version

- name: Check version for uv
shell: bash
run: |
uv --version

- name: Check for pyproject.toml
id: check_pyproject
shell: bash
run: |
if [ -f "pyproject.toml" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

- name: Build the virtual environment
shell: bash
run: uv venv --python ${{ inputs.python-version }}

- name: "Sync the virtual environment for ${{ github.repository }} if pyproject.toml exists"
shell: bash
run: |
if [ -f "pyproject.toml" ]; then
uv sync --all-extras
else
echo "No pyproject.toml found, skipping package installation"
fi
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This file is part of the tschm/.config-templates repository
# (https://github.com/tschm/.config-templates).
#
# Workflow: Continuous Integration
#
# Purpose: This workflow runs tests on multiple Python versions to ensure
# compatibility and code quality across different environments.
#
# Trigger: This workflow runs on every push and on pull requests to main/master
# branches (including from forks)
#
# Components:
# - 🧪 Run tests on multiple Python versions
# - 🔄 Matrix strategy for testing on different environments

name: "CI"

permissions:
contents: read

on:
push:
pull_request:
branches: [ main, master ]

jobs:
test:
# if: github.repository != 'tschm/.config-templates'
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}

strategy:
matrix:
# mongo container action only supported on Linux
os: [ ubuntu-latest ]
python-version: [ '3.10', '3.11', '3.12', '3.13', '3.14']

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
lfs: true

# Use the composite action to set up the project
- name: Setup the project
id: setup
uses: ./.github/actions/setup-project
with:
python-version: ${{ matrix.python-version }}

- name: "Run the tests"
run: |
# if there is a tests/requirements.txt file, install it
if [ -f "tests/requirements.txt" ]; then
uv pip install -r tests/requirements.txt
fi
uv pip install pytest
uv run pytest tests
39 changes: 0 additions & 39 deletions .github/workflows/codecov.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/deptry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Workflow: Deptry
#
# Purpose: This workflow identifies missing and obsolete dependencies in the project.
# It helps maintain a clean dependency tree by detecting unused packages and
# implicit dependencies that should be explicitly declared.
#
# Trigger: This workflow runs on every push and on pull requests to main/master
# branches (including from forks)

name: "DEPTRY"

# Permissions: Only read access to repository contents is needed
permissions:
contents: read

on:
push:
pull_request:
branches: [ main, master ]

jobs:
deptry_analysis:
name: Check dependencies with deptry
runs-on: ubuntu-latest
container:
image: ghcr.io/astral-sh/uv:0.9.5-python3.12-trixie

steps:
- uses: actions/checkout@v5

- name: Run deptry
run: |
set -euo pipefail
if [ -f "pyproject.toml" ]; then
if [ -d "src" ]; then
SOURCE_FOLDER="src"
else
SOURCE_FOLDER="."
fi
uvx deptry "$SOURCE_FOLDER"
else
printf "${YELLOW:-}[WARN] No pyproject.toml found, skipping deptry${RESET:-}\n"
fi
92 changes: 46 additions & 46 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: pytest

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
pytest:
name: py${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest isort black flake8
pip install ecos
- name: Test with pytest
run: |
pytest ./tests
- name: Check with isort
run: |
isort --check --diff .
- name: Check with black
run: |
black --check --diff .
- name: Check with flake8
run: |
flake8 --show-source --statistics .
## This workflow will install Python dependencies, run tests and lint with a variety of Python versions
## For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
#
#name: pytest
#
#on:
# push:
# branches: ["main"]
# pull_request:
# branches: ["main"]
#
#jobs:
# pytest:
# name: py${{ matrix.python-version }} on ${{ matrix.os }}
# runs-on: ${{ matrix.os }}
# env:
# MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434
# strategy:
# matrix:
# os: [ubuntu-latest, macos-latest, windows-latest]
# python-version: ["3.9", "3.10", "3.11", "3.12"]
#
# steps:
# - uses: actions/checkout@v4
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}
# cache: "pip"
# - name: Install dependencies
# run: |
# pip install -r requirements.txt
# pip install pytest
# pip install ecos
# - name: Test with pytest
# run: |
# pytest ./tests
# #- name: Check with isort
# # run: |
# # isort --check --diff .
# #- name: Check with black
# # run: |
# # black --check --diff .
# #- name: Check with flake8
# # run: |
# # flake8 --show-source --statistics .
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
.git
*.pyc
.idea
build
sandbox
.DS_Store

tests/dockerfiles/
.tox/
docs/_build/
media/logo_design/
DEV/
.pytest_cache/
.vscode/

# folder used for task
bin

# Environments
.env
.venv
Expand Down Expand Up @@ -48,3 +48,4 @@ dist

artifacts

_tests
Loading