Skip to content

Commit 1643ab2

Browse files
author
FolderView Plus Test
committed
Resolve Windows tooling in shell release scripts
1 parent 8e7ee41 commit 1643ab2

7 files changed

Lines changed: 58 additions & 27 deletions

File tree

scripts/dev_finalize.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ done
7171
cd "${ROOT_DIR}"
7272

7373
fvplus::require_commands bash node git
74+
NODE_BIN="$(fvplus::resolve_platform_command node)"
7475

7576
if [[ "${OPEN_FIXTURE}" == true ]]; then
76-
node scripts/generate_runtime_fixture.mjs
77+
"${NODE_BIN}" scripts/generate_runtime_fixture.mjs
7778
fi
7879

7980
bash scripts/doctor.sh

scripts/doctor.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ fvplus::require_commands "${REQUIRED_COMMANDS[@]}"
2727

2828
echo "Tooling doctor passed."
2929
for cmd in "${REQUIRED_COMMANDS[@]}"; do
30-
if "${cmd}" --version >/dev/null 2>&1; then
31-
version_line="$("${cmd}" --version 2>/dev/null | head -n 1)"
30+
resolved_cmd="$(fvplus::resolve_platform_command "${cmd}" || true)"
31+
if [[ -n "${resolved_cmd}" ]] && "${resolved_cmd}" --version >/dev/null 2>&1; then
32+
version_line="$("${resolved_cmd}" --version 2>/dev/null | head -n 1)"
3233
echo " ${cmd}: ${version_line}"
3334
else
3435
echo " ${cmd}: installed"

scripts/install_smoke.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ if [[ ! -f "${ARCHIVE_FILE}" ]]; then
1919
fi
2020

2121
fvplus::require_commands php node tar sed grep find
22+
PHP_BIN="$(fvplus::resolve_platform_command php)"
23+
NODE_BIN="$(fvplus::resolve_platform_command node)"
2224

2325
ARCHIVE_LIST="$(tar -tf "${ARCHIVE_FILE}")"
2426
ARCHIVE_LIST_NORMALIZED="$(printf '%s\n' "${ARCHIVE_LIST}" | sed 's#^\./##')"
@@ -154,11 +156,11 @@ for required_file in "${REQUIRED_FILES[@]}"; do
154156
done
155157

156158
while IFS= read -r -d '' file; do
157-
php -l "${file}" >/dev/null
159+
"${PHP_BIN}" -l "${file}" >/dev/null
158160
done < <(find "${PLUGIN_DIR}/server" -type f -name "*.php" -print0)
159161

160162
while IFS= read -r -d '' file; do
161-
node --check "${file}" >/dev/null
163+
"${NODE_BIN}" --check "${file}" >/dev/null
162164
done < <(find "${PLUGIN_DIR}/scripts" -type f -name "*.js" ! -path "*/scripts/include/*" -print0)
163165

