Skip to content

Commit c894c31

Browse files
committed
Merge remote-tracking branch 'upstream/master' into merge-upstream-26-01-05
2 parents 4e2e4e3 + 73fb005 commit c894c31

File tree

127 files changed

+35597
-5841
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+35597
-5841
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-FileCopyrightText: Contributors to PyPSA-Eur <https://github.com/pypsa/pypsa-eur>
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
*
6+
!pixi.*

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44

55
*.h5 filter=lfs diff=lfs merge=lfs -text
66
*.zip filter=lfs diff=lfs merge=lfs -text
7+
# SCM syntax highlighting & preventing 3-way merges
8+
pixi.lock merge=binary linguist-language=YAML linguist-generated=true

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ body:
5858
attributes:
5959
label: Installed Versions
6060
description: >
61-
Please share information on your environment. Paste the output below. For conda ``conda env export`` and for pip ``pip freeze``.
61+
Please share information on your environment. Paste the output below. For conda ``conda env export`` and for pixi, the content of ``pixi.lock``.
6262
value: >
6363
<details>
6464

.github/workflows/release.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*.*.*
7+
8+
env:
9+
PREPARATION_COMMIT: '[github-actions.ci] prepare release ${{ github.ref_name }}'
10+
BASE_ENV: envs/environment.yaml
11+
12+
jobs:
13+
check-preparation:
14+
name: Check if release is prepared
15+
runs-on: ubuntu-latest
16+
outputs:
17+
prepared: ${{ steps.validate.outputs.prepared }}
18+
steps:
19+
- uses: actions/checkout@v6
20+
21+
- name: Validate commit message
22+
id: validate
23+
run: |
24+
# Check if last commit is the expected commit message
25+
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
26+
echo "Expected: '${{ env.PREPARATION_COMMIT }}'"
27+
echo "Received: '$COMMIT_MESSAGE'"
28+
29+
prepared="false"
30+
if [[ "$COMMIT_MESSAGE" == "${{ env.PREPARATION_COMMIT }}" ]]; then
31+
prepared="true"
32+
fi
33+
34+
echo "prepared=$prepared" >> $GITHUB_OUTPUT
35+
36+
prepare-release:
37+
name: Prepare release
38+
needs: [check-preparation]
39+
if: ${{ needs.check-preparation.outputs.prepared == 'false' }}
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Generate token for PyPSA Bot
43+
id: generate-token
44+
uses: actions/create-github-app-token@v2
45+
with:
46+
app-id: ${{ vars.PYPSA_BOT_ID }}
47+
private-key: ${{ secrets.PYPSA_BOT_PRIVATE_KEY }}
48+
49+
- uses: actions/checkout@v6
50+
with:
51+
fetch-depth: 0
52+
53+
- name: Find the branch for commit/ tag
54+
run: |
55+
branch=$(git branch -r --contains ${{ github.sha }} | grep -v 'HEAD' | head -n 1 | sed 's|origin/||' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
56+
echo "Branch found: $branch"
57+
echo "BRANCH_NAME=$branch" >> $GITHUB_ENV
58+
59+
- uses: actions/checkout@v6
60+
with:
61+
fetch-depth: 0
62+
ref: ${{ env.BRANCH_NAME }}
63+
token: ${{ steps.generate-token.outputs.token }}
64+
65+
- name: Setup Pixi
66+
uses: prefix-dev/setup-pixi@v0.9.3
67+
with:
68+
pixi-version: v0.59.0
69+
cache: true
70+
# Do not cache in branches
71+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
72+
73+
# Start of preparation script
74+
75+
- name: Update DAGs in documentation
76+
run: |
77+
pixi run update-dags
78+
79+
# End of preparation script
80+
81+
- name: Remove previous tag
82+
run: |
83+
git tag -d ${{ github.ref_name }}
84+
git push origin --delete ${{ github.ref_name }}
85+
86+
- name: Commit changes
87+
uses: stefanzweifel/git-auto-commit-action@v7
88+
with:
89+
branch: ${{ env.BRANCH_NAME }}
90+
commit_message: '${{ env.PREPARATION_COMMIT }}'
91+
tagging_message: '${{ github.ref_name }}' # add tag again
92+
push_options: '${{ github.ref_name }}'
93+
add_options: '-u' # Never add untracked files

.github/workflows/test.yaml

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ concurrency:
1616
group: ${{ github.workflow }}-${{ github.ref }}
1717
cancel-in-progress: true
1818

19-
env:
20-
BASE_ENV: envs/environment.yaml
21-
2219
jobs:
2320
run-tests:
2421
name: OS
@@ -36,67 +33,75 @@ jobs:
3633
steps:
3734
- uses: actions/checkout@v6
3835

39-
- name: Setup env file path (ubuntu)
40-
if: matrix.os == 'ubuntu'
41-
run: |
42-
echo "env_file=envs/linux-64.lock.yaml" >> $GITHUB_ENV
43-
44-
- name: Setup env file path (macos and windows)
45-
if: matrix.os != 'ubuntu'
46-
run: |
47-
if [[ "${{ matrix.os }}" == "macos" ]]; then
48-
echo "env_file=envs/osx-arm64.lock.yaml" >> $GITHUB_ENV
49-
else
50-
echo "env_file=envs/win-64.lock.yaml" >> $GITHUB_ENV
51-
fi
52-
53-
- name: Use base env file if it was changed
36+
- uses: dorny/paths-filter@v3
37+
id: filter
38+
with:
39+
filters: |
40+
src:
41+
- 'scripts/**'
42+
- 'rules/**'
43+
- 'data/**'
44+
- 'Snakefile'
45+
- 'config/**'
46+
- 'test/**'
47+
- 'pixi.toml'
48+
- 'pixi.lock'
49+
- '.github/workflows/test.yaml'
50+
51+
- name: Free up disk space
5452
run: |
55-
git fetch origin ${{ github.event.repository.default_branch }}
56-
if git diff --name-only origin/${{ github.event.repository.default_branch }} | grep '${{ env.BASE_ENV }}'; then
57-
echo "Base env ${{ env.BASE_ENV }} changed. Using it instead of locked envs."
58-
echo "env_file=${{ env.BASE_ENV }}" >> $GITHUB_ENV
59-
else
60-
echo "Base env ${{ env.BASE_ENV }} not changed. Using locked envs."
61-
fi
53+
echo "Initial disk space"
54+
df -h
55+
echo "Free up disk space"
56+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
57+
sudo docker image prune --all --force
58+
sudo docker builder prune -a --force
59+
echo "Final disk space"
60+
df -h
61+
- name: Skip - no source changes
62+
if: steps.filter.outputs.src != 'true' && github.event_name != 'schedule'
63+
run: echo "Skipping tests because no source code changes detected"
64+
65+
- name: Setup Pixi
66+
if: steps.filter.outputs.src == 'true' || github.event_name == 'schedule'
67+
uses: prefix-dev/setup-pixi@v0.9.3
68+
with:
69+
pixi-version: v0.59.0
70+
cache: true
71+
# Do not cache in branches
72+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
6273

6374
- name: Setup cache keys
75+
if: steps.filter.outputs.src == 'true' || github.event_name == 'schedule'
6476
run: |
6577
echo "WEEK=$(date +'%Y%U')" >> $GITHUB_ENV # data and cutouts
6678
6779
- uses: actions/cache@v5
80+
if: steps.filter.outputs.src == 'true' || github.event_name == 'schedule'
6881
with:
6982
path: |
7083
data
7184
cutouts
7285
key: data-cutouts-${{ env.WEEK }}
7386

74-
- uses: conda-incubator/setup-miniconda@v3
75-
with:
76-
miniforge-version: latest
77-
activate-environment: pypsa-de
78-
channel-priority: strict
79-
80-
- name: Cache Conda env
81-
uses: actions/cache@v5
82-
with:
83-
path: ${{ env.CONDA }}/envs
84-
key: conda-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles(format('{0}', env.env_file)) }}
85-
id: cache-env
86-
87-
- name: Update environment
88-
if: steps.cache-env.outputs.cache-hit != 'true'
87+
- name: Run pylint check on scripts
88+
if: steps.filter.outputs.src == 'true' || github.event_name == 'schedule'
89+
# check for undefined variables to reuse functions across scripts
8990
run: |
90-
conda env update -n pypsa-de -f ${{ env.env_file }}
91-
echo "Run conda list" && conda list
91+
pixi run pylint --disable=all --enable=E0601,E0606 --output-format=parseable scripts/add_* scripts/prepare_* scripts/solve_*
9292
9393
- name: Run snakemake test workflows
94+
if: steps.filter.outputs.src == 'true' || github.event_name == 'schedule'
95+
env:
96+
SNAKEMAKE_STORAGE_CACHED_HTTP_CACHE: ""
97+
SNAKEMAKE_STORAGE_CACHED_HTTP_SKIP_REMOTE_CHECKS: "1"
9498
run: |
95-
make test
99+
pixi run integration-tests
96100
97101
- name: Run unit tests
102+
if: steps.filter.outputs.src == 'true' || github.event_name == 'schedule'
98103
run: |
99-
make unit-test
104+
pixi run unit-tests
100105
101106
- name: Upload artifacts
102107
if: always()
@@ -108,3 +113,7 @@ jobs:
108113
.snakemake/log
109114
results
110115
retention-days: 3
116+
117+
- name: Show remaining disk space
118+
if: always()
119+
run: df -h
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Update locked envs
2+
on:
3+
push:
4+
paths:
5+
- pixi.toml
6+
schedule:
7+
- cron: "0 8 1,16 * *" # Bi-weekly
8+
workflow_dispatch:
9+
10+
jobs:
11+
update-locked-environment:
12+
if: ${{ github.ref == 'refs/heads/master' }}
13+
name: Update lockfiles
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
shell: bash -l {0}
18+
steps:
19+
- uses: actions/checkout@v6
20+
21+
- name: Setup Pixi
22+
uses: prefix-dev/setup-pixi@v0.9.3
23+
with:
24+
pixi-version: v0.59.0
25+
26+
- name: Update lockfile
27+
run: |
28+
rm pixi.lock
29+
pixi install --all
30+
31+
- name: Create new conda lock files
32+
run: |
33+
pixi workspace export conda-explicit-spec -e default envs
34+
for f in envs/*_conda_spec*; do mv "$f" "${f/_conda_spec/.pin}"; done
35+
36+
- name: Create new conda environment file
37+
run: |
38+
pixi workspace export conda-environment -e default envs/environment.yaml -n pypsa-eur
39+
40+
- name: Upload artifacts
41+
uses: actions/upload-artifact@v6
42+
with:
43+
name: lockfiles
44+
path: |
45+
pixi.lock
46+
envs/
47+
48+
create-pull-request:
49+
needs: update-locked-environment
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v6
53+
- name: Download all artifacts
54+
uses: actions/download-artifact@v7
55+
with:
56+
name: lockfiles
57+
58+
- name: Create Pull Request
59+
uses: peter-evans/create-pull-request@v8
60+
with:
61+
token: ${{ secrets.GITHUB_TOKEN }}
62+
branch: update-locked-environment
63+
title: "[github-actions.ci] Update locked envs"
64+
body: |
65+
Automatically generated PR to update the pixi lockfile.
66+
67+
**Note: Do not merge without manual test execution. Either update the branch to trigger tests, or use `workflow_dispatch` to run tests manually. Unlike standard PRs, tests will not run automatically.**
68+
commit-message: "Update locked environment files for all platforms"

0 commit comments

Comments
 (0)