Skip to content
Open
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
67 changes: 37 additions & 30 deletions .github/workflows/test-models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ on:
branches:
- master
pull_request:
branches:
- master
branches: ["*"]
schedule:
- cron: "0 5 * * *"

env:
PACKAGE_NAME: "linopy"

# Cancel any in-progress runs when a new run is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -24,13 +26,24 @@ jobs:
matrix:
version:
- master
# - latest # Activate when v0.14.0 is released
# - latest

defaults:
run:
shell: bash -l {0}

steps:
- name: Free up disk space
run: |
echo "Initial disk space"
df -h
echo "Free up disk space"
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
sudo docker builder prune -a --force
echo "Final disk space"
df -h

- uses: actions/checkout@v5
with:
repository: PyPSA/pypsa-eur
Expand All @@ -43,6 +56,18 @@ jobs:
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $latest_tag

- name: Setup Pixi
uses: prefix-dev/setup-pixi@v0.9.3
with:
pixi-version: v0.59.0
cache: true
# Do not cache in branches
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}

- name: Setup cache keys
run: |
echo "WEEK=$(date +'%Y%U')" >> $GITHUB_ENV # data and cutouts

# Only run check if package is not pinned
- name: Check if inhouse package is pinned
run: |
Expand All @@ -53,51 +78,29 @@ jobs:
echo "pinned=false" >> $GITHUB_ENV
fi

- name: Setup secrets & cache dates
if: env.pinned == 'false'
run: |
echo -ne "url: ${CDSAPI_URL}\nkey: ${CDSAPI_TOKEN}\n" > ~/.cdsapirc
echo "week=$(date +'%Y%U')" >> $GITHUB_ENV # data and cutouts

- uses: actions/cache@v4
if: env.pinned == 'false'
with:
path: |
data
cutouts
key: data-cutouts-${{ env.week }}

- uses: conda-incubator/setup-miniconda@v3
if: env.pinned == 'false'
with:
activate-environment: pypsa-eur

- name: Cache Conda env
if: env.pinned == 'false'
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key: conda-pypsa-eur-${{ env.week }}-${{ hashFiles('envs/linux-64.lock.yaml') }}
id: cache-env

- name: Update environment
if: env.pinned == 'false' && steps.cache-env.outputs.cache-hit != 'true'
run: conda env update -n pypsa-eur -f envs/linux-64.lock.yaml
key: data-cutouts-pypsa-eur-${{ env.WEEK }}

- name: Install package from ref
if: env.pinned == 'false'
run: |
python -m pip install git+https://github.com/${{ github.repository }}@${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
pixi remove ${{ env.PACKAGE_NAME }}
pixi add --pypi --git https://github.com/${{ github.repository }}.git ${{ github.event.repository.name }} --rev ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

- name: Run snakemake test workflows
if: env.pinned == 'false'
run: |
make test
pixi run integration-tests

- name: Run unit tests
if: env.pinned == 'false'
run: |
make unit-test
pixi run unit-tests

- name: Upload artifacts
if: env.pinned == 'false'
Expand All @@ -109,3 +112,7 @@ jobs:
.snakemake/log
results
retention-days: 3

- name: Show remaining disk space
if: always()
run: df -h
Loading