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。

fix(ci): bound release dependency acquisition across Ubuntu runners (#13804)

efeirebce5e84d1251
diff --git a/.github/scripts/ci-install-system-deps.py b/.github/scripts/ci-install-system-deps.py
index e5c5ff087f..b10cfc4792 100644
--- a/.github/scripts/ci-install-system-deps.py
+++ b/.github/scripts/ci-install-system-deps.py
@@ -11,14 +11,23 @@ import time
from pathlib import Path
SOURCES = Path("/etc/apt/sources.list.d/ubuntu.sources")
+LEGACY_SOURCES = Path("/etc/apt/sources.list")
PRIMARY = "https://archive.ubuntu.com/ubuntu/"
BACKUP = "https://mirrors.edge.kernel.org/ubuntu/"
LAST_RESORT = "http://azure.archive.ubuntu.com/ubuntu/"
MIRRORS = [("primary", PRIMARY), ("backup", BACKUP), ("last-resort", LAST_RESORT)]
+PORT_MIRRORS = [("primary", "https://ports.ubuntu.com/ubuntu-ports/"),
+ ("backup", "https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/")]
PACKAGES = ["libwebkit2gtk-4.1-dev", "libappindicator3-dev", "librsvg2-dev",
"patchelf", "libssl-dev", "libsecret-1-dev"]
PACKAGE_GROUPS = {"gtk": PACKAGES, "packaging": ["zstd"],
- "duckdb": ["libdbus-1-dev", "pkg-config"]}
+ "duckdb": ["libdbus-1-dev", "pkg-config"],
+ "release": ["fcitx5-frontend-gtk3", "ibus-gtk3", "libwebkit2gtk-4.1-dev",
+ "libgtk-3-dev", "libappindicator3-dev", "librsvg2-dev", "patchelf",
+ "libssl-dev", "xdg-utils", "lld"],
+ "node-release": ["libfontconfig1-dev", "libsecret-1-dev"],
+ "fontconfig": ["libfontconfig1-dev"],
+ "preview": ["ffmpeg", "fonts-noto-cjk", "fonts-noto-color-emoji"]}
ACQUIRE_OPTIONS = ["-o", "Acquire::Retries=0", "-o", "Acquire::http::Timeout=30",
"-o", "Acquire::https::Timeout=30", "-o", "APT::Update::Error-Mode=any"]
starting_process = False
@@ -28,6 +37,10 @@ pending_cancel = None
def rewrite_ubuntu_uris(source, mirror):
known = {"mirror+file:/etc/apt/apt-mirrors.txt", PRIMARY, PRIMARY.rstrip("/"),
BACKUP, BACKUP.rstrip("/"), LAST_RESORT, LAST_RESORT.rstrip("/")}
+ known.update({"http://archive.ubuntu.com/ubuntu", "http://archive.ubuntu.com/ubuntu/"})
+ if any(mirror == uri for _label, uri in PORT_MIRRORS):
+ known = {uri.rstrip("/") + suffix for _label, uri in PORT_MIRRORS for suffix in ("", "/")}
+ known.update({"http://ports.ubuntu.com/ubuntu-ports", "http://ports.ubuntu.com/ubuntu-ports/"})
found = 0
in_uris = False
result = []
@@ -43,6 +56,14 @@ def rewrite_ubuntu_uris(source, mirror):
if line.lstrip().startswith("#"):
result.append(line)
continue
+ legacy = re.match(r"^(\s*deb(?:-src)?\s+(?:\[[^\]]*\]\s+)?)(\S+)", line)
+ if legacy:
+ uri = legacy.group(2)
+ if uri in known:
+ found += 1
+ line = line[:legacy.start(2)] + mirror + line[legacy.end(2):]
+ result.append(line)
+ continue
field = re.match(r"^([A-Za-z][A-Za-z0-9-]*):", line)
if field:
in_uris = field[1].lower() == "uris"
@@ -138,11 +159,15 @@ def run_apt(arguments, budget):
return process.returncode, output, timed_out
-def install(source_path=SOURCES, group="gtk"):
+def install(source_path=None, group="gtk"):
+ if source_path is None:
+ source_path = SOURCES if SOURCES.exists() else LEGACY_SOURCES
packages = PACKAGE_GROUPS[group]
original = source_path.read_bytes()
source = original.decode("utf-8")
- candidates = [(label, rewrite_ubuntu_uris(source, mirror)) for label, mirror in MIRRORS]
+ active_source = "\n".join(line for line in source.splitlines() if not line.lstrip().startswith("#"))
+ mirrors = PORT_MIRRORS if re.search(r"https?://[^\s]+/ubuntu-ports/?(?:\s|$)", active_source) else MIRRORS
+ candidates = [(label, rewrite_ubuntu_uris(source, mirror)) for label, mirror in mirrors]
try:
for index, (label, candidate) in enumerate(candidates):
source_path.write_bytes(candidate.encode("utf-8"))
@@ -155,7 +180,7 @@ def install(source_path=SOURCES, group="gtk"):
if code != 0 or timed_out:
if index + 1 < len(candidates) and is_retryable_acquisition_failure(output, timed_out):
reason = "acquisition deadline" if timed_out else "transient acquisition error"
- print(f"APT switching to next source {MIRRORS[index + 1][1]}: {reason}", flush=True)
+ print(f"APT switching to next source {mirrors[index + 1][1]}: {reason}", flush=True)
break
raise RuntimeError(f"APT {label} {phase} failed (exit={code}, timed_out={timed_out})")
else:
diff --git a/.github/scripts/ci-install-system-deps.test.py b/.github/scripts/ci-install-system-deps.test.py
index 19e2e6ee30..0b0ae3a037 100644
--- a/.github/scripts/ci-install-system-deps.test.py
+++ b/.github/scripts/ci-install-system-deps.test.py
@@ -91,6 +91,88 @@ class InstallerTests(unittest.TestCase):
self.assertIn("URIs: https://security.ubuntu.com/ubuntu/", rewritten)
self.assertIn("Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg", rewritten)
+ def test_jammy_list_preserves_options_suites_comments_and_security(self):
+ source = (
+ "# runner sources\n"
+ "deb [arch=amd64 signed-by=/usr/share/keyrings/ubuntu-archive-keyring.gpg] "
+ "http://azure.archive.ubuntu.com/ubuntu/ jammy main universe\n"
+ "deb-src http://archive.ubuntu.com/ubuntu jammy-updates main\n"
+ "deb http://security.ubuntu.com/ubuntu jammy-security main\n"
+ "# deb http://archive.ubuntu.com/ubuntu jammy-backports main\n"
+ "deb https://example.test/apt stable main\n"
+ )
+ expected = source.replace("http://azure.archive.ubuntu.com/ubuntu/", deps.BACKUP)
+ expected = expected.replace("deb-src http://archive.ubuntu.com/ubuntu ", "deb-src " + deps.BACKUP + " ")
+ self.assertEqual(deps.rewrite_ubuntu_uris(source, deps.BACKUP), expected)
+
+ def test_release_package_groups_preserve_existing_dependencies(self):
+ expected = {
+ "release": ["fcitx5-frontend-gtk3", "ibus-gtk3", "libwebkit2gtk-4.1-dev",
+ "libgtk-3-dev", "libappindicator3-dev", "librsvg2-dev", "patchelf",
+ "libssl-dev", "xdg-utils", "lld"],
+ "node-release": ["libfontconfig1-dev", "libsecret-1-dev"],
+ "fontconfig": ["libfontconfig1-dev"],
+ "preview": ["ffmpeg", "fonts-noto-cjk", "fonts-noto-color-emoji"],
+ }
+ for group, packages in expected.items():
+ with self.subTest(group=group):
+ self.calls.clear()
+ self.execute([OK, OK, OK], group)
+ self.assertEqual(self.calls[1][0], ["--download-only", "install", "-y", *packages])
+ self.assertEqual(self.calls[2][0], ["--no-download", "install", "-y", *packages])
+
+ def test_arm_sources_never_switch_to_amd64_archive(self):
+ for source in [
+ "deb http://ports.ubuntu.com/ubuntu-ports jammy main universe\n",
+ "Types: deb\nURIs: http://ports.ubuntu.com/ubuntu-ports/\nSuites: noble noble-security\nComponents: main\nSigned-By: /keyring\n",
+ ]:
+ with self.subTest(source=source):
+ self.source.write_text(source)
+ calls = []
+ responses = iter([TIMEOUT, OK, OK, OK])
+ def run(arguments, budget):
+ calls.append((arguments, self.source.read_text()))
+ return next(responses)
+ with patch.object(deps, "run_apt", side_effect=run):
+ deps.install(self.source, "release")
+ self.assertEqual(self.source.read_text(), source)
+ self.assertIn(deps.PORT_MIRRORS[0][1], calls[0][1])
+ self.assertIn(deps.PORT_MIRRORS[1][1], calls[1][1])
+ self.assertTrue(all("archive.ubuntu.com" not in text for _args, text in calls))
+
+ def test_default_source_selects_existing_runner_format(self):
+ legacy = Path(self.directory.name) / "sources.list"
+ legacy.write_text("deb http://archive.ubuntu.com/ubuntu jammy main\n")
+ with patch.object(deps, "SOURCES", Path(self.directory.name) / "missing.sources"), \
+ patch.object(deps, "LEGACY_SOURCES", legacy), \
+ patch.object(deps, "run_apt", return_value=OK):
+ deps.install(group="packaging")
+ self.assertEqual(legacy.read_text(), "deb http://archive.ubuntu.com/ubuntu jammy main\n")
+
+ def test_release_workflows_use_bounded_installer_from_their_checkout(self):
+ workflows = SCRIPT.parent.parent / "workflows"
+ expected = {
+ "release.yml": {"release": 1},
+ "agents-release.yml": {"packaging": 3},
+ "mcp-release.yml": {"node-release": 1, "fontconfig": 2},
+ "ui-preview.yml": {"preview": 1},
+ }
+ for filename, groups in expected.items():
+ content = (workflows / filename).read_text(encoding="utf-8")
+ with self.subTest(workflow=filename):
+ self.assertNotIn("sudo apt-get", content)
+ for group, count in groups.items():
+ self.assertEqual(content.count("ci-install-system-deps.py --group " + group + "\n"), count)
+ agents = (workflows / "agents-release.yml").read_text(encoding="utf-8")
+ jre = agents.split("\n build-jre:", 1)[1].split("\n reuse-previous-assets:", 1)[0]
+ self.assertLess(jre.index("uses: actions/checkout@"), jre.index("ci-install-system-deps.py"))
+ preview = (workflows / "ui-preview.yml").read_text(encoding="utf-8")
+ trusted_checkout = preview.split("path: ci", 1)[1].split("persist-credentials:", 1)[0]
+ self.assertIn(".github/scripts", trusted_checkout)
+ self.assertIn("ref: ${{ github.event.repository.default_branch }}", preview)
+ self.assertIn("working-directory: ci/.github/ui-preview", preview)
+ self.assertIn("sudo python3 ../scripts/ci-install-system-deps.py --group preview", preview)
+
def test_timeout_or_network_failure_switches_once_and_reuses_cache(self):
for failure in [TIMEOUT, NETWORK]:
with self.subTest(failure=failure):
diff --git a/.github/workflows/agents-release.yml b/.github/workflows/agents-release.yml
index a1fae94532..b277eede5b 100644
--- a/.github/workflows/agents-release.yml
+++ b/.github/workflows/agents-release.yml
@@ -1284,6 +1284,7 @@ jobs:
java-version: "21"
modules: "java.base,java.sql,java.sql.rowset,java.naming,java.management,java.desktop,java.security.jgss,java.security.sasl,jdk.security.auth,jdk.security.jgss,jdk.charsets,jdk.unsupported,java.scripting,java.compiler,jdk.crypto.ec"
steps:
+ - uses: actions/checkout@v7
- uses: actions/setup-java@v6
with:
distribution: temurin
@@ -1291,8 +1292,7 @@ jobs:
- name: Build JRE for all platforms
shell: bash
run: |
- sudo apt-get update
- sudo apt-get install -y zstd
+ sudo python3 .github/scripts/ci-install-system-deps.py --group packaging
MODULES="${{ matrix.modules }}"
JLINK_OPTS="--strip-debug --no-header-files --no-man-pages --compress=zip-6"
JRE_KEY="${{ matrix.jre-key }}"
@@ -1358,8 +1358,7 @@ jobs:
- uses: actions/checkout@v7
- name: Install artifact tools
run: |
- sudo apt-get update
- sudo apt-get install -y zstd
+ sudo python3 .github/scripts/ci-install-system-deps.py --group packaging
- name: Download and verify previous release artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -1414,8 +1413,7 @@ jobs:
- name: Install artifact tools
run: |
- sudo apt-get update
- sudo apt-get install -y zstd
+ sudo python3 .github/scripts/ci-install-system-deps.py --group packaging
- name: Flatten artifacts
run: |
diff --git a/.github/workflows/mcp-release.yml b/.github/workflows/mcp-release.yml
index 53b7c051ca..b3bd3caea3 100644
--- a/.github/workflows/mcp-release.yml
+++ b/.github/workflows/mcp-release.yml
@@ -51,8 +51,7 @@ jobs:
- name: Install native build dependencies
run: |
- sudo apt-get update
- sudo apt-get install -y libfontconfig1-dev libsecret-1-dev
+ sudo python3 .github/scripts/ci-install-system-deps.py --group node-release
- name: Install dependencies
run: pnpm install --frozen-lockfile
@@ -407,8 +406,7 @@ jobs:
- name: Install Linux native dependencies
if: runner.os == 'Linux'
run: |
- sudo apt-get update
- sudo apt-get install -y libfontconfig1-dev
+ sudo python3 .github/scripts/ci-install-system-deps.py --group fontconfig
- name: Setup Python for cargo-zigbuild
if: runner.os == 'Linux'
@@ -660,8 +658,7 @@ jobs:
- name: Install Linux native dependencies
if: runner.os == 'Linux'
run: |
- sudo apt-get update
- sudo apt-get install -y libfontconfig1-dev
+ sudo python3 .github/scripts/ci-install-system-deps.py --group fontconfig
- name: Setup Python for cargo-zigbuild
if: runner.os == 'Linux'
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 7c5b9b77d6..50d807b08b 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -254,10 +254,9 @@ jobs:
- name: Install system dependencies (Linux)
if: startsWith(matrix.platform, 'ubuntu')
run: |
- sudo apt-get update
# Bundle GTK input-method modules from the same Jammy ABI baseline
# instead of loading potentially incompatible modules from the host.
- sudo apt-get install -y fcitx5-frontend-gtk3 ibus-gtk3 libwebkit2gtk-4.1-dev libgtk-3-dev libappindicator3-dev librsvg2-dev patchelf libssl-dev xdg-utils lld
+ sudo python3 .github/scripts/ci-install-system-deps.py --group release
# The ARM hosted runner has 16 GB RAM and no swap; the serialized
# release build plus the final lld link of the dbx binary still
# exhausts memory and the runner loses communication with the
diff --git a/.github/workflows/ui-preview.yml b/.github/workflows/ui-preview.yml
index 38d4b26519..35e76088da 100644
--- a/.github/workflows/ui-preview.yml
+++ b/.github/workflows/ui-preview.yml
@@ -94,7 +94,9 @@ jobs:
with:
ref: ${{ github.event.repository.default_branch }}
path: ci
- sparse-checkout: .github/ui-preview
+ sparse-checkout: |
+ .github/ui-preview
+ .github/scripts
persist-credentials: false
# the fork's code, on purpose: this job is the one meant to run it,
# with a read-only token and no credentials left in the checkout
@@ -145,8 +147,7 @@ jobs:
- name: Chromium, ffmpeg and fonts
working-directory: ci/.github/ui-preview
run: |
- sudo apt-get update
- sudo apt-get install -y ffmpeg fonts-noto-cjk fonts-noto-color-emoji
+ sudo python3 ../scripts/ci-install-system-deps.py --group preview
npm install --no-audit --no-fund
npx playwright install --with-deps chromium
- name: Record