Skip to content

Commit 00023e2

Browse files
authored
add pypsa-eur model tests (#405)
1 parent 53d68fc commit 00023e2

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

.github/workflows/test-models.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Test models
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
schedule:
11+
- cron: "0 5 * * *"
12+
13+
# Cancel any in-progress runs when a new run is triggered
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
test-pypsa-eur:
20+
name: PyPSA-Eur
21+
runs-on: ubuntu-latest
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
version:
26+
- master
27+
# - latest # Activate when v0.14.0 is released
28+
29+
defaults:
30+
run:
31+
shell: bash -l {0}
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
with:
36+
repository: PyPSA/pypsa-eur
37+
ref: master
38+
39+
- name: Check out latest release
40+
if: matrix.version == 'latest'
41+
run: |
42+
git fetch --tags
43+
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
44+
git checkout $latest_tag
45+
46+
# Only run check if package is not pinned
47+
- name: Check if inhouse package is pinned
48+
run: |
49+
grep_line=$(grep -- '- pypsa' envs/environment.yaml)
50+
if [[ $grep_line == *"<"* || $grep_line == *"=="* ]]; then
51+
echo "pinned=true" >> $GITHUB_ENV
52+
else
53+
echo "pinned=false" >> $GITHUB_ENV
54+
fi
55+
56+
- name: Setup secrets & cache dates
57+
if: env.pinned == 'false'
58+
run: |
59+
echo -ne "url: ${CDSAPI_URL}\nkey: ${CDSAPI_TOKEN}\n" > ~/.cdsapirc
60+
echo "week=$(date +'%Y%U')" >> $GITHUB_ENV # data and cutouts
61+
62+
- uses: actions/cache@v4
63+
if: env.pinned == 'false'
64+
with:
65+
path: |
66+
data
67+
cutouts
68+
key: data-cutouts-${{ env.week }}
69+
70+
- uses: conda-incubator/setup-miniconda@v3
71+
if: env.pinned == 'false'
72+
with:
73+
activate-environment: pypsa-eur
74+
75+
- name: Cache Conda env
76+
if: env.pinned == 'false'
77+
uses: actions/cache@v4
78+
with:
79+
path: ${{ env.CONDA }}/envs
80+
key: conda-pypsa-eur-${{ env.week }}-${{ hashFiles('envs/linux-pinned.yaml') }}
81+
id: cache-env
82+
83+
- name: Update environment
84+
if: env.pinned == 'false' && steps.cache-env.outputs.cache-hit != 'true'
85+
run: conda env update -n pypsa-eur -f envs/linux-pinned.yaml
86+
87+
- name: Install package from ref
88+
if: env.pinned == 'false'
89+
run: |
90+
python -m pip install git+https://github.com/${{ github.repository }}@${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
91+
92+
- name: Run snakemake test workflows
93+
if: env.pinned == 'false'
94+
run: |
95+
make test
96+
97+
- name: Run unit tests
98+
if: env.pinned == 'false'
99+
run: |
100+
make unit-test
101+
102+
- name: Upload artifacts
103+
if: env.pinned == 'false'
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: results-pypsa-eur-${{ matrix.version }}
107+
path: |
108+
logs
109+
.snakemake/log
110+
results
111+
retention-days: 3

0 commit comments

Comments
 (0)