@@ -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-
2219jobs :
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
0 commit comments