Upload test stats #611
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload test stats | |
on: | |
workflow_run: | |
workflows: [pull, trunk, periodic] | |
types: | |
- completed | |
jobs: | |
# the conclusion field in the github context is sometimes null | |
# solution adapted from https://github.com/community/community/discussions/21090#discussioncomment-3226271 | |
get_workflow_conclusion: | |
runs-on: ubuntu-latest | |
outputs: | |
conclusion: ${{ fromJson(steps.get_conclusion.outputs.data).conclusion }} | |
steps: | |
- name: Get workflow run conclusion | |
uses: octokit/[email protected] | |
id: get_conclusion | |
with: | |
route: GET /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/attempts/${{ github.event.workflow_run.run_attempt }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
upload-test-stats: | |
needs: get_workflow_conclusion | |
if: | |
github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' || | |
needs.get_workflow_conclusion.outputs.conclusion == 'success' || needs.get_workflow_conclusion.outputs.conclusion == 'failure' | |
runs-on: [self-hosted, linux.2xlarge] | |
name: Upload test stats for ${{ github.event.workflow_run.id }}, attempt ${{ github.event.workflow_run.run_attempt }} | |
steps: | |
- name: Print workflow information | |
env: | |
TRIGGERING_WORKFLOW: ${{ toJSON(github.event.workflow_run) }} | |
run: echo "${TRIGGERING_WORKFLOW}" | |
- name: Checkout PyTorch | |
uses: pytorch/pytorch/.github/actions/checkout-pytorch@master | |
- run: | | |
pip3 install requests==2.26 | |
pip3 install rockset==0.8.3 | |
pip3 install boto3==1.19.12 | |
pip3 install six==1.16.0 | |
- name: Upload test stats | |
env: | |
ROCKSET_API_KEY: ${{ secrets.ROCKSET_API_KEY }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }} | |
WORKFLOW_RUN_ATTEMPT: ${{ github.event.workflow_run.run_attempt }} | |
WORKFLOW_URL: ${{ github.event.workflow_run.html_url }} | |
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} | |
run: | | |
echo "${WORKFLOW_URL}" | |
python3 -m tools.stats.upload_test_stats --workflow-run-id "${WORKFLOW_RUN_ID}" --workflow-run-attempt "${WORKFLOW_RUN_ATTEMPT}" --head-branch "${HEAD_BRANCH}" | |
python3 -m tools.stats.upload_sccache_stats --workflow-run-id "${WORKFLOW_RUN_ID}" --workflow-run-attempt "${WORKFLOW_RUN_ATTEMPT}" | |
check-api-rate: | |
if: ${{ always() }} | |
runs-on: [self-hosted, linux.2xlarge] | |
continue-on-error: true | |
steps: | |
- name: Get our GITHUB_TOKEN API limit usage | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PYTORCHBOT_TOKEN: ${{ secrets.GH_PYTORCHBOT_TOKEN}} | |
MERGEBOT_TOKEN: ${{ secrets.MERGEBOT_TOKEN}} | |
run: | | |
curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/rate_limit | |
curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $PYTORCHBOT_TOKEN" https://api.github.com/rate_limit | |
curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $MERGEBOT_TOKEN" https://api.github.com/rate_limit |