164166
MUTATING_ENDPOINTS=(

scripts/lib.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,26 @@ fvplus::fail() {
55
exit 1
66
}
77

8+
fvplus::resolve_platform_command() {
9+
local requested="${1:-}"
10+
local resolved=""
11+
[[ -n "${requested}" ]] || return 1
12+
if resolved="$(command -v "${requested}" 2>/dev/null)"; then
13+
printf '%s\n' "${resolved}"
14+
return 0
15+
fi
16+
if [[ "${requested}" != *.exe ]] && resolved="$(command -v "${requested}.exe" 2>/dev/null)"; then
17+
printf '%s\n' "${resolved}"
18+
return 0
19+
fi
20+
return 1
21+
}
22+
823
fvplus::require_commands() {
924
local missing=()
1025
local cmd
1126
for cmd in "$@"; do
12-
if ! command -v "$cmd" >/dev/null 2>&1; then
27+
if ! fvplus::resolve_platform_command "$cmd" >/dev/null 2>&1; then
1328
missing+=("$cmd")
1429
fi
1530
done
@@ -46,4 +61,3 @@ fvplus::archive_file() {
4661
archive_dir="$(fvplus::archive_dir "${root_dir}")"
4762
echo "${archive_dir}/folderview.plus-${version}.txz"
4863
}
49-

scripts/release_guard.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ ARCHIVE_DIR="${FVPLUS_ARCHIVE_DIR:-${ROOT_DIR}/archive}"
1111
MAX_ARCHIVE_BYTES="${FVPLUS_MAX_ARCHIVE_BYTES:-52428800}" # 50 MiB default ceiling
1212
MAX_ARCHIVE_FILE_COUNT="${FVPLUS_MAX_ARCHIVE_FILE_COUNT:-10000}"
1313

14+
resolve_php_bin() {
15+
fvplus::resolve_platform_command php
16+
}
17+
1418
packaging_sync_hint() {
1519
echo "HINT: Run 'bash pkg_build.sh' and commit updated release artifacts (folderview.plus.plg + folderview.plus.xml + archive/*.txz + archive/*.sha256)." >&2
1620
}
@@ -145,8 +149,9 @@ fi
145149
if command -v xmllint >/dev/null 2>&1; then
146150
xmllint --noout "${PLG_FILE}"
147151
else
152+
PHP_BIN="$(resolve_php_bin)"
148153
# shellcheck disable=SC2016
149-
php -r '
154+
"${PHP_BIN}" -r '
150155
libxml_use_internal_errors(true);
151156
$xml = @file_get_contents($argv[1]);
152157
if ($xml === false) { fwrite(STDERR, "ERROR: Failed to read PLG file\n"); exit(1); }

scripts/run_ci_suite.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ done
5858

5959
fvplus::require_commands bash node php git find shellcheck npm npx
6060
export FVPLUS_RELEASE_MODE="${RELEASE_MODE}"
61+
NODE_BIN="$(fvplus::resolve_platform_command node)"
62+
PHP_BIN="$(fvplus::resolve_platform_command php)"
63+
NPM_BIN="$(fvplus::resolve_platform_command npm)"
64+
NPX_BIN="$(fvplus::resolve_platform_command npx)"
6165

6266
chmod +x \
6367
scripts/api_contract_guard.sh \
@@ -111,7 +115,7 @@ prepare_playwright() {
111115
return
112116
fi
113117
fvplus::require_commands npm npx
114-
npm install --no-save playwright
118+
"${NPM_BIN}" install --no-save playwright
115119

116120
local browsers_dir="${PLAYWRIGHT_BROWSERS_PATH:-${HOME}/.cache/ms-playwright}"
117121
local browsers_cached=0
@@ -122,9 +126,9 @@ prepare_playwright() {
122126
if [[ "${browsers_cached}" -eq 1 ]] && parse_truthy "${FVPLUS_PLAYWRIGHT_SKIP_BROWSER_INSTALL_IF_CACHED:-1}"; then
123127
printf '[ci-suite] Playwright browsers already cached in %s, skipping browser install.\n' "${browsers_dir}"
124128
elif parse_truthy "${FVPLUS_PLAYWRIGHT_INSTALL_WITH_DEPS:-1}"; then
125-
npx playwright install --with-deps chromium firefox webkit
129+
"${NPX_BIN}" playwright install --with-deps chromium firefox webkit
126130
else
127-
npx playwright install chromium firefox webkit
131+
"${NPX_BIN}" playwright install chromium firefox webkit
128132
fi
129133
PLAYWRIGHT_READY=1
130134
}
@@ -141,15 +145,15 @@ lint_javascript_syntax() {
141145
mapfile -d '' files < <(find src -type f -name "*.js" ! -path "*/scripts/include/*" -print0)
142146
local file=""
143147
for file in "${files[@]}"; do
144-
node --check "${file}"
148+
"${NODE_BIN}" --check "${file}"
145149
done
146150
}
147151

148152
lint_php_syntax() {
149153
mapfile -d '' files < <(find src -type f -name "*.php" -print0)
150154
local file=""
151155
for file in "${files[@]}"; do
152-
php -l "${file}"
156+
"${PHP_BIN}" -l "${file}"
153157
done
154158
}
155159

@@ -184,15 +188,15 @@ run_lane() {
184188
run_timed_step shellcheck lint_shell_scripts
185189
run_timed_step javascript-syntax lint_javascript_syntax
186190
run_timed_step php-syntax lint_php_syntax
187-
run_timed_step javascript-unused-symbols node scripts/js_unused_symbols_guard.mjs
188-
run_timed_step php-static-analysis php scripts/php_unused_helpers_guard.php
191+
run_timed_step javascript-unused-symbols "${NODE_BIN}" scripts/js_unused_symbols_guard.mjs
192+
run_timed_step php-static-analysis "${PHP_BIN}" scripts/php_unused_helpers_guard.php
189193
;;
190194
tests)
191-
run_timed_step node-mobile-tests node --test tests/mobile-touch-support.test.mjs tests/mobile-regression-guard.test.mjs
192-
run_timed_step node-test-suite node --test tests/*.mjs
195+
run_timed_step node-mobile-tests "${NODE_BIN}" --test tests/mobile-touch-support.test.mjs tests/mobile-regression-guard.test.mjs
196+
run_timed_step node-test-suite "${NODE_BIN}" --test tests/*.mjs
193197
;;
194198
workflow-tests)
195-
run_timed_step versioning-guard-tests node --test tests/versioning-guard.test.mjs tests/support-policy-contract.test.mjs
199+
run_timed_step versioning-guard-tests "${NODE_BIN}" --test tests/versioning-guard.test.mjs tests/support-policy-contract.test.mjs
196200
;;
197201
workflow-guards)
198202
run_timed_step docs-metadata bash scripts/docs_metadata_guard.sh

tests/versioning-guard.test.mjs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,17 @@ test('shared ci suite centralizes linting, tests, guards, docs metadata, and smo
361361
assert.match(runCiSuite, /workflow-guards/);
362362
assert.match(runCiSuite, /docs-guards/);
363363
assert.match(runCiSuite, /shellcheck -x --source-path=SCRIPTDIR/);
364-
assert.match(runCiSuite, /node --check/);
365-
assert.match(runCiSuite, /php -l/);
366-
assert.match(runCiSuite, /node scripts\/js_unused_symbols_guard\.mjs/);
367-
assert.match(runCiSuite, /php scripts\/php_unused_helpers_guard\.php/);
368-
assert.match(runCiSuite, /node --test tests\/mobile-touch-support\.test\.mjs tests\/mobile-regression-guard\.test\.mjs/);
369-
assert.match(runCiSuite, /node --test tests\/\*\.mjs/);
370-
assert.match(runCiSuite, /node --test tests\/versioning-guard\.test\.mjs tests\/support-policy-contract\.test\.mjs/);
364+
assert.match(runCiSuite, /NODE_BIN="\$\(fvplus::resolve_platform_command node\)"/);
365+
assert.match(runCiSuite, /PHP_BIN="\$\(fvplus::resolve_platform_command php\)"/);
366+
assert.match(runCiSuite, /NPM_BIN="\$\(fvplus::resolve_platform_command npm\)"/);
367+
assert.match(runCiSuite, /NPX_BIN="\$\(fvplus::resolve_platform_command npx\)"/);
368+
assert.match(runCiSuite, /"\$\{NODE_BIN\}" --check/);
369+
assert.match(runCiSuite, /"\$\{PHP_BIN\}" -l/);
370+
assert.match(runCiSuite, /"\$\{NODE_BIN\}" scripts\/js_unused_symbols_guard\.mjs/);
371+
assert.match(runCiSuite, /"\$\{PHP_BIN\}" scripts\/php_unused_helpers_guard\.php/);
372+
assert.match(runCiSuite, /"\$\{NODE_BIN\}" --test tests\/mobile-touch-support\.test\.mjs tests\/mobile-regression-guard\.test\.mjs/);
373+
assert.match(runCiSuite, /"\$\{NODE_BIN\}" --test tests\/\*\.mjs/);
374+
assert.match(runCiSuite, /"\$\{NODE_BIN\}" --test tests\/versioning-guard\.test\.mjs tests\/support-policy-contract\.test\.mjs/);
371375
assert.match(runCiSuite, /bash scripts\/release_guard\.sh/);
372376
assert.match(runCiSuite, /bash scripts\/install_smoke\.sh/);
373377
assert.match(runCiSuite, /bash scripts\/main_branch_history_guard\.sh/);
@@ -376,10 +380,10 @@ test('shared ci suite centralizes linting, tests, guards, docs metadata, and smo
376380
assert.match(runCiSuite, /bash scripts\/workflow_self_check\.sh/);
377381
assert.match(runCiSuite, /bash scripts\/browser_smoke\.sh/);
378382
assert.match(runCiSuite, /bash scripts\/theme_matrix_smoke\.sh/);
379-
assert.match(runCiSuite, /npm install --no-save playwright/);
383+
assert.match(runCiSuite, /"\$\{NPM_BIN\}" install --no-save playwright/);
380384
assert.match(runCiSuite, /FVPLUS_PLAYWRIGHT_SKIP_BROWSER_INSTALL_IF_CACHED/);
381385
assert.match(runCiSuite, /Playwright browsers already cached/);
382-
assert.match(runCiSuite, /npx playwright install --with-deps chromium firefox webkit/);
386+
assert.match(runCiSuite, /"\$\{NPX_BIN\}" playwright install --with-deps chromium firefox webkit/);
383387
assert.match(runCiSuite, /FVPLUS_BROWSER_SMOKE_REQUIRED/);
384388
assert.match(runCiSuite, /FVPLUS_THEME_MATRIX_REQUIRED/);
385389
assert.match(runCiSuite, /FVPLUS_CI_TIMINGS_PATH/);

0 commit comments

Comments
 (0)