ci: fix model runs #693
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test models | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: ["*"] | |
| schedule: | |
| - cron: "0 5 * * *" | |
| # Cancel any in-progress runs when a new run is triggered | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test-pypsa-eur: | |
| name: PyPSA-Eur | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: | |
| - master | |
| # - 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 | |
| ref: master | |
| - name: Check out latest release | |
| if: matrix.version == 'latest' | |
| run: | | |
| git fetch --tags | |
| 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: | | |
| grep_line=$(grep -- '- pypsa' envs/environment.yaml) | |
| if [[ $grep_line == *"<"* || $grep_line == *"=="* ]]; then | |
| echo "pinned=true" >> $GITHUB_ENV | |
| else | |
| echo "pinned=false" >> $GITHUB_ENV | |
| fi | |
| - uses: actions/cache@v4 | |
| if: env.pinned == 'false' | |
| with: | |
| path: | | |
| data | |
| cutouts | |
| key: data-cutouts-pypsa-eur-${{ env.WEEK }} | |
| - name: Install package from ref | |
| if: env.pinned == 'false' | |
| run: | | |
| pixi remove pypsa | |
| pixi remove linopy | |
| 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 }} | |
| pixi add pypsa | |
| - name: Run snakemake test workflows | |
| if: env.pinned == 'false' | |
| run: | | |
| pixi run integration-tests | |
| - name: Run unit tests | |
| if: env.pinned == 'false' | |
| run: | | |
| pixi run unit-tests | |
| - name: Upload artifacts | |
| if: env.pinned == 'false' | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: results-pypsa-eur-${{ matrix.version }} | |
| path: | | |
| logs | |
| .snakemake/log | |
| results | |
| retention-days: 3 | |
| - name: Show remaining disk space | |
| if: always() | |
| run: df -h |