Wrap ZoneHVAC:EvaporativeCoolerUnit #420
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test PR Changes | |
on: | |
pull_request: | |
branches: [ master, develop ] | |
jobs: | |
test_installer: | |
runs-on: ubuntu-22.04 | |
if: "!(contains(github.event.head_commit.message, 'skip') && contains(github.event.head_commit.message, 'ci'))" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12.2' | |
- name: Setup python deps | |
shell: bash | |
run: | | |
pip install -r requirements.txt # requests matplotlib numpy pandas seaborn lxml beautifulsoup4 df2gspread docopt tqdm xmldiff | |
git fetch --no-tags --depth=1 origin ${{ github.base_ref }} | |
git fetch --no-tags --depth=1 origin ${{ github.head_ref }} | |
- name: Prepare list of changed tests | |
shell: python | |
run: | | |
import os | |
import shlex | |
import subprocess | |
import re | |
cmd = 'git diff origin/${{ github.base_ref }} origin/${{ github.head_ref }} --name-only -- model/' | |
result = subprocess.check_output(shlex.split(cmd)) | |
touched_files = result.decode('utf-8').splitlines() | |
if len(touched_files) == 0: | |
print("No touched files in model/, nothing to do") | |
exit(0) | |
print("Touched files:\n* {}".format("\n* ".join(touched_files))) | |
with open('model_tests.rb', 'r') as f: | |
content = f.read() | |
lines = content.splitlines() | |
re_test = re.compile(r'^\s+def (test_[^\s]*).*') | |
re_sim_test = re.compile(r"sim_test\('(.*)'") | |
test_name = None | |
fname_to_test = {} | |
for line in lines: | |
if (m := re_test.match(line)): | |
test_name = m.groups()[0] | |
elif (m := re_sim_test.search(line)): | |
fname_to_test[m.groups()[0]] = test_name | |
tests = [] | |
for touched_file in touched_files: | |
test_filename = os.path.basename(touched_file) | |
if test_filename in fname_to_test: | |
tests.append(fname_to_test[test_filename]) | |
test_filter = f"/^({'|'.join(tests)})$/" | |
with open(os.environ['GITHUB_ENV'], 'a') as f: | |
f.write(f"\nTEST_FILTER={test_filter}") | |
- name: Locate installer link | |
shell: python | |
run: | | |
import os | |
import re | |
import requests | |
pr_body = """${{ github.event.pull_request.body }}""" | |
m = re.search(r'\[OpenStudio Installer\].*(https?://.*\.deb)', pr_body, flags=re.I | re.DOTALL) | |
if m: | |
installer_link = m.groups()[0] | |
print(f"Using specified installer from PR body: {installer_link}") | |
else: | |
r = requests.get('https://api.github.com/repos/NREL/OpenStudio/releases/latest') | |
if not r.ok: | |
raise ValueError("Something went wrong when querying {}, status={}".format(url, r.status_code)) | |
exit(0) | |
data = r.json() | |
matched_installers = [x['browser_download_url'] for x in data['assets'] if 'Ubuntu-22.04-x86_64.deb' in x['name']] | |
if len(matched_installers) == 0: | |
matched_installers = [x['browser_download_url'] for x in data['assets'] if 'Ubuntu-22.04.deb' in x['name']] | |
if len(matched_installers) == 0: | |
matched_installers = [x['browser_download_url'] for x in data['assets'] if 'Linux.deb' in x['name']] | |
if len(matched_installers) ==0: | |
raise ValueError("Cannot locate latest openstudio installer") | |
if len(matched_installers) > 1: | |
print(f"Found more than one potential installer... {matched_installers}. Using the first found") | |
installer_link = matched_installers[0] | |
print(f"Defaulting installer link to the latest OpenStudio release: {installer_link}") | |
with open(os.environ['GITHUB_ENV'], 'a') as f: | |
f.write(f"\nINSTALLER_LINK={installer_link}") | |
- name: Download and install OS SDK installer | |
shell: bash | |
run: | | |
set -x | |
echo "Installer link: $INSTALLER_LINK" | |
wget --quiet $INSTALLER_LINK | |
sudo apt install -y ./OpenStudio*.deb | |
openstudio openstudio_version | |
- name: Run changed model_tests | |
shell: bash | |
run: | | |
MT_CPU=$(nproc) openstudio model_tests.rb -n "'$TEST_FILTER'" | |
- name: Run autosizing test | |
shell: bash | |
run: | | |
MT_CTU=$(nproc) openstudio model_tests.rb -n test_autosizing_rb | |
- name: Run highlevel_tests | |
shell: bash | |
run: | | |
MT_CPU=$(nproc) openstudio highlevel_tests.rb | |
- name: Test stability | |
shell: bash | |
if: contains(github.event.pull_request.labels.*.name, 'NewTest') | |
run: | | |
set -x | |
python process_results.py test-stability clean | |
python process_results.py test-stability run -n "'$TEST_FILTER'" | |
ls test/*_out_Linux_run1.osw || (echo "Seems like the tests didn't run!" && exit 1) | |
python process_results.py test-status --tagged --quiet || true | |
python process_results.py heatmap --tagged --quiet || true | |
- name: Archive test results? | |
if: contains(github.event.pull_request.labels.*.name, 'NewTest') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Test-Stability | |
path: Test-Stability/* |