2024-02-19 15:21:48 +00:00
|
|
|
# SPDX-FileCopyrightText: : 2021-2024 The PyPSA-Eur Authors
|
2021-06-22 09:01:33 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: CC0-1.0
|
|
|
|
|
|
|
|
name: CI
|
|
|
|
|
2022-01-13 17:25:12 +00:00
|
|
|
# Caching method based on and described by:
|
|
|
|
# epassaro (2021): https://dev.to/epassaro/caching-anaconda-environments-in-github-actions-5hde
|
|
|
|
# and code in GitHub repo: https://github.com/epassaro/cache-conda-envs
|
|
|
|
|
2021-07-09 08:22:40 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
pull_request:
|
2022-06-27 17:00:41 +00:00
|
|
|
branches:
|
|
|
|
- master
|
2021-07-09 08:22:40 +00:00
|
|
|
schedule:
|
|
|
|
- cron: "0 5 * * TUE"
|
2021-06-22 09:01:33 +00:00
|
|
|
|
2022-01-13 17:25:12 +00:00
|
|
|
env:
|
2023-03-08 19:46:00 +00:00
|
|
|
DATA_CACHE_NUMBER: 2
|
2022-01-13 17:25:12 +00:00
|
|
|
|
2021-06-22 09:01:33 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
|
|
|
|
strategy:
|
2023-03-09 10:52:06 +00:00
|
|
|
fail-fast: false
|
2023-07-23 08:24:08 +00:00
|
|
|
max-parallel: 3
|
2021-06-22 09:01:33 +00:00
|
|
|
matrix:
|
2023-07-23 08:25:02 +00:00
|
|
|
os:
|
2023-07-23 08:24:08 +00:00
|
|
|
- ubuntu-latest
|
|
|
|
- macos-latest
|
|
|
|
- windows-latest
|
2024-01-31 08:54:58 +00:00
|
|
|
inhouse:
|
|
|
|
- stable
|
|
|
|
- master
|
|
|
|
exclude:
|
|
|
|
- os: macos-latest
|
|
|
|
inhouse: master
|
|
|
|
- os: windows-latest
|
|
|
|
inhouse: master
|
2022-01-13 17:25:12 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
2022-09-16 13:04:04 +00:00
|
|
|
|
2021-06-22 09:01:33 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash -l {0}
|
2022-09-16 13:04:04 +00:00
|
|
|
|
2021-06-22 09:01:33 +00:00
|
|
|
steps:
|
2023-03-08 19:40:21 +00:00
|
|
|
- uses: actions/checkout@v3
|
2022-09-16 13:04:04 +00:00
|
|
|
|
2022-01-13 17:25:12 +00:00
|
|
|
- name: Setup secrets
|
|
|
|
run: |
|
|
|
|
echo -ne "url: ${CDSAPI_URL}\nkey: ${CDSAPI_TOKEN}\n" > ~/.cdsapirc
|
2022-09-16 13:04:04 +00:00
|
|
|
|
2023-07-23 08:24:08 +00:00
|
|
|
- name: Setup micromamba
|
|
|
|
uses: mamba-org/setup-micromamba@v1
|
2022-01-13 17:25:12 +00:00
|
|
|
with:
|
2023-07-23 08:24:08 +00:00
|
|
|
micromamba-version: latest
|
|
|
|
environment-file: envs/environment.yaml
|
|
|
|
log-level: debug
|
|
|
|
init-shell: bash
|
2023-07-23 08:58:38 +00:00
|
|
|
cache-environment: true
|
2023-07-23 08:24:08 +00:00
|
|
|
cache-downloads: true
|
|
|
|
|
2024-01-31 08:54:58 +00:00
|
|
|
- name: Install inhouse packages
|
|
|
|
run: |
|
|
|
|
pip install git+https://github.com/PyPSA/atlite.git@master git+https://github.com/PyPSA/powerplantmatching.git@master git+https://github.com/PyPSA/linopy.git@master
|
2024-01-31 08:59:31 +00:00
|
|
|
if: ${{ matrix.inhouse }} == 'master'
|
2024-01-31 08:54:58 +00:00
|
|
|
|
2022-04-11 15:08:25 +00:00
|
|
|
- name: Set cache dates
|
|
|
|
run: |
|
|
|
|
echo "WEEK=$(date +'%Y%U')" >> $GITHUB_ENV
|
2023-03-06 08:27:45 +00:00
|
|
|
|
2022-04-11 15:08:25 +00:00
|
|
|
- name: Cache data and cutouts folders
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
data
|
2023-03-06 10:54:08 +00:00
|
|
|
cutouts
|
2022-04-11 15:08:25 +00:00
|
|
|
key: data-cutouts-${{ env.WEEK }}-${{ env.DATA_CACHE_NUMBER }}
|
2022-09-16 13:04:04 +00:00
|
|
|
|
2022-01-13 17:25:12 +00:00
|
|
|
- name: Test snakemake workflow
|
2024-01-31 15:53:14 +00:00
|
|
|
run: ./test.sh
|
2023-03-08 19:06:18 +00:00
|
|
|
|
|
|
|
- name: Upload artifacts
|
2024-01-31 11:23:35 +00:00
|
|
|
uses: actions/upload-artifact@v4.3.0
|
2023-03-08 19:06:18 +00:00
|
|
|
with:
|
|
|
|
name: resources-results
|
|
|
|
path: |
|
|
|
|
resources
|
|
|
|
results
|
|
|
|
if-no-files-found: warn
|
|
|
|
retention-days: 1
|
2024-01-31 11:23:35 +00:00
|
|
|
if: matrix.os == 'ubuntu' && matrix.inhouse == 'stable'
|