Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/test_pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,31 @@ jobs:
if: always() && matrix.run_regressions && steps.branch_build.outcome != 'failure' # always run this step as long as we actually built
run: pip install energyplus-regressions>=2.1.4

# This will build out a ./regressions package as well as a ./regressions-plotter-{{matric.os}}.html report
- name: Run Regressions
if: always() && matrix.run_regressions && steps.branch_build.outcome != 'failure' # always run this step as long as we actually built
id: regressions
# steps.regressions.conclusion is always "success", but if no regressions, steps.regressions.outcome is "success"
continue-on-error: true
run: python ./scripts/dev/gha_regressions.py ./build/testfiles-develop ./build/testfiles ./regressions

- uses: actions/upload-artifact@v4
- name: Upload Regressions Full Bundle
uses: actions/upload-artifact@v4
id: upload_regressions
if: always() && matrix.run_regressions && steps.regressions.outcome == 'failure' # only run this if regressions were encountered "failed"
with:
name: "regressions-${{ matrix.os }}-${{ github.event.pull_request.head.sha }}"
path: "${{ github.workspace }}/regressions"

- name: Upload Regressions Plotter HTML
uses: actions/upload-artifact@v4
id: upload_regression_plotter
if: always() && matrix.run_regressions && steps.regressions.outcome == 'failure' # only run this if regressions were encountered "failed"
with:
name: "regressions-plotter-${{ matrix.os }}"
path: "${{ github.workspace }}/regression_plotter.html"

# This executes a Python script that reads regressions results and produces a JavaScript file meant to run on GitHub
- name: Generate Regression Summary GitHub Script
if: always() && matrix.run_regressions && steps.regressions.outcome == 'failure'
run: >
Expand All @@ -276,6 +287,7 @@ jobs:

# - uses: lhotari/action-upterm@v1

# Unfortunately I can't get forked repository runs to post onto the original PR, so this is needed to alert for regressions
- name: Fail on Regressions from Forked Repository
if: always() && matrix.run_regressions && steps.regressions.outcome == 'failure' && github.event.pull_request.head.repo.full_name != 'NREL/EnergyPlus'
run: |
Expand Down
43 changes: 43 additions & 0 deletions scripts/dev/gha_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,43 @@ def generate_markdown_summary(self, bundle_root: Path):
</details>"""
(bundle_root / "summary.md").write_text(content)

@staticmethod
def read_csv_to_columns(file_path: Path) -> dict[str, list[str | float]]:
columns = {}
with open(file_path, 'r', newline='') as file:
reader = csv.reader(file)
header = next(reader) # Read header row
for i, col_name in enumerate(header):
columns[col_name.strip()] = []
for row in reader:
for i, value in enumerate(row):
value = value.strip()
variable = header[i].strip()
try:
v = float(value)
columns[variable].append(v)
except ValueError: # just take the string timestamp
columns[variable].append(value)
return columns

@staticmethod
def generate_regression_plotter(bundle_root: Path, metadata_object: dict, results_object: dict, limit: bool):
metadata_string = "metadata = " + json.dumps(metadata_object, indent=4) + ';'
results_string = "results = " + json.dumps(results_object, indent=4) + ';'
limit_string = ""
if limit:
limit_string = r"""<div id="size-alert" class="alert alert-warning" role="alert">The regressions hit a size limit and were truncated, not all files may be represented here. Double check the full regression package.</div>"""
template_file = Path(__file__).resolve().parent / 'regression_plotter.in.html'
content = template_file.read_text()
patches = {
'<!--METADATA OVERRIDE-->': metadata_string,
'<!--RESULTS OVERRIDE-->': results_string,
'<!--LIMIT-->': limit_string
}
for key, value in patches.items():
content = content.replace(key, value)
(bundle_root / 'regression_plotter.html').write_text(content)

def check_all_regressions(self, base_testfiles: Path, mod_testfiles: Path, bundle_root: Path) -> bool:
any_diffs = False
bundle_root.mkdir(exist_ok=True)
Expand Down Expand Up @@ -570,6 +607,12 @@ def check_all_regressions(self, base_testfiles: Path, mod_testfiles: Path, bundl
print(f"* Diffs by Type *:\n{json.dumps(self.diffs_by_type, indent=2, sort_keys=True)}\n")
if any_diffs:
self.generate_markdown_summary(bundle_root)
self.generate_regression_plotter(
bundle_root, metadata_object, results_object, hit_max_limit
)
self.generate_regression_plotter(
bundle_root.parent, metadata_object, results_object, hit_max_limit
)
# print("::warning title=Regressions::Diffs Detected")
return any_diffs

Expand Down
Loading
Loading