Skip to content

Share the value checks between both VM paths #5

Share the value checks between both VM paths

Share the value checks between both VM paths #5

name: Verify split files
# shared/tools.func and shared/build-ui.func are loaders whose implementations
# sit in shared/tools/ and shared/build-ui/. A split can silently lose a
# function -- most easily by cutting through a heredoc that contains a column-0
# function definition, which looks like a definition but is payload. That only
# surfaces on a user's host at install time, so it is checked here instead.
on:
pull_request:
paths:
- "shared/tools.func"
- "shared/tools/**"
- "shared/build-ui.func"
- "shared/build-ui/**"
push:
branches: [main]
paths:
- "shared/tools.func"
- "shared/tools/**"
- "shared/build-ui.func"
- "shared/build-ui/**"
workflow_dispatch:
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Every part parses
run: |
set -euo pipefail
fail=0
for f in shared/tools.func shared/tools/*.func shared/build-ui.func shared/build-ui/*.func; do
bash -n "$f" || { echo "::error file=$f::syntax error"; fail=1; }
done
exit $fail
- name: Each loader still defines its whole API
run: |
set -euo pipefail
check() {
local loader="$1" snapshot="$2"
bash -c '
COMMUNITY_SCRIPTS_CORE_DIR="$PWD"
_cs_source_func() { source "$COMMUNITY_SCRIPTS_CORE_DIR/$1"; }
source "'"$loader"'" >/dev/null 2>&1
declare -F | awk "{print \$3}" |
grep -vE "^(_cs_source_func|_tools_source_part|_build_ui_source)$" | sort
' > /tmp/actual.txt
if ! diff -u "$snapshot" /tmp/actual.txt; then
echo "::error::$loader exports a different set of functions."
echo "Intentional? Regenerate $snapshot in the same PR."
return 1
fi
echo "$loader: $(wc -l < /tmp/actual.txt) functions, unchanged"
}
fail=0
check shared/tools.func shared/tools/API.txt || fail=1
check shared/build-ui.func shared/build-ui/API.txt || fail=1
exit $fail