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: 19 additions & 23 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# SPDX-License-Identifier: MPL-2.0


name: Build and Test

on:
Expand All @@ -28,20 +27,16 @@ concurrency:
cancel-in-progress: true

jobs:

build-python:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:

- name: Checkout source code
uses: actions/checkout@v6

- name: Setup Python 3.13
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Set PyPI version
uses: PowerGridModel/pgm-version-bump@main
Expand All @@ -51,8 +46,7 @@ jobs:
- name: Build
run: |
cat PYPI_VERSION
pip install build
python -m build --outdir wheelhouse .
uv build --sdist --no-create-gitignore --out-dir wheelhouse .

- name: Save version
id: version
Expand All @@ -74,12 +68,11 @@ jobs:
runs-on: ${{ matrix.os }}

steps:

- name: Checkout source code
uses: actions/checkout@v6

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python }}

Expand All @@ -89,11 +82,14 @@ jobs:
name: power-grid-model-io
path: wheelhouse/

- name: Create environment
run: uv venv

- name: Install built wheel file
run: pip install power-grid-model-io[dev]==${{ needs.build-python.outputs.version }} --find-links=wheelhouse
run: uv pip install power-grid-model-io==${{ needs.build-python.outputs.version }} --find-links=wheelhouse

- name: Unit test and coverage
run: pytest --verbose
run: uv run --only-group test --no-editable pytest --verbose

validation-tests:
needs: build-python
Expand All @@ -105,12 +101,11 @@ jobs:
runs-on: ${{ matrix.os }}

steps:

- name: Checkout source code
uses: actions/checkout@v6

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python }}

Expand All @@ -120,11 +115,14 @@ jobs:
name: power-grid-model-io
path: wheelhouse/

- name: Create environment
run: uv venv

- name: Install built wheel file
run: pip install power-grid-model-io[dev]==${{ needs.build-python.outputs.version }} --find-links=wheelhouse
run: uv pip install power-grid-model-io==${{ needs.build-python.outputs.version }} --find-links=wheelhouse

- name: Validation tests
run: pytest tests/validation --no-cov --verbose
run: uv run --only-group test --no-editable pytest tests/validation --no-cov --verbose

github-release:
needs:
Expand All @@ -135,10 +133,8 @@ jobs:
contents: write
runs-on: ubuntu-latest
steps:
- name: Setup Python 3.13
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Load built wheel file
uses: actions/download-artifact@v7
Expand Down
29 changes: 16 additions & 13 deletions .github/workflows/check-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,27 @@ jobs:
- name: Checkout
uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.11
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Upgrade pip
run: pip install --upgrade pip
- name: Install most linters from uv
run: |
uv sync --group lint

- name: Run mypy
run: |
uv run mypy .

- name: Install and run mypy
- name: Run ruff
run: |
pip install mypy
mypy src
uv run ruff check .
uv run ruff format .

- name: Install and run ruff
- name: Install and run markdownlint
run: |
pip install ruff .
ruff check .
ruff format .
npm install -g markdownlint-cli@0.47.0
echo "Running markdownlint"
markdownlint --fix .

- name: If needed raise error
run: |
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-pr-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# SPDX-License-Identifier: MPL-2.0


name: Check PR Labels

on:
Expand Down
110 changes: 110 additions & 0 deletions .github/workflows/refresh-lock-and-linter-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# SPDX-License-Identifier: MPL-2.0

name: Refresh lock and linter Dependencies

on:
workflow_call:
inputs:
create-pr:
type: boolean
description: "Whether to create a pull request with the changes"
required: false
default: false
workflow_dispatch:
inputs:
create-pr:
type: boolean
description: "Whether to create a pull request with the changes"
required: false
default: false
schedule:
- cron: "0 2 * * 0" # Every Sunday at 2:00 UTC


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-linter-dependencies
cancel-in-progress: true


