-
Notifications
You must be signed in to change notification settings - Fork 25
219 lines (187 loc) · 8.74 KB
/
export_standards_data.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
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
216
217
218
name: Export OpenStudio Standards Data
on:
workflow_dispatch:
inputs:
os_installer_link:
description: 'The Link where to download the LINUX OpenStudio SDK Installer (.DEB), otherwise defaults to the one specified in FindOpenStudioSDK.cmake'
required: false
branch_name:
description: 'The branch name to use and where to commit the test results. If ommited, check out develop, and commit results to a branch named like the installer SHA'
required: false
jobs:
export-os-standards:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.8.x'
- name: Extract OS SDK version from FindOpenStudioSDK.cmake
shell: python
run: |
import re
import os
import urllib.parse as ul
with open('FindOpenStudioSDK.cmake', 'r') as f:
content = f.read()
no_comments_lines = []
for line in content.splitlines():
l = line.strip().split('#')[0]
if l:
no_comments_lines.append(l)
content = "\n".join(no_comments_lines)
m_major = re.search(r'set\(OPENSTUDIO_VERSION_MAJOR (\d+)\)', content)
m_minor = re.search(r'set\(OPENSTUDIO_VERSION_MINOR (\d+)\)', content)
m_patch = re.search(r'set\(OPENSTUDIO_VERSION_PATCH (\d+)\)', content)
m_sha = re.search(r'set\(OPENSTUDIO_VERSION_SHA "(.*?)"\)', content)
sdk_version = ''
if m_major:
OS_SDK_VERSION_MAJOR = m_major.groups()[0]
sdk_version += OS_SDK_VERSION_MAJOR
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f"\nOS_SDK_VERSION_MAJOR={OS_SDK_VERSION_MAJOR}")
print(f"\n{OS_SDK_VERSION_MAJOR=}")
else:
print("Unable to find OPENSTUDIO_VERSION_MAJOR")
sdk_version += 'X'
sdk_version += '.'
if m_minor:
OS_SDK_VERSION_MINOR = m_minor.groups()[0]
sdk_version += OS_SDK_VERSION_MINOR
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f"\nOS_SDK_VERSION_MINOR={OS_SDK_VERSION_MINOR}")
print(f"\n{OS_SDK_VERSION_MINOR=}")
else:
print("Unable to find OPENSTUDIO_VERSION_MINOR")
sdk_version += 'Y'
sdk_version += '.'
if m_patch:
OS_SDK_VERSION_PATCH = m_patch.groups()[0]
sdk_version += OS_SDK_VERSION_PATCH
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f"\nOS_SDK_VERSION_PATCH={OS_SDK_VERSION_PATCH}")
print(f"\n{OS_SDK_VERSION_PATCH=}")
else:
print("Unable to find OPENSTUDIO_VERSION_PATCH")
sdk_version += 'Z'
if m_sha:
OS_SDK_VERSION_SHA = m_sha.groups()[0]
# NOT ADDING IT to sdk_version
# sdk_version += OS_SDK_VERSION_SHA
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f"\nOS_SDK_VERSION_SHA={OS_SDK_VERSION_SHA}")
print(f"{OS_SDK_VERSION_SHA=}")
else:
print("Unable to find OPENSTUDIO_VERSION_SHA")
OS_SDK_VERSION = sdk_version
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f"\nOS_SDK_VERSION={OS_SDK_VERSION}")
print(f"{OS_SDK_VERSION=}")
with open('sdk_version.txt', 'a') as f:
f.write(sdk_version)
m_baselink = re.search(r'set\(OPENSTUDIO_BASELINK_RELEASE "(http.*?)"', content)
if m_baselink:
OS_SDK_BASELINK = m_baselink.groups()[0].replace('${OPENSTUDIO_VERSION}', sdk_version)
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f"\nOS_SDK_BASELINK={OS_SDK_BASELINK}")
print(f"Found baselink '{OS_SDK_BASELINK=}'")
else:
print("Unable to find OPENSTUDIO_BASELINK_RELEASE")
OS_SDK_BASELINK = f"https://github.com/NREL/OpenStudio/releases/download/v{sdk_version}{OS_SDK_VERSION_SHA.split('+')[0]}"
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f"\nOS_SDK_BASELINK={OS_SDK_BASELINK}")
print(f"Defaulted baselink '{OS_SDK_BASELINK=}'")
links = re.findall(r'"(https?:\/\/openstudio-ci-builds.*?)"', content)
links = [link.replace('${OPENSTUDIO_VERSION}', sdk_version) for link in links]
if len(links) > 0:
OS_SDK_ALTERNATE_LINK_1 = links[0]
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f"\nOS_SDK_ALTERNATE_LINK_1={OS_SDK_ALTERNATE_LINK_1}")
print(f"Alternate link '{OS_SDK_ALTERNATE_LINK_1=}'")
OS_SDK_INSTALLER_NAME = ul.quote_plus(f"OpenStudio-{sdk_version}{OS_SDK_VERSION_SHA}-Linux.deb")
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f"\nOS_SDK_INSTALLER_NAME={OS_SDK_INSTALLER_NAME}")
print(f"{OS_SDK_INSTALLER_NAME=}")
- name: Download and install OS SDK installer
shell: bash
run: |
Color_Off='\033[0m' # No Color
Red='\033[0;31m'
Yellow='\033[0;33m'
echo "User-supplied arguments:"
echo "Installer link: ${{ github.event.inputs.os_installer_link }}"
echo "Branch Name: ${{ github.event.inputs.branch_name }}"
echo ""
installer_link="${{ github.event.inputs.os_installer_link }}"
if [ -z "$installer_link" ]; then
installer_link="$OS_SDK_BASELINK/$OS_SDK_INSTALLER_NAME"
echo -e "${Yellow}Trying with Baselink: $installer_link${Color_Off}"
if ! wget -q "$installer_link"; then
installer_link="$OS_SDK_ALTERNATE_LINK_1/$OS_SDK_INSTALLER_NAME"
echo -e "${Yellow}Not found at baselink. Trying with alternate link: $installer_link${Color_Off}"
if ! wget -q "$installer_link"; then
echo -e "${Yellow}Cannot find the OS SDK installer. Defaulting to latest release (pre-release included)${Color_Off}"
installer_link=$(curl -s https://api.github.com/repos/NREL/OpenStudio/releases | jq -r '. [0] | .assets | .[] | select(.name | contains("Linux")) | select(.name | contains("deb")) | .browser_download_url')
if [ -z "$installer_link" ]; then
echo -e "${Red}Could not locate the latest OpenStudio deb from the release page.${Color_Off}"
exit 1
fi
echo -e "${Yellow}Trying with latest release: $installer_link${Color_Off}"
if ! wget -q "$installer_link"; then
echo -e "${Red}Not found at $installer_link${Color_Off}"
echo -e "${Red}I've exhausted all options here. Sorry${Color_Off}"
exit 1
fi
fi
fi
else
if ! wget -q "$installer_link"; then
echo "Could not locate the DEB installer at supplied $installer_link"
exit 1
fi
fi
sudo apt update
sudo apt install -y ./OpenStudio*.deb
os_version=$(openstudio openstudio_version)
echo "os_version=$os_version" >> $GITHUB_ENV
- name: Checkout the branch
shell: bash
run: |
branch_name="${{ github.event.inputs.branch_name }}"
if [ -z "$branch_name" ]; then
branch_name=$(openstudio -e "puts OpenStudio::openStudioVersionBuildSHA")
echo "Branch name not supplied, defaulting to '$branch_name'"
else
git fetch
fi;
echo "branch_name=$branch_name" >> $GITHUB_ENV
git checkout $branch_name || git checkout -b $branch_name
- name: Export openstudio-standards libraries
shell: bash
working-directory: ./developer/ruby/
run: |
set -x
N=$(nproc) openstudio export_openstudio_standards_libraries.rb
- name: Upload libraries and logs
if: ${{ always() }}
shell: bash
run: |
Color_Off='\033[0m' # No Color
Red='\033[0;31m'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git config --global user.name 'github-actions[bot]'
mv developer/ruby/pkg/libraries/*.osm src/openstudio_app/Resources/
git add src/openstudio_app/Resources/
if [[ $(git diff --cached --exit-code) ]]; then
git commit -m "Add OSMs results from exporting openstudio-standards libraries with $os_version (${{ github.event.inputs.os_installer_link }})"
git push -u origin $branch_name
else
echo -e "${Red}No OSMs generated...${Color_Off}"
fi
git add -f ./developer/ruby/pkg/libraries/*
if [[ $(git diff --cached --exit-code) ]]; then
git commit -m "Add logs for review (DISCARD ME)"
git push -u origin $branch_name
else
echo "${Red}No logs to commit, that's very strange...${Color_Off}"
fi