diff --git a/.github/workflows/regression_tests.yml b/.github/workflows/regression_tests.yml index 9a08ca77..c7d5f8ce 100644 --- a/.github/workflows/regression_tests.yml +++ b/.github/workflows/regression_tests.yml @@ -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\`\`\`` - # }); \ No newline at end of file + git checkout \ No newline at end of file diff --git a/.github/workflows/update_regression_baseline.yml b/.github/workflows/update_regression_baseline.yml index 427e9213..6c35f789 100644 --- a/.github/workflows/update_regression_baseline.yml +++ b/.github/workflows/update_regression_baseline.yml @@ -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 @@ -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' @@ -35,13 +47,9 @@ jobs: git config --global user.email 'action@github.com' 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 \ No newline at end of file + git add tests/regression_test_baselines.json + git commit -m "Update regression test baselines" + git push origin HEAD:${{ steps.comment-branch.outputs.head_ref }} \ No newline at end of file diff --git a/tests/test_regression.py b/tests/test_regression.py index 932649c3..ced9d75c 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -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