|
14 | 14 |
|
15 | 15 | from . import CirrusAPI
|
16 | 16 | from .throbber import ProgressBar
|
17 |
| -from .queries import build_log, get_repo, create_build, wait_build, CirrusBuildError |
| 17 | +from .queries import build_log, get_repo, create_build, wait_build, CirrusBuildError, CirrusCreditsError |
18 | 18 |
|
19 | 19 | log = logging.getLogger(__name__)
|
20 | 20 |
|
@@ -47,10 +47,12 @@ def run(args, retry_index=0):
|
47 | 47 | print('Build created: {}'.format(build_url))
|
48 | 48 | with ProgressBar('' if args.verbose else '.'):
|
49 | 49 | try:
|
50 |
| - wait_build(api, build_id, abort=args.timeout*60) |
| 50 | + wait_build(api, build_id, abort=args.timeout*60, credits_error_message=args.cirrus_out_of_ci_credits_message) |
51 | 51 | rc, status, message = 0, 'successful', ''
|
52 | 52 | except CirrusBuildError:
|
53 | 53 | rc, status, message = 1, 'failed', ''
|
| 54 | + except CirrusCreditsError: |
| 55 | + rc, status, message = 3, 'error', 'Out of CI credits' |
54 | 56 | except Exception as exc:
|
55 | 57 | rc, status, message = 2, 'error', '{exception}: {text}'.format(
|
56 | 58 | exception=exc.__class__.__name__,
|
@@ -224,6 +226,15 @@ def parse_args(*a, **ka):
|
224 | 226 | 'the build is retried once more. Default: ${}'
|
225 | 227 | ).format(ENVIRONMENT['flaky_markers']),
|
226 | 228 | )
|
| 229 | + parser.add_argument( |
| 230 | + '--cirrus-out-of-ci-credits-message', |
| 231 | + default='Monthly compute limit exceeded', |
| 232 | + help=( |
| 233 | + 'Error message passed via "notifications" from Cirrus CI reported' |
| 234 | + 'when the CI job failed due to lack of CI credits.' |
| 235 | + 'Default: "Monthly compute limit exceeded"' |
| 236 | + ), |
| 237 | + ) |
227 | 238 | args = parser.parse_args(*a, **ka)
|
228 | 239 |
|
229 | 240 | if not args.token:
|
|
0 commit comments