jobs:
refresh-lock-and-linter-dependencies:
name: Refresh lock and linter Dependencies
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

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

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: upgrade uv lock
run: uv lock --upgrade

- name: Install linters from uv
run: |
uv sync --only-group lint

- name: retrieve versions
id: versions
run: |
grab_installed_version() {
local pkg="$1"
local version
version=$(uv pip freeze | grep -i "^$pkg==" | head -n1 | cut -d= -f3)
echo "${pkg}=$version" >> "$GITHUB_OUTPUT"
}
grab_installed_version "ruff"
grab_installed_version "clang-format"
grab_installed_version "mypy"
grab_installed_version "gersemi"

- name: Update .pre-commit-config.yaml
uses: cuchi/jinja2-action@v1.3.0
with:
template: .pre-commit-config.yaml.jinja
output_file: .pre-commit-config.yaml
variables: |
ruff=${{ steps.versions.outputs.ruff }}
clang_format=${{ steps.versions.outputs.clang-format }}
mypy=${{ steps.versions.outputs.mypy }}
gersemi=${{ steps.versions.outputs.gersemi }}

- name: show changed files
run: |
git status
git diff .pre-commit-config.yaml

- name: try to install pre-commit
run: |
source .venv/bin/activate
pre-commit install
pre-commit install-hooks
pre-commit uninstall

- name: generate GitHub App token
uses: actions/create-github-app-token@v2
id: generate-token
with:
app-id: ${{ secrets.CI_BOT_APP_ID }}
private-key: ${{ secrets.CI_BOT_PRIVATE_KEY }}

- name: create pull request
if: ${{ inputs.create-pr || github.event_name == 'schedule' }}
uses: peter-evans/create-pull-request@v8
with:
commit-message: "Refresh lock and linter dependencies"
branch: "dependencies/refresh-lock-and-linter"
title: "Refresh lock and linter dependencies"
body: "This PR refreshes the lock file and updates linter dependencies to their latest versions."
labels: "dependencies"
signoff: true
sign-commits: true
delete-branch: true
base: ${{ github.head_ref }}
token: ${{ steps.generate-token.outputs.token }}
15 changes: 5 additions & 10 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,13 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"

- name: Install in develop mode
run: |
pip install -e .[dev]
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Test and Coverage
run: |
pytest
uv sync --no-default-groups --group test
uv run pytest
# Fix relative paths in coverage file
# Known bug: https://community.sonarsource.com/t/sonar-on-github-actions-with-python-coverage-source-issue/36057
Expand All @@ -52,4 +47,4 @@ jobs:
uses: SonarSource/sonarqube-scan-action@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
16 changes: 16 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# SPDX-License-Identifier: MPL-2.0

# MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md001.md
MD001: false

# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md013.md
line-length:
line_length: 120
code_blocks: false
tables: false
stern: true

# MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md024.md
MD024: false
21 changes: 14 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# SPDX-License-Identifier: MPL-2.0

repos:
- repo: https://github.com/fsfe/reuse-tool
rev: v5.0.2
- repo: https://github.com/fsfe/reuse-tool # outside pypi
rev: v6.2.0
hooks:
- id: reuse
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.11.12
rev: v0.14.9
hooks:
# Run the linter.
- id: ruff-check
Expand All @@ -19,16 +19,23 @@ repos:
- id: ruff-format
name: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.16.0
rev: v1.19.0
hooks:
- id: mypy
additional_dependencies: [numpy, pandas]
additional_dependencies:
- numpy
- types-pyyaml
- types-requests
- repo: local
hooks:
- id: pytest
name: pytest
entry: pytest
entry: uv run pytest
language: system
pass_filenames: false
always_run: true
args: [ "--cov-fail-under=98" ]
- repo: https://github.com/igorshubovych/markdownlint-cli # outside pypi
rev: v0.47.0
hooks:
- id: markdownlint
args: ["--fix"]
Loading
Loading