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
65 changes: 38 additions & 27 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ on:
description: Create a (pre-)release when CI passes
default: false
required: false
update_dependencies:
type: boolean
description: Update dependencies to their latest version
default: false
required: false
outputs:
tag:
description: "The created release tag"
Expand All @@ -31,33 +36,37 @@ jobs:
steps:

- name: Checkout source code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup Python 3.13
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
if: ${{ always() }}
with:
python-version: "3.13"
activate-environment: true
enable-cache: true

- name: Install dependencies
if: ${{ always() }}
run: uv sync --frozen

- name: Set PyPI version
uses: PowerGridModel/pgm-version-bump@main
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: |
cat PYPI_VERSION
pip install build
python -m build --outdir wheelhouse .

- name: Save version
id: version
run: echo "version=$(cat PYPI_VERSION)" >> $GITHUB_OUTPUT

- name: Build
run: |
uv build

- name: Store built wheel file
uses: actions/upload-artifact@v4
with:
name: power-grid-model-ds
path: wheelhouse/
path: dist/

tests:
needs: build-python
Expand All @@ -70,26 +79,33 @@ jobs:

steps:
- name: Checkout source code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
if: ${{ always() }}
with:
python-version: ${{ matrix.python }}
activate-environment: true
enable-cache: true

- name: install poe
run: uv tool install poethepoet

- name: Load built wheel file
uses: actions/download-artifact@v4
with:
name: power-grid-model-ds
path: wheelhouse/
path: dist/

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

- name: Unit test and coverage
run: pytest --verbose
- name: Run All Code Quality Checks & Tests
run: poe all --check


github-release:
if: ${{ inputs.create_release == 'true' }}
needs:
- build-python
- tests
Expand All @@ -99,19 +115,14 @@ jobs:
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- name: Setup Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Checkout source code
uses: actions/checkout@v4 # needed by 'Prevent automatic major/minor release'
uses: actions/checkout@v5

- name: Load built wheel file
uses: actions/download-artifact@v4
with:
name: power-grid-model-ds
path: wheelhouse/
path: dist/

- name: Prevent automatic major/minor release
if: (github.event_name == 'push')
Expand Down Expand Up @@ -143,7 +154,7 @@ jobs:
uses: softprops/action-gh-release@v2
with:
files: |
./wheelhouse/*
./dist/*
tag_name: ${{ steps.tag.outputs.tag }}
prerelease: ${{github.ref != 'refs/heads/main'}}
generate_release_notes: true
Expand Down
56 changes: 45 additions & 11 deletions .github/workflows/check-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ name: Check Code Quality
on:
# run pipeline from another workflow
workflow_call:
inputs:
update_dependencies:
type: boolean
description: Update dependencies to their latest version
default: false
required: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-code-quality
Expand All @@ -18,19 +24,47 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout source code
uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
if: ${{ always() }}
with:
python-version: 3.11
activate-environment: true
enable-cache: true

- name: Upgrade pip
run: pip install --upgrade pip
- name: install poe
if: ${{ always() }}
run: uv tool install poethepoet

- name: Install dependencies
run: pip install -e .[dev]

- name: Run pre-commit on all files
run: pre-commit run --all-files
if: ${{ always() }}
run: uv sync --frozen --dev

- name: Update dependencies
if: ${{ inputs.update_dependencies && always() }}
run: uv sync --upgrade --dev

- name: lint
if: ${{ always() }}
run: poe lint --check
- name: format
if: ${{ always() }}
run: poe format --check
- name: lock
if: ${{ always() }}
run: poe lock
- name: type
if: ${{ always() }}
run: poe type
- name: cover
if: ${{ always() }}
run: poe cover
- name: report
if: ${{ always() }}
run: poe report

- name: Actually stop now if any quality control failed
if: ${{ failure() }}
run: exit 1
3 changes: 0 additions & 3 deletions .github/workflows/citations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,5 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install R
run: |
sudo apt-get update && sudo apt-get install -y r-base
- name: Validate CITATION.cff
uses: dieghernan/cff-validator@v4
12 changes: 2 additions & 10 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ concurrency:
cancel-in-progress: true

jobs:
build-test-release:
uses: "./.github/workflows/build-test-release.yml"
permissions:
contents: write
with:
create_release: false

check-code-quality:
uses: "./.github/workflows/check-code-quality.yml"

reuse-compliance:
uses: "./.github/workflows/reuse-compliance.yml"
with:
update_dependencies: true
2 changes: 1 addition & 1 deletion .github/workflows/reuse-compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v5
26 changes: 14 additions & 12 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,26 @@ jobs:
steps:

- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
uses: actions/checkout@v5

- name: Setup Python 3.11
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
if: ${{ always() }}
with:
python-version: "3.11"
activate-environment: true
enable-cache: true

- name: Install in develop mode
run: |
pip install -e .[dev]
- name: install poe
run: uv tool install poethepoet

- name: Install dependencies
if: ${{ always() }}
run: uv sync --frozen --dev

- name: Test and Coverage
run: |
coverage run -m pytest
coverage xml
coverage report --fail-under=80
poe coverage
uv run coverage xml

- name: SonarCloud Scan
if: ${{ (github.event_name == 'push') || (github.event.pull_request.head.repo.owner.login == 'PowerGridModel') }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ settings.json
# overage
htmlcov
.coverage
coverage.xml

# caching
*.pickle
Expand Down
36 changes: 5 additions & 31 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,12 @@
# SPDX-License-Identifier: MPL-2.0

repos:
- repo: https://github.com/fsfe/reuse-tool
rev: v4.0.3
hooks:
- id: reuse
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.2
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies: [numpy, pandas]
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
files: ^src/.+\.py$
language: system
types: [ python ]
args: [ "--rcfile=pyproject.toml" ]
require_serial: true
- id: pytest
name: pytest
entry: pytest
- id: quality-checks
name: Running 'poe all --check'
entry: poe all --check
language: system
pass_filenames: false
types: [python]
always_run: true
args: []
pass_filenames: false
10 changes: 8 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ build:
tools:
python: "3.11"
jobs:
pre_create_environment:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
create_environment:
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
install:
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group doc
post_install:
# Build package with doc requirements from pyproject.optional-dependencies
- pip install --verbose --editable .[doc]
# download support
- wget -P docs/release_and_support https://github.com/PowerGridModel/.github/raw/main/RELEASE.md
- wget -P docs/release_and_support https://github.com/PowerGridModel/.github/raw/main/SUPPORT.md
Expand Down
Loading
Loading