Skip to content

Commit 72bc0db

Browse files
committed
Write error log to GitHub Actions variable error_log (for use with PR comments)
1 parent 37bd58e commit 72bc0db

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

action.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,24 @@ description: Lint LookML Projects and create Pull Request reviews with linting v
44

55
inputs:
66
configFile:
7-
description: 'path to config file'
8-
required: true
7+
description: 'Path to linter config file specifying severity of each rule.'
8+
required: false
99
default: ${{ github.workspace }}/.github/config.yaml
1010
filepaths:
11-
description: 'list of files to lint (using output of tj-actions/changed-files action in workflow)'
11+
description: 'List of files to lint. Ignore if wanting to lint ALL project files. Use output from tj-actions/changed-files action in workflow to lint only files changed in commit/pull request.'
1212
required: false
1313
default: null
1414
saveOutputToFile:
15-
description: 'Flag to determine whether or not linter output should be saved to a .txt file within repo'
15+
description: 'Flag to determine whether or not linter output should be saved to a .txt file within repo.'
1616
required: false
1717
default: false
1818
type: boolean
1919

20+
outputs:
21+
error_log:
22+
description: 'Error/warning output generated by the linter (indented by LookML file names).'
23+
value: ${{ steps.lookml-linter.outputs.error_log }}
24+
2025
runs:
2126
using: docker
2227
image: Dockerfile

linter/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import subprocess
23
from linter.config_validator import ConfigValidator
34
from linter.lookml_linter import LookMlLinter
45
from linter.lookml_project_parser import LookMlProjectParser
@@ -27,6 +28,13 @@ def main():
2728
error_log = linter.get_errors()
2829
print(error_log)
2930

31+
# Save output to GHA environment variable
32+
with open(os.getenv('GITHUB_ENV'), 'a') as fh:
33+
error_log = error_log.replace(' ', '    ')
34+
fh.write("error_log<<EOF\n")
35+
fh.write(error_log)
36+
fh.write("EOF\n")
37+
3038
# Save output to file, if enabled
3139
if save_output_to_file == 'true' or save_output_to_file == 'True':
3240
linter.save_errors(error_log, '_lookml-linter-output.txt')

0 commit comments

Comments
 (0)