-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
112 lines (98 loc) · 3.74 KB
/
action.yml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: 'fish-shop/syntax-check'
description: 'A GitHub action for syntax checking fish shell files'
branding:
icon: 'check'
color: 'green'
inputs:
annotations:
description: 'Display annotations for syntax errors in workflow summary and pull request checks'
required: false
default: 'true'
title:
description: 'Title to display in job summary'
required: false
default: 'Syntax check results'
patterns:
description: 'File patterns to match against when running syntax checks'
required: false
default: '**.fish'
outputs:
total:
description: "Total number of files syntax checked"
value: ${{ steps.syntax-check.outputs.total }}
passed:
description: "Number of files passed syntax check"
value: ${{ steps.syntax-check.outputs.passed }}
failed:
description: "Number of files failed syntax check"
value: ${{ steps.syntax-check.outputs.failed }}
runs:
using: "composite"
steps:
- name: Syntax check fish shell files
id: syntax-check
env:
ANNOTATIONS: ${{ inputs.annotations }}
TITLE: ${{ inputs.title }}
PATTERNS: ${{ inputs.patterns }}
run: |
set -gx TERM xterm-256color
set title "$TITLE"
set annotations "$ANNOTATIONS"
set passed 0
set failed 0
for pattern in (string split --no-empty -- " " $PATTERNS)
set -l escaped (string escape --style=script --no-quoted -- $pattern)
set -l escaped (string replace -r -a -- '\\\([?*{}])' '$1' $escaped)
eval set -l files $escaped
for file in $files
echo -n " "
set -l output (fish --no-execute $file 2>&1)
if test $status -ne 0
set_color red; and echo -n "✖"; and set_color normal
echo " $file"
for line in (string split -- $output)
echo " $line"
end
if test "$annotations" = "true"
string match --regex --groups-only '^(?<file>.+)\s+\(line\s+(?<line>[0-9]+)\):\s+(?<message>.+)' $output
set -l title "Syntax issue"
echo "::error file=$file,line=$line,title=$title::$message"
end
set failed (math $failed + 1)
else
set_color green; and echo -n "✔"; and set_color normal
echo " $file"
set passed (math $passed + 1)
end
end
end
set total (math $passed + $failed)
echo
set_color green; and echo -n "passed: $passed"; and set_color normal
echo -n " "
set_color red; and echo -n "failed: $failed"; and set_color normal
echo " of $total files"
echo
if test $failed -gt 0
set_color red; and echo "$failed of $total failed."
else
set_color green; and echo "All of $total files passed!"
end
if test $failed -eq 0
set result ":white_check_mark: Pass"
else
set result ":x: Fail"
end
echo "### $title" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Result :microscope: | Passed :white_check_mark: | Failed :x: |" >> $GITHUB_STEP_SUMMARY
echo "|---------------------|---------------------------|------------|" >> $GITHUB_STEP_SUMMARY
echo "| $result | $passed | $failed |" >> $GITHUB_STEP_SUMMARY
echo "total=$total" >> "$GITHUB_OUTPUT"
echo "passed=$passed" >> "$GITHUB_OUTPUT"
echo "failed=$failed" >> "$GITHUB_OUTPUT"
if test $failed -ne 0
exit 1
end
shell: fish {0}