forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (95 loc) · 5.03 KB
/
upload-test-stats.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Upload test stats
on:
workflow_run:
workflows: [pull, trunk, periodic, inductor, unstable, slow, unstable-periodic, inductor-periodic, rocm]
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:
if: github.repository_owner == 'pytorch'
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.repository_owner == 'pytorch' &&
(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: ubuntu-22.04
environment: upload-stats
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@main
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: pip
- run: |
pip3 install requests==2.26 rockset==1.0.3 boto3==1.19.12
- name: Upload test stats
env:
ROCKSET_API_KEY: ${{ secrets.ROCKSET_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_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_REPOSITORY: ${{ github.event.workflow_run.head_repository.full_name }}
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}" --head-repository "${HEAD_REPOSITORY}"
python3 -m tools.stats.upload_sccache_stats --workflow-run-id "${WORKFLOW_RUN_ID}" --workflow-run-attempt "${WORKFLOW_RUN_ATTEMPT}"
- name: Upload test artifacts
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_ARTIFACTS_URL: ${{ github.event.workflow_run.artifacts_url }}
WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }}
WORKFLOW_RUN_ATTEMPT: ${{ github.event.workflow_run.run_attempt }}
REPO_FULLNAME: ${{ github.event.workflow_run.repository.full_name }}
run: |
echo "${WORKFLOW_ARTIFACTS_URL}"
# Note that in the case of Linux and Windows, their artifacts have already been uploaded to S3, so there simply won't be
# anything on GitHub to upload. The command should return right away
python3 -m tools.stats.upload_artifacts --workflow-run-id "${WORKFLOW_RUN_ID}" --workflow-run-attempt "${WORKFLOW_RUN_ATTEMPT}" --repo "${REPO_FULLNAME}"
- name: Analyze disabled tests rerun
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_ARTIFACTS_URL: ${{ github.event.workflow_run.artifacts_url }}
WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }}
WORKFLOW_RUN_ATTEMPT: ${{ github.event.workflow_run.run_attempt }}
REPO_FULLNAME: ${{ github.event.workflow_run.repository.full_name }}
run: |
# Analyze the results from disable tests rerun and upload them to S3
python3 -m tools.stats.check_disabled_tests --workflow-run-id "${WORKFLOW_RUN_ID}" --workflow-run-attempt "${WORKFLOW_RUN_ATTEMPT}" --repo "${REPO_FULLNAME}"
check-api-rate:
if: ${{ always() && github.repository_owner == 'pytorch' }}
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Get our GITHUB_TOKEN API limit usage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/rate_limit