-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.yml
90 lines (82 loc) · 2.73 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
name: luacheck-runner
description: Runs luacheck.
branding:
icon: check-square
color: yellow
inputs:
files:
description: >
A list of files, rockspecs, or directories to be checked.
Defaults to the workspace path as set by the `path` input.
required: false
default: '.'
path:
description: >
The working directory for luacheck.
The file list should be relative to this path and output
filenames be displayed relative to this path.
Defaults to the workspace path.
required: false
default: ${{ github.workspace }}
args:
description: >
Additional command-line arguments.
See https://luacheck.readthedocs.io/en/stable/cli.html
required: false
config:
description: >
URL to a custom configuration (`.luacheckrc`) file that will be
used as the default configuration file.
required: false
annotate:
description: >
Emits annotations for source code at locations parsed from the output.
Must be set to "none", "warning" or "error".
Requires that output of warnings not be suppressed through the -qq or -qqq arguments.
required: false
default: none
runs:
using: composite
steps:
- run: |
echo "##[group]Install luacheck"
if ! hash luacheck &>/dev/null; then
sudo apt-get update 1>/dev/null || exit 1
sudo apt-get install -yq luarocks 1>/dev/null || exit 1
sudo luarocks install luacheck 1.1.1-1 1>/dev/null || exit 1
sudo luarocks install lanes 3.16.0-0 &>/dev/null || true
fi
echo "##[command]luacheck --version"
luacheck --version
echo "##[endgroup]"
shell: bash
- run: |
[ -z "${{ inputs.config }}" ] && exit 0
mkdir -p ~/.config/luacheck
curl -fsSL "${{ inputs.config }}" -o ~/.config/luacheck/.luacheckrc || {
echo "Unable to download \"${{ inputs.config }}\"" >&2
exit 1
}
shell: bash
- run: |
annotate() {
case "${{ inputs.annotate }}" in
warning|error)
# Search for "<path>:<line>:<col>: <message>" lines in the output,
# trim whitespace, and reformat them to workflow commands.
awk -F':' -v level="${{ inputs.annotate }}" '
{ print $0 }
/^\s+.+?:[0-9]+:[0-9]+:/ {
gsub(/^\s+|\s+$/, "")
gsub(/^\s+/, "", $4)
printf "::%s file=%s,line=%s,col=%s::%s\n", level, $1, $2, $3, $4
}'
;;
*)
cat
;;
esac
}
luacheck ${{ inputs.args }} -- ${{ inputs.files }} | annotate
working-directory: ${{ inputs.path }}
shell: bash