Files
pytorch/.github/scripts/parse_ref.py
Sam Estep e1cbc43f50 Use tools/print_test_stats.py in GHA (#57647)
Summary:
Judging from https://github.com/pytorch/pytorch/issues/57584, it seems like the test-reports artifact was originally intended to be downloaded to `$PWD/test-reports` instead of just directly into `$PWD`. To minimize confusion, this PR changes it to download into `test/test-reports`, which should match where the files came from in the `test` step anyway.

TODOs:

- [x] change the extract path for test-reports
- [x] install Python dependencies
- [x] call `tools/print_test_stats.py`
- [x] use deep clone to allow `git` commands
- [x] correctly set `CIRCLE_*` environment variables
- [x] set Scribe credentials
- [x] set AWS credentials

Pull Request resolved: https://github.com/pytorch/pytorch/pull/57647

Test Plan: CI.

Reviewed By: seemethere

Differential Revision: D28325833

Pulled By: samestep

fbshipit-source-id: cc322bad76747f59b764a1a0a863153bb26095e7
2021-05-10 12:29:40 -07:00

22 lines
526 B
Python
Executable File

#!/usr/bin/env python3
import os
import re
def main() -> None:
ref = os.environ['GITHUB_REF']
m = re.match(r'^refs/(\w+)/(.*)$', ref)
if m:
category, stripped = m.groups()
if category == 'heads':
print(f'::set-output name=branch::{stripped}')
elif category == 'pull':
print(f'::set-output name=branch::pull/{stripped.split("/")[0]}')
elif category == 'tags':
print(f'::set-output name=tag::{stripped}')
if __name__ == '__main__':
main()