-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathreport-test-status
More file actions
executable file
·71 lines (67 loc) · 1.64 KB
/
report-test-status
File metadata and controls
executable file
·71 lines (67 loc) · 1.64 KB
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
#!/usr/bin/env python
"""
Updates the git commit status
"""
import sys
import os
import argparse
from github import Github
from socket import setdefaulttimeout
from Mu2eCI.logger import log
setdefaulttimeout(120)
parser = argparse.ArgumentParser(
description="Process a pull request given a repository and PR number."
)
parser.add_argument("--pullrequest", type=int, help="The Pull Request ID.")
parser.add_argument(
"--repository",
type=str,
help="The GitHub repository. Must be in the format e.g. Mu2e/Offline",
)
parser.add_argument(
"--dry-run",
type=bool,
default=False,
help="Is this a dry run? i.e. don't touch GitHub.",
)
parser.add_argument(
"--message",
type=str,
help="The status message.",
)
parser.add_argument(
"--test-name",
type=str,
help="The test name.",
)
parser.add_argument(
"--test-state",
type=str,
help="The test state.",
choices=["pending", "failure", "success", "error"],
)
parser.add_argument(
"--commit",
type=str,
help="The test commit.",
)
parser.add_argument(
"--url",
type=str,
help="The git commit status URL.",
)
args = parser.parse_args()
if __name__ == "__main__":
gh = Github(login_or_token=os.environ["GITHUBTOKEN"], retry=3)
try:
repo = gh.get_repo(args.repository)
pr = repo.get_issue(args.pullrequest)
repo.get_commit(sha=args.commit).create_status(
state=args.test_state,
target_url=args.url,
description=args.message,
context=args.test_name,
)
except Exception:
log.exception("Failed to change git commit status: ")
sys.exit(1)