Skip to content

Commit

Permalink
Create main.yml
Browse files Browse the repository at this point in the history
Setting up CI based on pypsa-eurs actions
  • Loading branch information
ktehranchi authored Mar 2, 2024
1 parent 02afa3c commit 9777d41
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# SPDX-FileCopyrightText: : 2021-2024 The PyPSA-Eur Authors
#
# SPDX-License-Identifier: CC0-1.0

name: CI

# 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

on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: "0 5 * * TUE"

env:
DATA_CACHE_NUMBER: 2

jobs:
build:

strategy:
fail-fast: false
max-parallel: 3
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
inhouse:
- stable
- master
exclude:
- os: macos-latest
inhouse: master
- os: windows-latest
inhouse: master
runs-on: ${{ matrix.os }}

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

steps:
- uses: actions/checkout@v3

- name: Setup secrets
run: |
echo -ne "url: ${CDSAPI_URL}\nkey: ${CDSAPI_TOKEN}\n" > ~/.cdsapirc
- name: Setup micromamba
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: latest
environment-file: envs/environment.yaml
log-level: debug
init-shell: bash
cache-environment: true
cache-downloads: true

- 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
if: ${{ matrix.inhouse }} == 'master'

- name: Set cache dates
run: |
echo "WEEK=$(date +'%Y%U')" >> $GITHUB_ENV
- name: Cache data and cutouts folders
uses: actions/cache@v3
with:
path: |
data
cutouts
key: data-cutouts-${{ env.WEEK }}-${{ env.DATA_CACHE_NUMBER }}

- name: Test snakemake workflow
run: ./test.sh

- name: Upload artifacts
uses: actions/[email protected]
with:
name: resources-results
path: |
resources
results
if-no-files-found: warn
retention-days: 1
if: matrix.os == 'ubuntu' && matrix.inhouse == 'stable'

0 comments on commit 9777d41

Please sign in to comment.