Files
LocalAI/scripts/addons/prepare.sh
T
mudler-agentandEttore Di Giacinto 8b4f3c35e8 fix(ci): use native workflow path filters (#13037)
* ci: select affected checks and share add-on builds

Keep validation check identities present while omitting expensive steps
when explicit dependency rules prove they are unaffected. Unknown inputs
and diff failures retain broad validation.

Select add-on package legs on PRs and master without weakening catalog
checks or changing release publishing. Manual package runs validate only,
including their reusable Sandbox guest image dependency.

Share bounded, same-run production fixtures across the five add-on test
groups. Verify checkout identity, tools, paths, modes and checksums before
using them. Keep instrumented coverage builds separate.

Assisted-by: nib:gpt-6.1-sol
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* fix(ci): validate documentation test contracts

Documentation is executable input to Tables, recovery, diagnostics,
gallery and other add-on tests. Select all domains for docs changes
instead of treating the whole directory as inert. Cover known readers,
unfamiliar paths and deleted guides in classifier regression fixtures.

Assisted-by: nib:gpt-6.1-sol
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* fix(ci): gate affected jobs before allocation

Classify each workflow once and gate whole expensive jobs. Limit add-on
matrices to affected packages and host groups instead of allocating all
runners before deciding whether their steps should run.

Select documentation readers explicitly and derive host consumers from
local Go imports. Keep unknown source inputs conservative. Preserve
coverage, production fixtures, publish locks and manual full validation.
Remove the unrequested weekly schedules.

Reject classifier failures and unexpected dependency skips in stable
aggregate checks. Document required-check migration without claiming
access to protected-branch settings. Test actual YAML job and matrix
eligibility against representative paths and the original triggers.

Assisted-by: nib:gpt-6.1-sol
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* fix(ci): validate executable and fixture seams

Include executed fixture binaries and their production imports in host
selection. Lexical Go imports alone miss the mock backend started by
the UI test server and add-on suites.

Rebase restored artifact timestamps only after identity and checksum
validation. Preserve the existing stale-source checks across a later
consumer checkout and reject subsequent source edits.

Validate package plan outputs before allowing dependency skips. Missing
or malformed plans must not turn failed publication preparation green.
Cover all three review findings with before-fix reproductions and
actual workflow eligibility regressions.

Assisted-by: nib:gpt-6.1-sol
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* fix(ci): use native workflow path filters

Replace calculated dependencies with visible PR and master path lists.
Run complete area suites without classifier runners or result plumbing.
Restore original packaging validation and publication dependencies.

Keep one production fixture build for the five original add-on groups.
Verify artifact identity and freshness without changing suite inventories.
Document allowlist maintenance and required-check migration limits.

Assisted-by: nib:gpt-6.1-sol
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

---------

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
2026-11-02 21:16:37 +01:00

91 lines
4.9 KiB
Bash

#!/bin/sh
# SPDX-License-Identifier: MIT
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
cd "$root"
export GOTOOLCHAIN=local
export GOPATH="$root/.cache/addons/go" GOMODCACHE="$root/.cache/addons/go/pkg/mod"
export GOCACHE="$root/.cache/addons/go-build" GOBIN="$root/.cache/addons/bin"
export npm_config_cache="$root/.cache/addons/npm" PLAYWRIGHT_BROWSERS_PATH="$root/.cache/addons/browsers"
export PATH="$GOBIN:$PATH"
mode=${1:-}
case "$mode" in --check|--prepare|--prepare-build|--integration) ;; *) echo 'usage: prepare.sh --check|--prepare|--prepare-build|--integration' >&2; exit 2;; esac
[ "$#" -eq 1 ] || exit 2
fail() { echo "$*" >&2; exit 1; }
go version 2>/dev/null | grep -Eq '^go version go1\.26\.[0-9]+ ' || fail 'Go 1.26.x required (GOTOOLCHAIN=local)'
node --version 2>/dev/null | grep -Eq '^v22\.([1-9][2-9]|[2-9][0-9]|[1-9][0-9]{2,})\.[0-9]+$' || fail 'Node 22.12 or later within Node 22 required'
[ "$(protoc --version 2>/dev/null)" = 'libprotoc 26.1' ] || fail 'protoc 26.1 required; provision explicitly (Makefile downloader uses a different version)'
if [ "$mode" = --check ]; then
# Fail before invoking compilers or package managers if generated inputs are absent.
for file in pkg/grpc/proto/backend.pb.go pkg/grpc/proto/backend_grpc.pb.go pkg/motion/proto/motion.pb.go core/http/react-ui/dist/index.html; do
[ -s "$file" ] || fail "missing generated file: $file; run --integration explicitly"
done
fi
command -v npm >/dev/null || fail 'npm required'
command -v "${CC:-cc}" >/dev/null || fail 'CGO C compiler required'
[ "$(go env CGO_ENABLED)" = 1 ] || fail 'CGO_ENABLED=1 required'
space() {
available=$(df -Pk "$root" | awk 'END {print $4}')
[ "$available" -ge 20971520 ] || fail 'stop: at least 20 GiB free required before setup/build'
}
if [ "$mode" = --prepare ] || [ "$mode" = --prepare-build ]; then
space
mkdir -p "$GOBIN" "$root/.cache/addons/tmp"
export TMPDIR="$root/.cache/addons/tmp"
# Exact existing Makefile pins; Go module checksums are authenticated by sum.golang.org.
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2
space
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@1958fcbe2ca8bd93af633f11e97d44e567e945af
space
go mod download
space
(cd core/http/react-ui && npm ci --no-audit --no-fund)
# Explicit setup only: the lockfile-pinned local CLI selects the browser
# revision. Never use npx or install host OS packages here.
# A producer that only compiles fixtures needs no browser. Test consumers
# still use --prepare and the unchanged browser readiness checks.
if [ "$mode" = --prepare-build ]; then
:
elif [ -z "${PLAYWRIGHT_CHROMIUM_PATH:-}" ]; then
space
core/http/react-ui/node_modules/.bin/playwright install chromium
else
[ -x "$PLAYWRIGHT_CHROMIUM_PATH" ] || fail 'configured Chromium is not executable'
fi
exit 0
fi
# Go resolves the Makefile commit to cmd/protoc-gen-go-grpc/v1.4.0.
# Bind the tag to the checksum authenticated by sum.golang.org, not its label.
check_plugin() {
metadata=$(go version -m "$(command -v "$1")") || fail "$1 build metadata unavailable"
printf '%s\n' "$metadata" | awk -v module="$2" -v version="$3" -v sum="$4" '
$1 == "mod" && $2 == module && $3 == version && $4 == sum { found=1 }
$1 == "=>" { replaced=1 }
END { exit !(found && !replaced) }
' || fail "$1 exact module version/checksum required"
}
check_plugin protoc-gen-go google.golang.org/protobuf v1.34.2 'h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg='
check_plugin protoc-gen-go-grpc google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.4.0 'h1:9SxA29VM43MF5Z9dQu694wmY5t8E/Gxr7s+RSxiIDmc='
export GOPROXY=off GOSUMDB=off GOFLAGS=-mod=readonly
if [ "$mode" = --integration ]; then
space
mkdir -p pkg/grpc/proto "$root/.cache/addons/tmp"
export TMPDIR="$root/.cache/addons/tmp"
protoc --experimental_allow_proto3_optional -Ibackend/ --go_out=pkg/grpc/proto/ --go_opt=paths=source_relative --go-grpc_out=pkg/grpc/proto/ --go-grpc_opt=paths=source_relative backend/backend.proto
# Same command as the protogen-go target of the Makefile.
protoc -Ipkg/motion/proto --go_out=pkg/motion/proto --go_opt=paths=source_relative pkg/motion/proto/motion.proto
space
(cd core/http/react-ui && npm run build)
space
go build -p 2 -tags auth -o tests/e2e/mock-backend/mock-backend ./tests/e2e/mock-backend
space
go build -p 2 -tags auth -o tests/e2e-ui/ui-test-server ./tests/e2e-ui
exit 0
fi
for file in tests/e2e/mock-backend/mock-backend tests/e2e-ui/ui-test-server core/http/react-ui/node_modules/.bin/playwright; do
[ -x "$file" ] || fail "missing executable: $file"
done
(cd core/http/react-ui && npm ls --depth=0 --offline >/dev/null) || fail 'installed npm dependencies do not match package/lock requirements'
# --check inspects only; verify performs native compile/runtime and browser probes.
printf '{"case":"toolchain","status":"passed"}\n'