Skip to content

Commit 0b2b2e6

Browse files
committed
Fix CI: SC2034 false positives + stub host commands in status test
common.sh: SERVER_URL, MAX_RETRY_TIME, DRY_RUN, FORCE are written here and read by sibling modules sourced from the dispatcher. Standalone shellcheck doesn't follow the source graph so the per-file analysis flags them as unused. Per-line disables document the cross-module read. test_apl_feed_cli.bats: the status test asserted Result text that depends on whether the host runner has systemctl, an active feed service, and an established socket on port 31090. Stub systemctl, nc, and ss in setup so checks resolve to ok regardless of host. Updated assertion to match the now-deterministic 'feeding looks healthy' result.
1 parent 4d15435 commit 0b2b2e6

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

scripts/apl-feed/common.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#!/usr/bin/env bash
22

33
ROOT='/'
4+
# shellcheck disable=SC2034 # SERVER_URL/MAX_RETRY_TIME/DRY_RUN/FORCE are read by sibling modules sourced from apl-feed.sh
45
SERVER_URL="${APL_FEED_SERVER_URL:-https://airplanes.live}"
6+
# shellcheck disable=SC2034
57
MAX_RETRY_TIME="${APL_FEED_MAX_RETRY_TIME:-60}"
8+
# shellcheck disable=SC2034
69
DRY_RUN=0
10+
# shellcheck disable=SC2034
711
FORCE=0
812
TMP_FILES=()
913

@@ -197,11 +201,13 @@ parse_common_option() {
197201
;;
198202
--server-url)
199203
[[ $# -ge 2 ]] || die "--server-url requires URL"
204+
# shellcheck disable=SC2034 # consumed by http.sh/claim.sh after parse
200205
SERVER_URL="$2"
201206
return 2
202207
;;
203208
--max-retry-time)
204209
[[ $# -ge 2 ]] || die "--max-retry-time requires N"
210+
# shellcheck disable=SC2034 # consumed by claim.sh after parse
205211
MAX_RETRY_TIME="$2"
206212
return 2
207213
;;

test/test_apl_feed_cli.bats

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,37 @@ setup() {
88
echo "11111111-2222-3333-4444-555555555555" > "$ROOT_DIR/usr/local/share/airplanes/airplanes-uuid"
99
MOCK_PORT_FILE="$(mktemp)"
1010
MOCK_PID_FILE="$(mktemp)"
11+
12+
# Stub external commands `apl-feed status` calls so the result-text
13+
# assertions don't depend on whether the host runner has systemctl,
14+
# active services, or established sockets. Defaults: services active,
15+
# receiver port reachable, ingest link established.
16+
STUB_BIN_DIR="$(mktemp -d)"
17+
cat > "$STUB_BIN_DIR/systemctl" <<'STUB'
18+
#!/usr/bin/env bash
19+
case "$*" in
20+
"is-active --quiet "*) exit 0 ;;
21+
"is-enabled "*) echo "enabled"; exit 0 ;;
22+
esac
23+
exit 0
24+
STUB
25+
cat > "$STUB_BIN_DIR/nc" <<'STUB'
26+
#!/usr/bin/env bash
27+
exit 0
28+
STUB
29+
cat > "$STUB_BIN_DIR/ss" <<'STUB'
30+
#!/usr/bin/env bash
31+
printf 'ESTAB 0 0 127.0.0.1:43530 78.46.234.18:31090 \n'
32+
exit 0
33+
STUB
34+
chmod +x "$STUB_BIN_DIR/systemctl" "$STUB_BIN_DIR/nc" "$STUB_BIN_DIR/ss"
35+
PATH="$STUB_BIN_DIR:$PATH"
36+
export PATH STUB_BIN_DIR
1137
}
1238

1339
teardown() {
1440
stop_mock_server || true
15-
rm -rf "$ROOT_DIR"
41+
rm -rf "$ROOT_DIR" "$STUB_BIN_DIR"
1642
rm -f "$MOCK_PORT_FILE" "$MOCK_PID_FILE"
1743
}
1844

@@ -173,7 +199,7 @@ PY
173199
[[ "$output" =~ "registered and claimed (v3)" ]]
174200
[[ "$output" =~ "Website feed" ]]
175201
[[ "$output" =~ "last data seen 1m ago" ]]
176-
[[ "$output" =~ "Result: some checks need attention" ]]
202+
[[ "$output" =~ "Result: feeding looks healthy" ]]
177203
[ "$(cat "$ROOT_DIR/etc/airplanes/claim-secret.version")" = "3" ]
178204
}
179205

0 commit comments

Comments
 (0)