forked from open-energy-transition/pypsa-eur
-
Notifications
You must be signed in to change notification settings - Fork 19
114 lines (96 loc) · 3.12 KB
/
Copy pathtest.yaml
File metadata and controls
114 lines (96 loc) · 3.12 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
name: Test workflows
on:
push:
branches:
- master
pull_request:
schedule:
- cron: "0 5 * * 1-6"
- cron: "0 5 * * 0"
workflow_dispatch:
# Cancel any in-progress runs when a new run is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
BASE_ENV: envs/environment.yaml
jobs:
run-tests:
name: OS
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
# Run windows only on scheduled runs on Sundays, otherwise ignore
os: ${{ github.event.schedule == '0 5 * * 0' && fromJson('["ubuntu", "macos", "windows"]') || github.ref_name == 'releases/**' && fromJson('["ubuntu", "macos", "windows"]') || fromJson('["ubuntu"]') }}
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- name: Setup env file path (ubuntu)
if: matrix.os == 'ubuntu'
run: |
echo "env_file=envs/linux-64.lock.yaml" >> $GITHUB_ENV
- name: Setup env file path (macos and windows)
if: matrix.os != 'ubuntu'
run: |
if [[ "${{ matrix.os }}" == "macos" ]]; then
echo "env_file=envs/osx-arm64.lock.yaml" >> $GITHUB_ENV
else
echo "env_file=envs/win-64.lock.yaml" >> $GITHUB_ENV
fi
- name: Use base env file if it was changed
run: |
git fetch origin master
if git diff --name-only origin/master | grep '${{ env.BASE_ENV }}'; then
echo "Base env ${{ env.BASE_ENV }} changed. Using it instead of locked envs."
echo "env_file=${{ env.BASE_ENV }}" >> $GITHUB_ENV
else
echo "Base env ${{ env.BASE_ENV }} not changed. Using locked envs."
fi
- name: Setup cache keys
run: |
echo "WEEK=$(date +'%Y%U')" >> $GITHUB_ENV # data and cutouts
- uses: actions/cache@v4
with:
path: |
data
cutouts
key: data-cutouts-${{ env.WEEK }}
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
activate-environment: pypsa-eur
channel-priority: strict
- name: Cache Conda env
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles(format('{0}', env.env_file)) }}
id: cache-env
- name: Update environment
if: steps.cache-env.outputs.cache-hit != 'true'
run: |
conda env update -n pypsa-eur -f ${{ env.env_file }}
echo "Run conda list" && conda list
- name: Run pylint check on scripts
# check for undefined variables to reuse functions across scripts
run: |
pylint --disable=all --enable=E0601,E0606 --output-format=parseable scripts/add_* scripts/prepare_* scripts/solve_*
- name: Run snakemake test workflows
run: |
make test
- name: Run unit tests
run: |
make unit-test
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: results-${{ matrix.os }}
path: |
logs
.snakemake/log
results
retention-days: 3