forked from PyPSA/PyPSA
-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (183 loc) · 5.49 KB
/
test-models.yml
File metadata and controls
215 lines (183 loc) · 5.49 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Test models
on:
push:
branches:
- master
- release-branch-v*
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:
- 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 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 }}
- uses: conda-incubator/setup-miniconda@v3
if: env.pinned == 'false'
with:
miniforge-version: latest
activate-environment: pypsa-eur
channel-priority: strict
- 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-64.lock.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-64.lock.yaml --quiet
conda list
- 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 }}
conda list
- name: Check pypsa version
run: |
python -c "import pypsa; print(pypsa.__version__)"
- name: Run snakemake test workflows
if: env.pinned == 'false'
run: |
make test
- name: Run unit tests
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
test-pypsa-de:
name: PyPSA-DE
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version:
- master
# - latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v5
with:
repository: PyPSA/pypsa-de
ref: main
- 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 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
resources/ariadne_database.csv
key: data-cutouts-pypsa-de-${{ env.WEEK }}
- uses: conda-incubator/setup-miniconda@v3
if: env.pinned == 'false'
with:
miniforge-version: latest
activate-environment: pypsa-de
channel-priority: strict
- name: Cache Conda env
if: env.pinned == 'false'
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key: conda-pypsa-de-${{ env.WEEK }}-${{ hashFiles('envs/linux-64.lock.yaml') }}
id: cache-env
- name: Update environment
if: env.pinned == 'false' && steps.cache-env.outputs.cache-hit != 'true'
run: |
conda env update -n pypsa-de -f envs/linux-64.lock.yaml
echo "Run conda list" && conda list
- 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-de-${{ matrix.version }}
path: |
logs
.snakemake/log
results
retention-days: 3