Files
Wakeful/scripts/check.sh
Gary HansenandClaude Opus 5.5 757f1ed64a
check / lint (push) Successful in 7m16s
check / macos (push) Canceled after 0s
Add Gitea Actions pipeline with basic checks
scripts/check.sh (also `make check`) parses the Swift sources, validates
Info.plist and its placeholders, checks the Makefile VERSION against the
newest CHANGELOG release, and flags whitespace errors and conflict markers.

The lint job runs it on the existing Linux runners in a swift:6.3
container. A full macOS build job is included but skipped until a macOS
runner is registered and the MACOS_RUNNER repo variable is set to true.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 15:14:13 +10:00

52 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
# Basic checks that need no macOS SDK, so CI can run them on Linux.
# Run locally with `make check`. A full compile still needs a Mac.
set -eu
cd "$(dirname "$0")/.."
fail=0
step() { printf '\n==> %s\n' "$1"; }
bad() { printf 'FAIL: %s\n' "$1"; fail=1; }
step "Swift syntax"
swiftc -parse Sources/Wakeful/*.swift || bad "swiftc -parse reported errors"
step "Info.plist"
# The Makefile seds these placeholders in; losing one ships a broken bundle.
for key in __BUNDLE_ID__ __VERSION__; do
grep -q "$key" Resources/Info.plist || bad "Resources/Info.plist is missing $key"
done
if command -v plutil >/dev/null 2>&1; then
plutil -lint Resources/Info.plist || bad "Resources/Info.plist is not a valid plist"
else
swift - <<'SWIFT' || bad "Resources/Info.plist is not a valid plist"
import Foundation
let data = try Data(contentsOf: URL(fileURLWithPath: "Resources/Info.plist"))
_ = try PropertyListSerialization.propertyList(from: data, format: nil)
print("Resources/Info.plist: OK")
SWIFT
fi
step "Version"
version=$(sed -n 's/^VERSION *:= *//p' Makefile)
latest=$(sed -n 's/^## \[\([0-9][^]]*\)\].*/\1/p' CHANGELOG.md | head -n 1)
if [ -z "$version" ]; then
bad "no VERSION in Makefile"
elif [ "$version" != "$latest" ]; then
bad "Makefile VERSION is $version but the newest CHANGELOG release is ${latest:-missing}"
else
echo "$version"
fi
step "Whitespace and conflict markers"
# Diff the whole tree against the empty tree so this works on a shallow clone.
empty=$(git hash-object -t tree /dev/null)
git diff --check "$empty" HEAD -- . && echo OK || bad "whitespace errors or conflict markers (see above)"
echo
if [ "$fail" -ne 0 ]; then
echo "Checks failed."
exit 1
fi
echo "All checks passed."