Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

ci: wait for Docker daemon after mirror restart

efeire170e9f912bf8
diff --git a/.github/scripts/ci-workflow.test.mjs b/.github/scripts/ci-workflow.test.mjs
index 59150b3051..6f162e058f 100644
--- a/.github/scripts/ci-workflow.test.mjs
+++ b/.github/scripts/ci-workflow.test.mjs
@@ -5,7 +5,7 @@ import { tmpdir } from "node:os";
import path from "node:path";
import test from "node:test";
-const workflow = readFileSync(new URL("../workflows/ci.yml", import.meta.url), "utf8");
+const workflow = readFileSync(new URL("../workflows/ci.yml", import.meta.url), "utf8").replaceAll("\r\n", "\n");
function job(name, content = workflow) {
const jobs = content.slice(content.indexOf("\njobs:\n") + 7);
const pattern = /^ ([\w-]+):\s*$/gm;
@@ -290,6 +290,50 @@ test("Linux Rust dependency installs bound apt mirror stalls", () => {
}
});
+for (const name of ["rust-test", "agent-integration"]) {
+ for (const scenario of ["ready", "delayed", "unavailable", "missing-mirror"]) {
+ test(`${name} Docker readiness: ${scenario}`, () => {
+ const step = job(name).match(/ - name: Configure public Docker Hub cache\n([\s\S]*?)(?=\n - )/)[1];
+ const block = step.slice(step.indexOf(" timeout 30s")).replace(/^ /gm, "");
+ const directory = mkdtempSync(path.join(tmpdir(), "dbx-docker-ready-"));
+ try {
+ const result = spawnSync("bash", ["-e", "-o", "pipefail", "-c", `
+ sudo() { "$@"; }
+ systemctl() { printf 'restart\\n' >> "$STATE/restarts"; }
+ timeout() { shift; "$@"; }
+ sleep() { :; }
+ ${process.platform === "win32" ? 'python3() { python "$@"; }' : ""}
+ docker() {
+ local count=0
+ [[ ! -f "$STATE/count" ]] || read -r count < "$STATE/count"
+ count=$((count + 1)); printf '%s\\n' "$count" > "$STATE/count"
+ if [[ "$SCENARIO" == unavailable ]] || { [[ "$SCENARIO" == delayed ]] && ((count < 3)); }; then
+ printf 'daemon not ready\\n' >&2; return 124
+ fi
+ if [[ "$SCENARIO" == missing-mirror ]]; then printf '[]\\n'; else printf '["https://mirror.gcr.io/"]\\n'; fi
+ }
+ ${block}
+ printf 'verified\\n'
+ `], { env: { ...process.env, STATE: directory.replaceAll("\\", "/"), SCENARIO: scenario }, encoding: "utf8", timeout: 15000 });
+ assert.ifError(result.error);
+ assert.equal(readFileSync(path.join(directory, "restarts"), "utf8"), "restart\n");
+ const count = Number(readFileSync(path.join(directory, "count"), "utf8"));
+ if (scenario === "ready" || scenario === "delayed") {
+ assert.equal(result.status, 0, result.stderr);
+ assert.match(result.stdout, /verified/);
+ assert.equal(count, scenario === "ready" ? 1 : 3);
+ } else {
+ assert.notEqual(result.status, 0);
+ assert.doesNotMatch(result.stdout, /verified/);
+ assert.equal(count, scenario === "unavailable" ? 12 : 1);
+ }
+ } finally {
+ rmSync(directory, { recursive: true, force: true });
+ }
+ });
+ }
+}
+
test("Rust test jobs install pinned nextest and retain separate doctests", () => {
const pluginDevHost = readFileSync(new URL("../workflows/plugin-dev-host.yml", import.meta.url), "utf8");
const pluginRelease = readFileSync(new URL("../workflows/plugin-cli-release.yml", import.meta.url), "utf8");
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 13293b5018..ec7e605f09 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1013,8 +1013,17 @@ jobs:
[[ "$ID" == ubuntu ]] || exit 0
sudo python3 .github/scripts/configure-docker-mirror.py /etc/docker/daemon.json --validate
timeout 30s sudo systemctl restart docker
- timeout 15s docker info --format '{{json .RegistryConfig.Mirrors}}' \
- | python3 -c 'import json, sys; assert any(x.rstrip("/") == "https://mirror.gcr.io" for x in json.load(sys.stdin))'
+ for attempt in {1..12}; do
+ if mirrors="$(timeout 5s docker info --format '{{json .RegistryConfig.Mirrors}}')"; then
+ printf '%s\n' "$mirrors" | python3 -c 'import json, sys; assert any(x.rstrip("/") == "https://mirror.gcr.io" for x in json.load(sys.stdin))'
+ break
+ fi
+ if ((attempt == 12)); then
+ echo '::error::Docker did not become ready after restart' >&2
+ exit 1
+ fi
+ sleep 2
+ done
- name: Install system dependencies
run: |
@@ -1642,8 +1651,17 @@ jobs:
[[ "$ID" == ubuntu ]] || exit 0
sudo python3 .github/scripts/configure-docker-mirror.py /etc/docker/daemon.json --validate
timeout 30s sudo systemctl restart docker
- timeout 15s docker info --format '{{json .RegistryConfig.Mirrors}}' \
- | python3 -c 'import json, sys; assert any(x.rstrip("/") == "https://mirror.gcr.io" for x in json.load(sys.stdin))'
+ for attempt in {1..12}; do
+ if mirrors="$(timeout 5s docker info --format '{{json .RegistryConfig.Mirrors}}')"; then
+ printf '%s\n' "$mirrors" | python3 -c 'import json, sys; assert any(x.rstrip("/") == "https://mirror.gcr.io" for x in json.load(sys.stdin))'
+ break
+ fi
+ if ((attempt == 12)); then
+ echo '::error::Docker did not become ready after restart' >&2
+ exit 1
+ fi
+ sleep 2
+ done
- name: Setup RocketMQ server Java
if: matrix.scenario == 'rocketmq'
uses: actions/setup-java@v6