Repository navigation
102 lines (88 loc) · 3.32 KB
/
Copy pathshellcheck.yml
File metadata and controls
102 lines (88 loc) · 3.32 KB
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
name: ShellCheck
on:
push:
pull_request:
jobs:
shellcheck:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@2.0.0
smoke-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Syntax check
run: |
bash -n stylesmuggler-helper.sh
bash -n fix-magento-source.sh
bash -n stylesmuggler-remote-check.sh
- name: fix-magento-source.sh - rejects a non-Magento root
run: |
set +e
output=$(./fix-magento-source.sh /definitely-does-not-exist < /dev/null 2>&1)
status=$?
echo "$output"
set -e
[ "$status" -eq 1 ]
echo "$output" | grep -q "does not look like a Magento/Adobe Commerce root"
- name: fix-magento-source.sh - detects native environment and runs clean
run: |
fixture=$(mktemp -d)
mkdir -p "$fixture/bin"
echo '{}' > "$fixture/composer.json"
touch "$fixture/bin/magento"
# A finite, self-terminating input stream, not `yes N` - under this
# step's `pipefail`, `yes` getting SIGPIPE-killed once the script
# exits would otherwise surface as a spurious non-zero status even
# though the script itself succeeded.
output=$(printf 'N\n%.0s' {1..10} | ./fix-magento-source.sh "$fixture" 2>&1)
status=$?
echo "$output"
[ "$status" -eq 0 ]
echo "$output" | grep -q "Detected environment: native"
rm -rf "$fixture"
- name: stylesmuggler-helper.sh - runs without shell errors
run: |
set +e
output=$(./stylesmuggler-helper.sh . /tmp < /dev/null 2>&1)
status=$?
echo "$output"
set -e
# Accept a clean result (0) or "issues found"/non-interactive skip (1) -
# real IoC findings depend on the runner's own process table and aren't
# the thing under test here. Only fail on genuine shell errors.
[ "$status" -eq 0 ] || [ "$status" -eq 1 ]
! echo "$output" | grep -Ei "command not found|unbound variable|syntax error"
- name: stylesmuggler-remote-check.sh - requires a URL argument
run: |
set +e
output=$(./stylesmuggler-remote-check.sh < /dev/null 2>&1)
status=$?
echo "$output"
set -e
[ "$status" -eq 2 ]
echo "$output" | grep -q "Usage:"
- name: stylesmuggler-remote-check.sh - reports an unreachable host cleanly
run: |
set +e
# Deterministic, network-independent "unreachable" target instead of a
# real domain, so this doesn't depend on external network/DNS state.
output=$(STYLESMUGGLER_TIMEOUT=3 ./stylesmuggler-remote-check.sh http://127.0.0.1:1 < /dev/null 2>&1)
status=$?
echo "$output"
set -e
[ "$status" -eq 4 ]
echo "$output" | grep -q "Could not reach"
! echo "$output" | grep -Ei "command not found|unbound variable|syntax error"