Skip to content

Commit

Permalink
Pull in JS attempt here
Browse files Browse the repository at this point in the history
  • Loading branch information
Myoldmopar committed Aug 28, 2024
1 parent ba45f76 commit 435070a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 17 deletions.
38 changes: 21 additions & 17 deletions .github/workflows/build_and_test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,32 +170,36 @@ jobs:
- 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 ./branch/scripts/dev/gha_regressions.py ./baseline/build/testfiles ./branch/build/testfiles/ ${{ github.workspace }}/regressions

- name: Generate Artifact Summary
if: always() && matrix.run_regressions && steps.regressions.outcome == 'failure'
shell: bash
run: echo "$(cat ${{ github.workspace }}/regressions/summary.md)" >> $GITHUB_STEP_SUMMARY

- name: Store Summary in the Environment
if: always() && matrix.run_regressions && steps.regressions.outcome == 'failure'
shell: bash
run: echo "R_STUFF=$(cat ${{ github.workspace }}/regressions/summary.md)" >> $GITHUB_ENV

- 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 }}"
path: "${{ github.workspace }}/regressions"

- uses: actions/github-script@v7
- name: Generate Regression Summary GitHub Script
if: always() && matrix.run_regressions && steps.regressions.outcome == 'failure'
shell: bash
run: >
python ./branch/scripts/dev/build_regression_summary.py
${{ github.workspace }}/regressions/summary.md
${{ github.workspace }}/regressions/summary.js
${{ matrix.os }}
${{ github.sha }}
${{ github.run_id }}
${{ steps.upload_regressions.outputs.artifact-url }}
- name: DEBUG Print contents of JS script
if: always() && matrix.run_regressions && steps.regressions.outcome == 'failure'
run: cat ${{ github.workspace }}/regressions/summary.js

- uses: actions/github-script@v7
if: always() && matrix.run_regression && steps.regressions.outcome == 'failure'
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "### :warning: Regressions detected on ${{ matrix.os }} for commit ${{ github.sha }}\n\n ${{ env.R_STUFF }}\n\n - [View Results](https://github.com/NREL/EnergyPlus/actions/runs/${{ github.run_id }})\n - [Download Regressions](${{ steps.upload_regressions.outputs.artifact-url }})"
})
const script = require('${{ github.workspace }}/regressions/summary.js')
console.log(script({github, context}))
33 changes: 33 additions & 0 deletions scripts/dev/build_regression_summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from sys import argv

summary_input_md_file = argv[1]
summary_output_js_file = argv[2]
matrix_os = argv[3]
github_sha = argv[4]
github_run_id = argv[5]
artifact_url = argv[6]

with open(summary_input_md_file) as md:
md_contents = md.read()

fixed_up_contents = f"""
### :warning: Regressions detected on {matrix_os} for commit {github_sha}
{md_contents}
- [View Results](https://github.com/NREL/EnergyPlus/actions/runs/{github_run_id})
- [Download Regressions]({artifact_url})
"""

with open(summary_output_js_file, 'w') as js:
js_contents = f"""
module.exports = ({{github, context}}) => {{
github.rest.issues.createComment({{
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `{fixed_up_contents}`
}})
}}
"""
js.write(js_contents)

0 comments on commit 435070a

Please sign in to comment.