Initial Dever 0.0.1
This commit is contained in:
commit
81233d098c
1479 files changed
+163782
No files matched your search
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env bash
|
||||
# 真实下载与共享缓存验收;准备完成后由调用方关闭本 Job 的外网再跑通用开发验收。
|
||||
set -euo pipefail
|
||||
cd /work
|
||||
export SHELL=/bin/bash
|
||||
for certificate in root.pem server.pem server-key.pem; do
|
||||
test -f "/work/tls/$certificate" || { echo "Missing TLS fixture: $certificate" >&2; exit 1; }
|
||||
done
|
||||
for tool in rustc cargo rustup gcc cc ld; do
|
||||
if command -v "$tool"; then
|
||||
echo "unexpected preinstalled compiler: $tool" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
python3 /work/server.py > server.log 2>&1 &
|
||||
server=$!
|
||||
finish() {
|
||||
local code=$?
|
||||
if (( code )); then
|
||||
echo "ONLINE_VALIDATION_FAILED: $code" >&2
|
||||
for log in retry.log first-run.err first-test.err wait.log http/server-False.log http/server-True.log server.log; do
|
||||
if [[ -f $log ]]; then printf '\n%s\n' "$log"; tail -n 20 "$log"; fi
|
||||
done
|
||||
fi
|
||||
kill "$server"
|
||||
wait "$server" || true
|
||||
}
|
||||
trap finish EXIT
|
||||
python3 - <<'PY'
|
||||
import socket
|
||||
import time
|
||||
for attempt in range(100):
|
||||
try:
|
||||
with socket.create_connection(('127.0.0.1', 18080), timeout=1):
|
||||
break
|
||||
except ConnectionRefusedError:
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
raise RuntimeError('local release server did not start')
|
||||
PY
|
||||
url=http://127.0.0.1:18080
|
||||
prefix='/work/install/dever tools'
|
||||
export RUSTUP_DIST_SERVER=$url
|
||||
touch /work/reject-environment
|
||||
curl -fsSL "$url/install" | timeout 30 bash -s -- --prefix "$prefix" --release-url "$url" > install.log 2>&1
|
||||
cat install.log
|
||||
if grep -Ei 'rustc|cargo|private Rust' install.log; then exit 1; fi
|
||||
test "$("$prefix/bin/dever" --version)" = 'dever 0.0.1'
|
||||
"$prefix/bin/dever" new editing
|
||||
"$prefix/bin/dever" check editing
|
||||
"$prefix/bin/dever" fmt editing --check
|
||||
test ! -e "$prefix/versions/0.0.1/toolchain/ready"
|
||||
# 安装已返回且编辑命令可用;首次编译须报告真实下载失败,不能假成功。
|
||||
if "$prefix/bin/dever" build editing --output /work/rejected-app > failed-build.log 2>&1; then
|
||||
echo 'build unexpectedly succeeded without an environment' >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -F 'Dever environment preparation failed' failed-build.log
|
||||
grep -F '404' "$prefix/versions/0.0.1/toolchain/prepare.log"
|
||||
test ! -e /work/rejected-app
|
||||
rm /work/reject-environment
|
||||
touch /work/hold-environment
|
||||
# 用真实归档前缀模拟上次断线已下载的内容,服务端记录并验证 Range 恢复。
|
||||
native=$(basename /work/assets/dever-native-*.tar.xz)
|
||||
head -c 65536 "/work/assets/$native" > "$prefix/cache/downloads/$native.part"
|
||||
curl -fsSL "$url/install" | timeout 30 bash -s -- --prefix "$prefix" --release-url "$url" > retry.log 2>&1
|
||||
"$prefix/bin/dever" run editing -- hello.greeting.greet '{"name":"background"}' > first-run.log 2> first-run.err &
|
||||
running=$!
|
||||
"$prefix/bin/dever" test editing > first-test.log 2> first-test.err &
|
||||
testing=$!
|
||||
bash assets/install --prefix "$prefix" --release-url "$url" --wait > wait.log 2>&1 &
|
||||
waiting=$!
|
||||
for attempt in {1..100}; do
|
||||
if [[ -f /work/parallel-downloads ]]; then break; fi
|
||||
sleep 0.1
|
||||
done
|
||||
test -f /work/parallel-downloads
|
||||
kill -0 "$running" "$testing" "$waiting"
|
||||
test ! -e "$prefix/versions/0.0.1/toolchain/ready"
|
||||
if flock -n "$prefix/.prepare.lock" true; then
|
||||
echo 'preparation lock was not held' >&2
|
||||
exit 1
|
||||
fi
|
||||
echo BACKGROUND_EDITING_AND_PARALLEL_DOWNLOAD_PASS
|
||||
rm /work/hold-environment
|
||||
wait "$running"
|
||||
wait "$testing"
|
||||
wait "$waiting"
|
||||
cat first-run.log first-run.err first-test.log
|
||||
grep -F '"data":"Hello, background"' first-run.log
|
||||
test "$(cat /work/resumed-offset)" = 65536
|
||||
test -f "$prefix/versions/0.0.1/toolchain/ready"
|
||||
if grep -Ei 'rustc|cargo|rust-std' first-run.err first-test.err wait.log; then exit 1; fi
|
||||
echo RESUME_AND_CONCURRENT_BUILD_PASS
|
||||
test "$(grep -c 'dever.*env' "$HOME/.bashrc")" -eq 1
|
||||
first=$(find "$prefix/toolchains" -type f -printf '%P %s %T@\n' | sort | sha256sum)
|
||||
curl -fsSL "$url/install" | bash -s -- --prefix "$prefix" --release-url "$url" --wait
|
||||
second=$(find "$prefix/toolchains" -type f -printf '%P %s %T@\n' | sort | sha256sum)
|
||||
test "$first" = "$second"
|
||||
test "$(grep -c 'dever.*env' "$HOME/.bashrc")" -eq 1
|
||||
# 校验失败不能切换现有命令,下载错误不得伪报成功。
|
||||
active=$(readlink "$prefix/bin/dever")
|
||||
cp assets/dever-0.0.1-linux-x86_64.tar.xz assets/dever-0.0.2-linux-x86_64.tar.xz
|
||||
printf '%064d dever-0.0.2-linux-x86_64.tar.xz\n' 0 > assets/dever-0.0.2-linux-x86_64.tar.xz.sha256
|
||||
if bash assets/install --prefix "$prefix" --release-url "$url" --version 0.0.2 > rejected.log 2>&1; then
|
||||
echo 'corrupt release unexpectedly installed' >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -F FAILED rejected.log
|
||||
test "$(readlink "$prefix/bin/dever")" = "$active"
|
||||
test ! -e "$prefix/versions/0.0.2"
|
||||
test -z "$(find "$prefix" -maxdepth 1 -name '.install.*' -type d -print)"
|
||||
du -sk "$prefix" "$prefix/cache/cargo" "$prefix/toolchains"
|
||||
echo ONLINE_INSTALL_PASS
|
||||
touch /work/online-ready
|
||||
while [ ! -f /work/offline-start ]; do sleep 1; done
|
||||
bash /work/check.sh --installed "$prefix"
|
||||
Reference in new issue
Block a user