Skip to content

Commit

Permalink
enh: add comment trigger for baseline_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsbck committed Nov 21, 2024
1 parent 2855ff7 commit 61c577c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 28 deletions.
18 changes: 1 addition & 17 deletions .github/workflows/regression_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,4 @@ jobs:
echo "No regression test results found in main branch"
fi
pytest -m regression
git checkout
# - name: Comment PR
# if: github.event.pull_request.base.ref == 'main'
# uses: actions/github-script@v7
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# const fs = require('fs');
# const TestReport = fs.readFileSync('regression_test_report.txt', 'utf8');

# await github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: `## Regression Test Results\n\`\`\`\n${TestReport}\n\`\`\``
# });
git checkout
28 changes: 18 additions & 10 deletions .github/workflows/update_regression_baseline.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# .github/workflows/regression_tests.yml
name: Update Regression Tests
name: Update Regression Baseline

on:
workflow_dispatch:
issue_comment:
types: [created]


jobs:
regression_tests:
name: regression_tests
if: github.event.issue.pull_request && contains(github.event.comment.body, '/update_baseline')
runs-on: ubuntu-20.04
permissions:
contents: write
Expand All @@ -27,6 +30,15 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Get PR branch
uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch

- name: Checkout PR branch
uses: actions/checkout@v3
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}

- name: Update baseline
if: github.event.pull_request.base.ref == 'main'
Expand All @@ -35,13 +47,9 @@ jobs:
git config --global user.email '[email protected]'
NEW_BASELINE=1 pytest -m regression
- name: Commit and push if baseline changed
- name: Commit and push
if: github.event.pull_request.base.ref == 'main'
run: |
if git diff --quiet tests/regression_test_baselines.json; then
echo "No changes to baseline file"
else
git add tests/regression_test_baselines.json
git commit -m "Update regression test baselines"
git push origin HEAD:${{ github.head_ref }}
fi
git add tests/regression_test_baselines.json
git commit -m "Update regression test baselines"
git push origin HEAD:${{ steps.comment-branch.outputs.head_ref }}
2 changes: 1 addition & 1 deletion tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def append_to_json(fpath, test_name, input_kwargs, runtimes):


class compare_to_baseline:
def __init__(self, baseline_iters=1, test_iters=1):
def __init__(self, baseline_iters=3, test_iters=1):
self.baseline_iters = baseline_iters
self.test_iters = test_iters

Expand Down

0 comments on commit 61c577c

Please sign in to comment.