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
19 changes: 19 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[flake8]
max-line-length = 100
extend-ignore = E203, E501, W503
exclude =
.git,
__pycache__,
.venv,
.venv-mo2fmu,
venv,
build,
dist,
*.egg-info,
.eggs,
node_modules
max-complexity = 30
docstring-convention = google
per-file-ignores =
__init__.py:F401
tests/*:D100,D101,D102,D103
65 changes: 38 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ on:
jobs:

build_wheel:
runs-on: self-${{ matrix.os }}
runs-on: [self-hosted, ubuntu-24.04, gaya]
continue-on-error: true
strategy:
fail-fast: false
max-parallel: 1
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
os: [ubuntu-24.04]
name: Build wheel package
if: "!contains(github.event.head_commit.message, 'skip wheel')"
if: ${{ !contains(github.event.head_commit.message, 'skip wheel') }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ifs: true
lfs: true
submodules: recursive
clean: true

Expand All @@ -36,28 +36,27 @@ jobs:

- name: Install Python/Node Env
run: |
uv venv
source .venv/bin/activate
uv pip install -r pyproject.toml --extra dev --extra test
uv venv .venv-mo2fmu
uv pip install --python .venv-mo2fmu -e ".[all]"
npm install
npx downdoc README.adoc

- name: Build mo2fmu wheel
- name: Code Quality Checks
run: |
source .venv/bin/activate
pipx run build
uv pip install dist/*.whl
source .venv-mo2fmu/bin/activate
ruff check src/python tests
black --check src/python tests
flake8 src/python tests
mypy src/python

- name: Sleep to avoid dymola license conflit
if: matrix.os == 'ubuntu-24.04'
- name: Build mo2fmu wheel
run: |
echo "Sleeping to wait dymola license availability"
sleep 120
uv build

- name: Python Tests
run: |
source .venv/bin/activate
pytest
source .venv-mo2fmu/bin/activate
pytest --cov=feelpp.mo2fmu --cov-report=term-missing --cov-report=xml

env:
PYTHONPATH: ${{ github.workspace }}
Expand All @@ -72,12 +71,12 @@ jobs:

build_docs:
needs: build_wheel
runs-on: self-${{ matrix.os }}
runs-on: [self-hosted, ubuntu-24.04, gaya]
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
os: [ubuntu-24.04]
name: Build & Deploy docs
if: "!contains(github.event.head_commit.message, 'skip docs')"
if: ${{ !contains(github.event.head_commit.message, 'skip docs') }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -105,21 +104,20 @@ jobs:

- name: Install Python deps
run: |
uv venv
source .venv/bin/activate
uv pip install dist/*.whl
uv venv .venv-mo2fmu
uv pip install --python .venv-mo2fmu dist/*.whl

- name: Build Antora site
run: |
source .venv/bin/activate
source .venv-mo2fmu/bin/activate
npm install
npm run antora || true
npm run antora
env:
GIRDER_API_KEY: ${{ secrets.GIRDER }}

- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-22.04'
if: github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-24.04'
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -131,16 +129,22 @@ jobs:
runs-on: ubuntu-latest
needs: build_wheel
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
id-token: write
environment:
name: pypi
url: https://pypi.org/p/feelpp-mo2fmu
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download wheel artifact (Ubuntu 22.04)
- name: Download wheel artifact (Ubuntu 24.04)
uses: actions/download-artifact@v4
with:
name: artifacts-wheel-ubuntu-22.04
name: artifacts-wheel-ubuntu-24.04
path: ./dist/

- name: Create Release & Upload Wheel
Expand All @@ -153,3 +157,10 @@ jobs:
LICENSE
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
verbose: true

17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,19 @@ dist
node_modules/
**/__pycache__/
.env
.venv/
.venv/
.venv-mo2fmu/

# Test artifacts and FMU outputs
*.fmu
toto/

# Coverage reports
.coverage
htmlcov/
coverage.xml

# Type checking and linting
.mypy_cache/
.ruff_cache/
.pytest_cache/
48 changes: 48 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Pre-commit configuration for code quality checks
# Install: pip install pre-commit
# Setup: pre-commit install
# Run manually: pre-commit run --all-files

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- id: check-toml
- id: debug-statements
- id: mixed-line-ending

- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
language_version: python3

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings, flake8-bugbear]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: [types-all]
args: [--ignore-missing-imports]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

FROM ghcr.io/feelpp/dymola:2021
FROM ghcr.io/feelpp/dymola:2025

USER root
RUN pip3 install click spdlog
COPY pyproject.toml .
COPY src/ ./src/
RUN pip3 install click spdlog xvfbwrapper pathlib
RUN pip3 install --editable .


