mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-23 14:44:54 -04:00
Revert "chore(tests): Avoid network, sleep and more during tests" (#11601)
Revert "chore(tests): Avoid network, sleep and more during tests (#11050)"
This reverts commit cb3bf7af3f.
This commit is contained in:
1 parent
6d27f3b210
commit
2383726d6d
121 files changed
+407
-4756
No files matched your search
@@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ca="${LOCALAI_BUILD_PROXY_CA:?build proxy CA is unset}"
|
||||
builder="${BUILDER_NAME:?Buildx builder name is unset}"
|
||||
container="$(docker ps --filter "name=buildx_buildkit_${builder}0" --format '{{.ID}}' | head -n1)"
|
||||
if test -z "$container"; then
|
||||
echo 'BuildKit container not found' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker exec "$container" mkdir -p /usr/local/share/ca-certificates /etc/ssl/certs
|
||||
docker cp "$ca" "$container:/usr/local/share/ca-certificates/localai-build-proxy.crt"
|
||||
docker exec "$container" sh -eu -c '
|
||||
if command -v update-ca-certificates >/dev/null 2>&1; then
|
||||
update-ca-certificates
|
||||
else
|
||||
cat /usr/local/share/ca-certificates/localai-build-proxy.crt >>/etc/ssl/certs/ca-certificates.crt
|
||||
fi
|
||||
'
|
||||
docker restart "$container" >/dev/null
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
output="${RUNNER_TEMP}/localai-build-proxy"
|
||||
mkdir -p "$output"
|
||||
CGO_ENABLED=0 GOCACHE="${RUNNER_TEMP}/go-build-cache" go build -o "$output/build-proxy" ./cmd/build-proxy
|
||||
nohup "$output/build-proxy" --listen 127.0.0.1:18080 --output "$output" >"$output/proxy.log" 2>&1 &
|
||||
echo "$!" >"$output/proxy.pid"
|
||||
for _ in $(seq 1 50); do
|
||||
grep -q '^ca=' "$output/proxy.log" && break
|
||||
sleep 0.1
|
||||
done
|
||||
grep '^proxy=' "$output/proxy.log"
|
||||
grep '^ca=' "$output/proxy.log"
|
||||
proxy_ca="$output/ca/ca.crt"
|
||||
ca_bundle="$output/ca/ca-bundle.crt"
|
||||
system_ca=""
|
||||
for candidate in \
|
||||
/etc/ssl/certs/ca-certificates.crt \
|
||||
/etc/ssl/cert.pem \
|
||||
/etc/pki/tls/certs/ca-bundle.crt \
|
||||
/etc/openssl/certs/ca-certificates.crt; do
|
||||
if test -s "$candidate"; then
|
||||
system_ca="$candidate"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$system_ca"; then
|
||||
echo 'build proxy: unable to find the runner system CA bundle' >&2
|
||||
exit 1
|
||||
fi
|
||||
cat "$system_ca" "$proxy_ca" >"$ca_bundle"
|
||||
{
|
||||
echo "LOCALAI_BUILD_PROXY=http://127.0.0.1:18080"
|
||||
echo "LOCALAI_BUILD_PROXY_OUTPUT=$output"
|
||||
echo "LOCALAI_BUILD_PROXY_CA=$proxy_ca"
|
||||
echo "LOCALAI_BUILD_PROXY_CA_BUNDLE=$ca_bundle"
|
||||
echo "HTTP_PROXY=http://127.0.0.1:18080"
|
||||
echo "HTTPS_PROXY=http://127.0.0.1:18080"
|
||||
echo "http_proxy=http://127.0.0.1:18080"
|
||||
echo "https_proxy=http://127.0.0.1:18080"
|
||||
echo "SSL_CERT_FILE=$ca_bundle"
|
||||
echo "CURL_CA_BUNDLE=$ca_bundle"
|
||||
echo "REQUESTS_CA_BUNDLE=$ca_bundle"
|
||||
echo "GIT_SSL_CAINFO=$ca_bundle"
|
||||
echo "NODE_EXTRA_CA_CERTS=$proxy_ca"
|
||||
echo "NO_PROXY=localhost,127.0.0.1"
|
||||
echo "no_proxy=localhost,127.0.0.1"
|
||||
} >>"$GITHUB_ENV"
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if test -z "${LOCALAI_BUILD_PROXY_OUTPUT:-}"; then
|
||||
echo 'Build proxy did not start; skipping inventory finalization'
|
||||
exit 0
|
||||
fi
|
||||
output="$LOCALAI_BUILD_PROXY_OUTPUT"
|
||||
if test -f "$output/proxy.pid"; then
|
||||
kill -TERM "$(cat "$output/proxy.pid")" 2>/dev/null || true
|
||||
for _ in $(seq 1 50); do
|
||||
test -f "$output/summary.json" && break
|
||||
sleep 0.1
|
||||
done
|
||||
fi
|
||||
|
||||
# Later artifact uploads and action post-hooks must not target a stopped proxy.
|
||||
{
|
||||
echo 'HTTP_PROXY='
|
||||
echo 'HTTPS_PROXY='
|
||||
echo 'http_proxy='
|
||||
echo 'https_proxy='
|
||||
echo 'SSL_CERT_FILE='
|
||||
echo 'CURL_CA_BUNDLE='
|
||||
echo 'REQUESTS_CA_BUNDLE='
|
||||
echo 'GIT_SSL_CAINFO='
|
||||
echo 'NODE_EXTRA_CA_CERTS='
|
||||
} >>"$GITHUB_ENV"
|
||||
if test -f "$output/summary.json"; then
|
||||
{
|
||||
echo '### Build network inventory'
|
||||
echo
|
||||
echo 'HTTPS without the generated CA is reported as CONNECT because its HTTP method is encrypted.'
|
||||
echo
|
||||
echo '```json'
|
||||
cat "$output/summary.json"
|
||||
echo '```'
|
||||
} >>"$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
|
||||
# A matrix cancellation can interrupt checkout or a BuildKit request at any
|
||||
# point. Preserve whatever inventory exists, but do not replace the canceled
|
||||
# conclusion with a misleading proxy-enforcement failure.
|
||||
if test "${LOCALAI_BUILD_JOB_STATUS:-}" = cancelled; then
|
||||
echo 'Build was cancelled; skipping network inventory enforcement'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! test -s "$output/events.jsonl"; then
|
||||
echo 'Build proxy produced no network inventory' >&2
|
||||
exit 1
|
||||
fi
|
||||
if grep -qE '"method":"CONNECT"|"error":"plain HTTP is forbidden"' "$output/events.jsonl"; then
|
||||
echo 'Build traffic bypassed HTTPS interception or attempted plain HTTP' >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in new issue
Block a user