Skip to content

Commit 1f6b98a

Browse files
committed
Resolve actions command warning
If line and endLine are different (like a range usually is), then it can't cope with col and endColumn being set: ``` Invalid error command value. 'col' and 'endColumn' cannot be set if 'line' and 'endLine' are different values. ```
1 parent 9053410 commit 1f6b98a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

image/tools/convert_validate_report.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ def convert_to_github(report: Dict, base_path: str) -> Iterable[str]:
2525
params['endLine'] = diag['range']['end']['line']
2626
params['endColumn'] = diag['range']['end']['column']
2727

28+
if params.get('line') != params.get('endLine'):
29+
# GitHub can't cope with 'col' and 'endColumn' if 'line' and 'endLine' are different values.
30+
if 'col' in params:
31+
del params['col']
32+
if 'endColumn' in params:
33+
del params['endColumn']
34+
2835
summary = diag['summary'].split('\n')[0]
2936
params = ','.join(f'{k}={v}' for k, v in params.items())
3037

tests/test_validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_invalid_paths():
122122

123123
expected_output = [
124124
'::error file=tests/validate/invalid/main.tf,line=2,col=1,endLine=2,endColumn=33::Duplicate resource "null_resource" configuration',
125-
'::error file=tests/validate/module/invalid.tf,line=2,col=1,endLine=5,endColumn=66::Duplicate resource "null_resource" configuration'
125+
'::error file=tests/validate/module/invalid.tf,line=2,endLine=5::Duplicate resource "null_resource" configuration'
126126
]
127127

128128
output = list(convert_to_github(input, 'tests/validate/invalid'))

0 commit comments

Comments
 (0)