-
Notifications
You must be signed in to change notification settings - Fork 42
146 lines (130 loc) · 4.93 KB
/
run_mdk.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
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
# ==============================================================================
# Workflow description:
# Runs the command line interface of OasisLMF package on the PiWind model.
# Multiple versions of python are tested and be extending via
# the `py-version` test matrix.
#
# Loss results are not checked and the workflow should only fail on:
# 1. Package installation failure when pip installing 'oasislmf'
# 2. An invocation error or python exception when executing 'oasislmf model run ..'
# 3. Empty files are produced (either input files / or results)
# ==============================================================================
name: PiWind MDK
on:
push:
branches:
- main
- stable**
pull_request:
branches:
- main
- stable**
workflow_dispatch:
inputs:
mdk_branch:
description: 'Branch to test from Oasislmf repo - https://github.com/OasisLMF/OasisLMF'
required: true
mdk_run_type:
description: 'Loss modes to test, options are one of "[gul, il, ri]"'
required: true
ods_branch:
description: 'Build ods_tools package before test [git ref]'
required: false
piwind_branch:
description: 'Branch of PiWind to test (Only needed for remote triggers)'
required: true
workflow_call:
inputs:
mdk_branch:
description: 'Branch to test from Oasislmf repo - https://github.com/OasisLMF/OasisLMF'
required: true
type: string
mdk_run_type:
description: 'Loss modes to test, options are one of "[gul, il, ri]"'
required: true
type: string
ods_branch:
description: 'Build ods_tools package before test [git ref]'
required: false
type: string
piwind_branch:
description: 'Branch of PiWind to test (Only needed for remote triggers)'
required: true
type: string
env:
SCRIPT_BRANCH: 'main'
PIWIND_BRANCH: ${{ github.ref }}
MDK_BRANCH: 'main'
MDK_RUN: 'ri'
jobs:
ods_tools:
if: inputs.ods_branch != ''
uses: OasisLMF/ODS_Tools/.github/workflows/build.yml@main
secrets: inherit
with:
ods_branch: ${{ inputs.ods_branch }}
run_mdk:
if: ${{ ! failure() || ! cancelled() }}
runs-on: ubuntu-latest
needs: ods_tools
strategy:
matrix:
py-version: ["3.8", "3.9", "3.10"]
steps:
- name: Github context
run: echo "$GITHUB_CONTEXT"
shell: bash
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Set inputs
run: |
[[ -z "${{ inputs.piwind_branch }}" ]] || echo "PIWIND_BRANCH=${{ inputs.piwind_branch }}" >> $GITHUB_ENV
[[ -z "${{ inputs.piwind_branch }}" ]] || echo "SCRIPT_BRANCH=${{ inputs.piwind_branch }}" >> $GITHUB_ENV
[[ -z "${{ inputs.mdk_branch }}" ]] || echo "MDK_BRANCH=${{ inputs.mdk_branch }}" >> $GITHUB_ENV
[[ -z "${{ inputs.mdk_run_type }}" ]] || echo "MDK_RUN=${{ inputs.mdk_run_type }}" >> $GITHUB_ENV
- name: Update Params (Push)
if: github.event_name == 'push'
run: |
echo "MDK_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
echo "PIWIND_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
echo "SCRIPT_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Update Params (Pull Request)
if: github.event_name == 'pull_request'
run: |
# Check if PR is from OasisPiWind / OasisLMF and set other target
if [[ -z "${{ inputs.piwind_branch }}" ]]; then
# Pull Request from PiWind (Set MDK)
echo "MDK_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV
echo "SCRIPT_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
else
# Pull Request from OasisLMF (Set piwind)
echo "PIWIND_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV
fi
- name: Fetch CLI test script
run: |
BASE_URL="https://raw.githubusercontent.com/OasisLMF/OasisPiWind/${{ env.SCRIPT_BRANCH }}/tests"
wget $BASE_URL/run_mdk.py
chmod +x run_mdk.py
- name: Setup Python ${{ matrix.py-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py-version }}
- name: download ods_tools
if: needs.ods_tools.outputs.whl_filename != ''
uses: actions/download-artifact@v3
with:
name: bin_package
path: ${{ github.workspace }}/
- name: install ods_tools
if: needs.ods_tools.outputs.whl_filename != ''
run: |
pip uninstall ods_tools -y
pip install ${{ needs.ods_tools.outputs.whl_filename }}
- name: install wheel
run: |
pip install wheel
- name: run MDK
run: |
./run_mdk.py --model-repo-branch ${{ env.PIWIND_BRANCH}} \
--mdk-repo-branch ${{ env.MDK_BRANCH }} \
--model-run-mode ${{ env.MDK_RUN }}