-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
98 lines (89 loc) · 3.19 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
name: 'fish-shop/run-fishtape-tests'
description: 'A GitHub action for running fishtape tests'
branding:
icon: 'check-square'
color: 'green'
inputs:
title:
description: 'Title to display in job summary'
required: false
default: 'Test results'
patterns:
description: 'File patterns to match against when running tests'
required: false
default: '**.fish'
raw-output:
description: 'Produce raw TAP output'
required: false
default: 'false'
outputs:
total:
description: "Total number of tests run"
value: ${{ steps.run-fishtape-tests.outputs.total }}
passed:
description: "Number of tests passed"
value: ${{ steps.run-fishtape-tests.outputs.passed }}
failed:
description: "Number of tests failed"
value: ${{ steps.run-fishtape-tests.outputs.failed }}
runs:
using: 'composite'
steps:
- name: Install fisher
uses: fish-shop/install-plugin@e3c44aa8a5f9ada23260ae77277de124efb29242 # v2.3.28
with:
plugin-manager: fisher
plugins: jorgebucaran/fishtape
- name: Install tap-diff
run: npm install -g tap-diff
shell: fish {0}
- name: Run fishtape tests
id: run-fishtape-tests
env:
TITLE: ${{ inputs.title }}
PATTERNS: ${{ inputs.patterns }}
RAW_OUTPUT: ${{ inputs.raw-output }}
run: |
set -gx TERM xterm-256color
set -gx FORCE_COLOR 2
set title "$TITLE"
set raw_output (string escape --no-quoted -- $RAW_OUTPUT)
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 -a files $escaped
end
switch $raw_output
case true
fishtape $files | tee output
case false
fishtape $files | tee output | tap-diff
case '*'
echo "Unrecognised raw output option: '$raw_output'" >&2
exit 1
end
set total (tail -n 4 output | sed -rn 's/^[[:digit:]]\.\.([[:digit:]]+)$/\1/p')
set passed (tail -n 4 output | sed -rn 's/^# pass ([[:digit:]]+)$/\1/p')
set failed (tail -n 4 output | sed -rn 's/^# fail ([[:digit:]]+)$/\1/p')
for param in total passed failed
if test -z "$$param"
set $param 0
end
end
if test "$failed" = "0"
set result ":white_check_mark: Pass"
else
set result ":x: Fail"
end
echo "### $title" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Test 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" != "0"
exit 1
end
shell: fish {0}