Merge pull request #2 from kristianwind/fix-gitea-php
Run the text-domain check in a container when the runner has no PHP
This commit is contained in:
@@ -46,6 +46,35 @@ ci_plugin_header() {
|
|||||||
"$(ci_repo_root)/$PLUGIN_MAIN" | head -1 | sed -E 's/[[:space:]]+$//'
|
"$(ci_repo_root)/$PLUGIN_MAIN" | head -1 | sed -E 's/[[:space:]]+$//'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Run one of this repository's PHP scripts.
|
||||||
|
#
|
||||||
|
# Uses the local php when there is one — a laptop, GitHub's hosted runners —
|
||||||
|
# and a container otherwise. The Gitea runner image has no php, and losing a
|
||||||
|
# build to "php: command not found" after everything else passed is a silly way
|
||||||
|
# to spend an afternoon. Measured: it happened on the very first Gitea run.
|
||||||
|
#
|
||||||
|
# The repository goes in over a tarball and `docker cp`, never a bind mount: a
|
||||||
|
# Gitea Actions job runs inside a container talking to the HOST's docker
|
||||||
|
# daemon, so a host path here lands on an empty directory nobody created.
|
||||||
|
ci_php() {
|
||||||
|
if command -v php >/dev/null 2>&1; then
|
||||||
|
php "$@"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local tarball cid code=0
|
||||||
|
tarball=$(mktemp -t wpci-php-XXXXXX.tar)
|
||||||
|
( cd "$(ci_repo_root)" && git ls-files -z | tar --null -T - -cf "$tarball" )
|
||||||
|
|
||||||
|
cid=$(docker create "php:8.4-cli" sh -c \
|
||||||
|
"mkdir -p /src && tar -xf /tmp/src.tar -C /src && cd /src && exec php $(printf '%q ' "$@")")
|
||||||
|
docker cp "$tarball" "$cid:/tmp/src.tar" >/dev/null
|
||||||
|
docker start -a "$cid" || code=$?
|
||||||
|
docker rm -f "$cid" >/dev/null
|
||||||
|
rm -f "$tarball"
|
||||||
|
return "$code"
|
||||||
|
}
|
||||||
|
|
||||||
ci_step() { printf '\n\033[1m→ %s\033[0m\n' "$*"; }
|
ci_step() { printf '\n\033[1m→ %s\033[0m\n' "$*"; }
|
||||||
ci_fail() { printf '\033[31mFAIL\033[0m %s\n' "$*" >&2; }
|
ci_fail() { printf '\033[31mFAIL\033[0m %s\n' "$*" >&2; }
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -84,7 +84,7 @@ done <<< "$(git ls-files '*.php')"
|
|||||||
[ "$fails" = "$before" ] && echo " clean"
|
[ "$fails" = "$before" ] && echo " clean"
|
||||||
|
|
||||||
ci_step "text domain"
|
ci_step "text domain"
|
||||||
php ci/check-textdomain.php "$TEXT_DOMAIN" . || fails=$((fails + 1))
|
ci_php ci/check-textdomain.php "$TEXT_DOMAIN" . || fails=$((fails + 1))
|
||||||
|
|
||||||
ci_step "every file the plugin loads is a file the release contains"
|
ci_step "every file the plugin loads is a file the release contains"
|
||||||
# The bug this exists for: a new class file is written, required from the main
|
# The bug this exists for: a new class file is written, required from the main
|
||||||
@@ -107,7 +107,14 @@ for path in $referenced; do
|
|||||||
printf '%s\n' "$shipped" | grep -qx "$path" \
|
printf '%s\n' "$shipped" | grep -qx "$path" \
|
||||||
|| note_fail "The code loads '$path', but the release zip does not contain it. Committed?"
|
|| note_fail "The code loads '$path', but the release zip does not contain it. Committed?"
|
||||||
done
|
done
|
||||||
echo " $checked plugin-relative include(s) checked"
|
if [ "$checked" = 0 ]; then
|
||||||
|
# A check that verifies nothing must say so rather than reporting success.
|
||||||
|
# Not a failure: a single-file plugin, or one with an autoloader instead of
|
||||||
|
# a list of requires, legitimately has nothing here.
|
||||||
|
echo "::warning::No plugin-relative include was found to check. That is expected for a single-file plugin or an autoloader, and a broken scan otherwise."
|
||||||
|
else
|
||||||
|
echo " $checked plugin-relative include(s) checked"
|
||||||
|
fi
|
||||||
|
|
||||||
ci_step "one version, stated once"
|
ci_step "one version, stated once"
|
||||||
# WordPress compares the update feed against the header and nothing else, so a
|
# WordPress compares the update feed against the header and nothing else, so a
|
||||||
|
|||||||
Reference in New Issue
Block a user