Expand Down
15 changes: 15 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include README.md
include LICENSE
include pyproject.toml
include .flake8

recursive-include src *.py py.typed
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

exclude .gitignore
exclude Makefile
exclude Dockerfile
prune tests
prune docs
prune .github
92 changes: 92 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
.PHONY: help venv install install-dev clean clean-all lint format type-check test test-cov all-checks build publish

# Unset VIRTUAL_ENV to avoid uv warnings
unexport VIRTUAL_ENV

help:
@echo "Available targets:"
@echo " venv - Create virtual environment with uv"
@echo " install - Install package in editable mode with uv"
@echo " install-dev - Install package with all development dependencies"
@echo " clean - Remove build artifacts and cache files"
@echo " clean-all - Remove build artifacts, caches, and virtual environment"
@echo " lint - Run linting (flake8, ruff)"
@echo " format - Format code (black, isort)"
@echo " format-check - Check code formatting without making changes"
@echo " type-check - Run type checking (mypy)"
@echo " test - Run tests"
@echo " test-cov - Run tests with coverage report"
@echo " all-checks - Run all checks (format-check, lint, type-check, test)"
@echo " build - Build distribution packages with uv"
@echo " publish - Publish to PyPI (requires TWINE_USERNAME and TWINE_PASSWORD)"
@echo " publish-test - Publish to TestPyPI"

venv:
@echo "Creating virtual environment with uv..."
uv venv .venv-mo2fmu
@echo "✅ Virtual environment created at .venv-mo2fmu"
@echo "To install dependencies, run: make install-dev"

install: venv
uv pip install --python .venv-mo2fmu -e .

install-dev: venv
uv pip install --python .venv-mo2fmu -e ".[all]"

clean:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
rm -rf src/**/*.egg-info
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
rm -rf .coverage htmlcov/ .pytest_cache/
@echo "✅ Cleaned build artifacts and caches"

clean-all: clean
rm -rf .venv-mo2fmu
@echo "✅ Removed virtual environment"

lint:
@echo "Running flake8..."
uv run --python .venv-mo2fmu flake8 src/python tests
@echo "Running ruff..."
uv run --python .venv-mo2fmu ruff check src/python tests

format:
@echo "Organizing imports and formatting..."
uv run --python .venv-mo2fmu ruff check --fix src/python tests
@echo "Running black..."
uv run --python .venv-mo2fmu black src/python tests

format-check:
@echo "Checking imports and formatting..."
uv run --python .venv-mo2fmu ruff check src/python tests
@echo "Checking black..."
uv run --python .venv-mo2fmu black --check src/python tests

type-check:
@echo "Running mypy..."
uv run --python .venv-mo2fmu mypy src/python

test:
uv run --python .venv-mo2fmu pytest tests/

test-cov:
uv run --python .venv-mo2fmu pytest --cov=feelpp.mo2fmu --cov-report=term-missing --cov-report=html tests/

all-checks: format-check lint type-check test
@echo "✅ All checks passed!"

build: clean
uv build --python .venv-mo2fmu

publish: build
uv run --python .venv-mo2fmu twine upload dist/*

publish-test: build
uv run --python .venv-mo2fmu twine upload --repository testpypi dist/*
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Options:
--version TEXT the FMI version.
--dymola PATH path to Dymola root.
--dymolapath PATH path to Dymola executable.
--dymolaegg PATH path to Dymola egg file, relative to Dymola
--dymolawhl PATH path to Dymola whl file, relative to Dymola
root.
-v, --verbose verbose mode.
-f, --force force FMU generation even if file exists.
Expand All @@ -64,7 +64,7 @@ mo2fmu(
fmi_version="2.0",
dymola_root="/path/to/dymola/root",
dymola_executable="/path/to/dymola/executable",
dymola_egg="/path/to/dymola.egg",
dymola_whl="/path/to/dymola.whl",
verbose=True,
force=False
)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Options:
--version TEXT the FMI version.
--dymola PATH path to Dymola root.
--dymolapath PATH path to Dymola executable.
--dymolaegg PATH path to Dymola egg file, relative to Dymola
--dymolawhl PATH path to Dymola whl file, relative to Dymola
root.
-v, --verbose verbose mode.
-f, --force force FMU generation even if file exists.
Expand All @@ -49,7 +49,7 @@ mo2fmu(
fmi_version="2.0",
dymola_root="/path/to/dymola/root",
dymola_executable="/path/to/dymola/executable",
dymola_egg="/path/to/dymola.egg",
dymola_whl="/path/to/dymola.whl",
verbose=True,
force=False
)
Expand Down
Loading
Loading