-
Notifications
You must be signed in to change notification settings - Fork 53
111 lines (95 loc) · 2.85 KB
/
test-models.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Test models
on:
push:
branches:
- master
pull_request:
branches:
- master
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 # Activate when v0.14.0 is released
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
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
# 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
- 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-pinned.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-pinned.yaml
- 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 }}
- name: Run snakemake test workflows
if: env.pinned == 'false'
run: |
make test
- name: Run unit tests
if: env.pinned == 'false'
run: |
make unit-test
- name: Upload artifacts
if: env.pinned == 'false'
uses: actions/upload-artifact@v4
with:
name: results-pypsa-eur-${{ matrix.version }}
path: |
logs
.snakemake/log
results
retention-days: 3