Skip to content

Commit

Permalink
Open an issue when benchmarks fails to upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Giguere committed Jan 9, 2025
1 parent f5f5f11 commit eb6c52b
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/nightly_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,19 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.QUTIP_BENCHMARK_S3_KEYID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.QUTIP_BENCHMARK_S3_SECRET }}
AWS_EC2_METADATA_DISABLED: true

finalise:
needs: publish
if: failure()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Open Issue on Failure
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
if [[ -z "${{ inputs.open_issue }}" ]] || [[ "${{ inputs.open_issue }}" != "False" ]];
then
pip install requests
python tools/report_failing_tests.py $GITHUB_TOKEN
fi
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,19 @@ jobs:
run: |
python -m pip install ghp-import
ghp-import -m "Automatic push by ghp-import" -f -n -p -o -r origin -b gh-pages website/_site
finalise:
needs: publish
if: failure()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Open Issue on Failure
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
if [[ -z "${{ inputs.open_issue }}" ]] || [[ "${{ inputs.open_issue }}" != "False" ]];
then
pip install requests
python tools/report_failing_tests.py $GITHUB_TOKEN
fi
45 changes: 45 additions & 0 deletions tools/report_failing_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import requests
import json
import sys
import argparse
from datetime import date

def open_issue(token):
url = "https://api.github.com/repos/qutip/qutip-jax/issues"
data = json.dumps({
"title": f"Automated tests failed on {date.today()}",
"labels": ["bug"],
"body": "Scheduled test failed!"
})

headers = {
"Accept": "application/vnd.github.v3+json",
"Authorization" : f"token {token}",
}

post_request = requests.post(url=url, data=data, headers=headers)

if post_request.status_code == 201:
print("Success")

else:
print(
"Fail:",
post_request.status_code,
post_request.reason,
post_request.content
)


def main():
parser = argparse.ArgumentParser(
description="""Open an issue on failed tests."""
)
parser.add_argument("token")
args = parser.parse_args()
print(args.token)
open_issue(args.token)


if __name__ == "__main__":
sys.exit(main())

0 comments on commit eb6c52b

Please sign in to comment.