|
57 | 57 | - name: Install dependencies |
58 | 58 | run: uv pip install --system ".[docs,full]" |
59 | 59 |
|
| 60 | + - name: Get notebook cache key |
| 61 | + id: notebook-cache-key |
| 62 | + run: | |
| 63 | + set -eo pipefail |
| 64 | + # Hash notebooks + flixopt source code using null-delimited find for safety |
| 65 | + 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) |
| 66 | + echo "hash=$HASH" >> $GITHUB_OUTPUT |
| 67 | +
|
| 68 | + - name: Cache executed notebooks |
| 69 | + uses: actions/cache@v4 |
| 70 | + id: notebook-cache |
| 71 | + with: |
| 72 | + path: docs/notebooks/**/*.ipynb |
| 73 | + key: notebooks-${{ steps.notebook-cache-key.outputs.hash }} |
| 74 | + |
| 75 | + - name: Execute notebooks in parallel |
| 76 | + if: steps.notebook-cache.outputs.cache-hit != 'true' |
| 77 | + run: | |
| 78 | + set -eo pipefail |
| 79 | + # Execute all notebooks in parallel (4 at a time) |
| 80 | + # Run from notebooks directory so relative imports work |
| 81 | + cd docs/notebooks && find . -name '*.ipynb' -print0 | \ |
| 82 | + xargs -0 -P 4 -I {} sh -c 'jupyter execute --inplace "$1" || exit 255' _ {} |
| 83 | +
|
60 | 84 | - name: Build docs |
| 85 | + env: |
| 86 | + MKDOCS_JUPYTER_EXECUTE: "false" |
61 | 87 | run: mkdocs build --strict |
62 | 88 |
|
63 | 89 | - uses: actions/upload-artifact@v4 |
@@ -95,12 +121,36 @@ jobs: |
95 | 121 | - name: Install dependencies |
96 | 122 | run: uv pip install --system ".[docs,full]" |
97 | 123 |
|
| 124 | + - name: Get notebook cache key |
| 125 | + id: notebook-cache-key |
| 126 | + run: | |
| 127 | + set -eo pipefail |
| 128 | + # Hash notebooks + flixopt source code using null-delimited find for safety |
| 129 | + 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) |
| 130 | + echo "hash=$HASH" >> $GITHUB_OUTPUT |
| 131 | +
|
| 132 | + - name: Cache executed notebooks |
| 133 | + uses: actions/cache@v4 |
| 134 | + id: notebook-cache |
| 135 | + with: |
| 136 | + path: docs/notebooks/**/*.ipynb |
| 137 | + key: notebooks-${{ steps.notebook-cache-key.outputs.hash }} |
| 138 | + |
| 139 | + - name: Execute notebooks in parallel |
| 140 | + if: steps.notebook-cache.outputs.cache-hit != 'true' |
| 141 | + run: | |
| 142 | + set -eo pipefail |
| 143 | + cd docs/notebooks && find . -name '*.ipynb' -print0 | \ |
| 144 | + xargs -0 -P 4 -I {} sh -c 'jupyter execute --inplace "$1" || exit 255' _ {} |
| 145 | +
|
98 | 146 | - name: Configure Git |
99 | 147 | run: | |
100 | 148 | git config user.name "github-actions[bot]" |
101 | 149 | git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
102 | 150 |
|
103 | 151 | - name: Deploy docs |
| 152 | + env: |
| 153 | + MKDOCS_JUPYTER_EXECUTE: "false" |
104 | 154 | run: | |
105 | 155 | VERSION=${{ inputs.version }} |
106 | 156 | VERSION=${VERSION#v} |
|
0 commit comments