Skip to content

Feature/element data classes #361

Feature/element data classes

Feature/element data classes #361

Workflow file for this run

name: Docs
on:
push:
branches: [main]
paths:
- 'docs/**'
- 'mkdocs.yml'
- 'flixopt/**'
pull_request:
paths:
- 'docs/**'
- 'mkdocs.yml'
workflow_dispatch:
inputs:
deploy:
description: 'Deploy docs to GitHub Pages'
type: boolean
default: false
version:
description: 'Version to deploy (e.g., v6.0.0)'
type: string
required: false
workflow_call:
inputs:
deploy:
type: boolean
default: false
version:
type: string
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.11"
MPLBACKEND: Agg
PLOTLY_RENDERER: notebook_connected
jobs:
build:
name: Build documentation
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v7
with:
version: "0.9.10"
enable-cache: true
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Extract changelog
run: |
cp CHANGELOG.md docs/changelog.md
python scripts/format_changelog.py
- name: Install dependencies
run: uv pip install --system ".[docs,full]"
- name: Get notebook cache key
id: notebook-cache-key
run: |
set -eo pipefail
# Hash notebooks + flixopt source code using null-delimited find for safety
HASH=$({ find docs/notebooks -name '*.ipynb' -print0; find flixopt -name '*.py' -print0; } | sort -z | xargs -0 tar -cf - 2>/dev/null | sha256sum | cut -d' ' -f1)
echo "hash=$HASH" >> $GITHUB_OUTPUT
- name: Cache executed notebooks
uses: actions/cache@v4
id: notebook-cache
with:
path: docs/notebooks/**/*.ipynb
key: notebooks-${{ steps.notebook-cache-key.outputs.hash }}
- name: Execute fast notebooks
if: steps.notebook-cache.outputs.cache-hit != 'true'
run: |
set -eo pipefail
# Execute fast notebooks in parallel (4 at a time), excluding slow ones
cd docs/notebooks && find . -name '*.ipynb' | \
grep -vFf slow_notebooks.txt | \
xargs -P 4 -I {} sh -c 'jupyter execute --inplace "$1" || exit 255' _ {}
- name: Build docs
env:
MKDOCS_JUPYTER_EXECUTE: "false"
run: mkdocs build --strict
- uses: actions/upload-artifact@v4
with:
name: docs
path: site/
retention-days: 7
deploy:
name: Deploy documentation
needs: build
if: ${{ inputs.deploy == true && inputs.version != '' }}
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v7
with:
version: "0.9.10"
enable-cache: true
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Extract changelog
run: |
cp CHANGELOG.md docs/changelog.md
python scripts/format_changelog.py
- name: Install dependencies
run: uv pip install --system ".[docs,full]"
- name: Get notebook cache key
id: notebook-cache-key
run: |
set -eo pipefail
# Hash notebooks + flixopt source code using null-delimited find for safety
HASH=$({ find docs/notebooks -name '*.ipynb' -print0; find flixopt -name '*.py' -print0; } | sort -z | xargs -0 tar -cf - 2>/dev/null | sha256sum | cut -d' ' -f1)
echo "hash=$HASH" >> $GITHUB_OUTPUT
- name: Cache executed notebooks
uses: actions/cache@v4
id: notebook-cache
with:
path: docs/notebooks/**/*.ipynb
key: notebooks-${{ steps.notebook-cache-key.outputs.hash }}
- name: Execute fast notebooks
if: steps.notebook-cache.outputs.cache-hit != 'true'
run: |
set -eo pipefail
# Execute fast notebooks in parallel (4 at a time), excluding slow ones
cd docs/notebooks && find . -name '*.ipynb' | \
grep -vFf slow_notebooks.txt | \
xargs -P 4 -I {} sh -c 'jupyter execute --inplace "$1" || exit 255' _ {}
- name: Execute slow notebooks
if: steps.notebook-cache.outputs.cache-hit != 'true'
run: |
set -eo pipefail
# Execute slow notebooks (only on release)
cd docs/notebooks && cat slow_notebooks.txt | \
xargs -I {} sh -c 'jupyter execute --inplace "$1" || exit 255' _ {}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Deploy docs
env:
MKDOCS_JUPYTER_EXECUTE: "false"
run: |
VERSION=${{ inputs.version }}
VERSION=${VERSION#v}
# Check if this is a pre-release (alpha, beta, rc)
if [[ "$VERSION" =~ (alpha|beta|rc) ]]; then
# Pre-release: deploy version only, don't update "latest"
mike deploy --push $VERSION
else
# Stable release: deploy and update "latest" alias
mike deploy --push --update-aliases $VERSION latest
mike set-default --push latest
fi