Standardize CI scripts to print both raw and GitHub actions messages when run under GitHub actions

Apparently the location information is no longer visible in build logs

Pointed out in https://github.com/DFHack/dfhack/pull/1704#issuecomment-726991055
develop
lethosor 2020-12-27 23:35:36 -05:00
parent eb6957a167
commit 4460584361
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
2 changed files with 3 additions and 7 deletions

@ -128,21 +128,17 @@ def main():
lines[i] = line.decode('utf-8') lines[i] = line.decode('utf-8')
except UnicodeDecodeError: except UnicodeDecodeError:
msg_params = (rel_path, i + 1, 'Invalid UTF-8 (other errors will be ignored)') msg_params = (rel_path, i + 1, 'Invalid UTF-8 (other errors will be ignored)')
error('%s:%i: %s' % msg_params)
if is_github_actions: if is_github_actions:
error()
print('::error file=%s,line=%i::%s' % msg_params) print('::error file=%s,line=%i::%s' % msg_params)
else:
error('%s:%i: %s' % msg_params)
lines[i] = '' lines[i] = ''
for linter in linters: for linter in linters:
try: try:
linter.check(lines) linter.check(lines)
except LinterError as e: except LinterError as e:
error('%s: %s' % (rel_path, e))
if is_github_actions: if is_github_actions:
error()
print(e.github_actions_workflow_command(rel_path)) print(e.github_actions_workflow_command(rel_path))
else:
error('%s: %s' % (rel_path, e))
if fix: if fix:
linter.fix(lines) linter.fix(lines)
contents = '\n'.join(lines) contents = '\n'.join(lines)

@ -11,6 +11,7 @@ def print_stderr(stderr, args):
return return
for line in stderr.split('\n'): for line in stderr.split('\n'):
print(line)
parts = list(map(str.strip, line.split(':'))) parts = list(map(str.strip, line.split(':')))
# e.g. luac prints "luac:" in front of messages, so find the first part # e.g. luac prints "luac:" in front of messages, so find the first part
# containing the actual filename # containing the actual filename
@ -18,7 +19,6 @@ def print_stderr(stderr, args):
if parts[i].endswith('.' + args.ext) and parts[i + 1].isdigit(): if parts[i].endswith('.' + args.ext) and parts[i + 1].isdigit():
print('::error file=%s,line=%s::%s' % (parts[i], parts[i + 1], ':'.join(parts[i + 2:]))) print('::error file=%s,line=%s::%s' % (parts[i], parts[i + 1], ':'.join(parts[i + 2:])))
break break
print(line)
def main(args): def main(args):