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): serialize contributor PR runs with repository owner exemption

t8y211974accdbac
diff --git a/.github/scripts/ci-guide.md b/.github/scripts/ci-guide.md
index 556bca9491..4845b8538a 100644
--- a/.github/scripts/ci-guide.md
+++ b/.github/scripts/ci-guide.md
@@ -2,14 +2,35 @@
Paths in this guide are relative to `.github/`.
-`workflows/ci.yml` retains one workflow and one cancellation group. Splitting jobs
-does not change release workflows or branch-protection settings. The existing
+`workflows/ci.yml` retains one workflow. Splitting jobs does not change release
+workflows or branch-protection settings. The existing
`rust` and `agents` aggregate check names remain; `ci` additionally summarizes all
selected jobs. None of these gates accepts a failed, cancelled, missing, or
unexpectedly skipped prerequisite. The gates are guarded by
-`if: always() && !cancelled()`: on a superseded commit a newer push cancels the
-run, and `always()` alone would still execute the gate and report those
-cancellations as a failure of the commit that no longer matters.
+`if: always() && !cancelled()`: on a cancelled run, `always()` alone would still
+execute the gate and report cancelled prerequisites as a failure.
+
+## Contributor concurrency
+
+PRs from anyone other than the repository owner share a main `CI` concurrency
+group keyed by the PR author's stable numeric user ID. Only one run in that
+author's group executes at a time; other authors have independent groups.
+The PR author, not the trigger actor or author association, determines this
+policy, so a maintainer retrigger cannot bypass contributor limits.
+`cancel-in-progress: false` preserves the executing PR, and `queue: max` retains
+up to 100 pending runs rather than replacing earlier pending PRs. Further runs
+beyond that limit are cancelled by GitHub. Updates to the same contributor PR
+also enqueue separate runs; this policy does not deduplicate superseded commits.
+
+The repository owner (`t8y2` here, compared with `github.repository_owner`) is
+exempt from author-level limits. Owner PRs retain one cancellation group per PR,
+so separate owner PRs run independently and a new commit cancels that PR's old
+run. Main pushes retain their independent ref-based cancellation group. These
+paths use `queue: single`, never `queue: max` with in-progress cancellation.
+
+This limits main CI workflow runs, not the runner count inside one selected PR.
+Other PR workflows and all release workflows remain unchanged. Existing runs
+retain their original workflow configuration until a new event uses this policy.
## Selection
diff --git a/.github/scripts/ci-workflow.test.mjs b/.github/scripts/ci-workflow.test.mjs
index 834fbb6e6a..f5bb9c972d 100644
--- a/.github/scripts/ci-workflow.test.mjs
+++ b/.github/scripts/ci-workflow.test.mjs
@@ -15,6 +15,59 @@ function job(name, content = workflow) {
return jobs.slice(definitions[index].index, definitions[index + 1]?.index ?? jobs.length);
}
+function concurrencySettings(github) {
+ const block = workflow.match(/^concurrency:\n((?: [^\n]+\n)+)/m)?.[1];
+ assert.ok(block, "missing workflow concurrency");
+ const format = (template, value) => template.replace("{0}", String(value));
+ return Object.fromEntries(block.trim().split("\n").map((line) => {
+ const [, setting, value] = line.match(/^\s*([\w-]+):\s*(.+)$/);
+ const evaluate = (expression) => new Function("github", "format", `return (${expression});`)(github, format);
+ const expressions = [...value.matchAll(/\$\{\{\s*(.*?)\s*\}\}/g)];
+ return [setting, expressions.length === 1 && expressions[0][0] === value
+ ? evaluate(expressions[0][1]) : value.replace(/\$\{\{\s*(.*?)\s*\}\}/g, (_, expression) => evaluate(expression))];
+ }));
+}
+
+function concurrencyContext({ authorId = 101, author = "contributor", actor = author, ref = "refs/pull/100/merge", eventName = "pull_request" } = {}) {
+ return { workflow: "CI", repository_owner: "t8y2", actor, ref, event_name: eventName,
+ event: eventName === "pull_request" ? { pull_request: { user: { id: authorId, login: author } } } : {} };
+}
+
+test("a contributor shares one main CI queue across all PRs regardless of trigger actor", () => {
+ const settings = concurrencySettings(concurrencyContext());
+ assert.deepEqual(settings, { group: "CI-pr-author-101", "cancel-in-progress": false, queue: "max" });
+ for (const context of [concurrencyContext({ ref: "refs/pull/200/merge" }), concurrencyContext({ actor: "t8y2" }),
+ concurrencyContext({ actor: "github-actions[bot]" }), concurrencyContext({ author: "renamed-contributor" })]) {
+ assert.deepEqual(concurrencySettings(context), settings);
+ }
+ assert.notEqual(concurrencySettings(concurrencyContext({ authorId: 102, author: "another-contributor" })).group, settings.group);
+});
+
+test("repository-owner PRs remain independent and superseded runs are cancelled only within a PR", () => {
+ const first = concurrencySettings(concurrencyContext({ authorId: 1, author: "t8y2" }));
+ const second = concurrencySettings(concurrencyContext({ authorId: 1, author: "t8y2", ref: "refs/pull/200/merge" }));
+ assert.deepEqual(first, { group: "CI-refs/pull/100/merge", "cancel-in-progress": true, queue: "single" });
+ assert.notEqual(first.group, second.group);
+ assert.deepEqual(concurrencySettings(concurrencyContext({ authorId: 1, author: "t8y2", actor: "another-contributor" })), first);
+});
+
+test("main pushes retain their independent cancellation group without PR context", () => {
+ const main = concurrencySettings(concurrencyContext({ eventName: "push", ref: "refs/heads/main", actor: "github-actions[bot]" }));
+ assert.deepEqual(main, { group: "CI-refs/heads/main", "cancel-in-progress": true, queue: "single" });
+ assert.notEqual(main.group, concurrencySettings(concurrencyContext()).group);
+});
+
+test("expanded author queues never combine max queuing with in-progress cancellation", () => {
+ for (const context of [concurrencyContext(), concurrencyContext({ author: "t8y2" }),
+ concurrencyContext({ eventName: "push", ref: "refs/heads/main" })]) {
+ const settings = concurrencySettings(context);
+ assert.ok(settings.queue === "single" || settings.queue === "max");
+ assert.equal(settings.queue === "max" && settings["cancel-in-progress"], false);
+ }
+ const concurrency = workflow.match(/^concurrency:\n((?: [^\n]+\n)+)/m)[1];
+ assert.doesNotMatch(concurrency, /github\.actor|author_association/);
+});
+
test("fast checks run format and contracts before graph resolution or compilation", () => {
const fast = job("fast-checks");
for (const command of ["cargo fmt --check", "node --test scripts/core-architecture.test.mjs", "node scripts/sync-connection-types.mjs --check", "node .github/scripts/ci-lockfiles.mjs", "node .github/scripts/ci-rust-coverage.mjs"]) assert.ok(fast.includes(command));
@@ -295,7 +348,7 @@ test("Win7 TLS cache keys ignore the workspace lockfile", () => {
assert.doesNotMatch(win7, /key: win7-(?:aws-lc|openssl).*hashFiles\('Cargo\.lock'/);
});
-test("path filtering and the planner use the exact test merge first parent and preserve cancellation scope", () => {
+test("path filtering and the planner use the exact test merge first parent", () => {
const changes = job("changes");
assert.ok(changes.includes("BEFORE_SHA: ${{ github.event.before }}"));
assert.ok(changes.includes('BASE_SHA="$(node .github/scripts/ci-change-base.mjs)"'));
@@ -312,6 +365,4 @@ test("path filtering and the planner use the exact test merge first parent and p
assert.ok(changes.includes(`steps.plan.outputs.${flag}`));
}
assert.doesNotMatch(changes, /steps\.filter\.outputs\.windows_win7_bundle|github\.event\.pull_request\.base\.sha|WIN7_CURRENT/);
- assert.ok(workflow.includes("group: ${{ github.workflow }}-${{ github.ref }}"));
- assert.ok(workflow.includes("cancel-in-progress: true"));
});
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4c99c2e8a1..97f5c40ecd 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -10,8 +10,9 @@ on:
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.user.login != github.repository_owner && format('pr-author-{0}', github.event.pull_request.user.id) || github.ref }}
+ cancel-in-progress: ${{ github.event_name != 'pull_request' || github.event.pull_request.user.login == github.repository_owner }}
+ queue: ${{ github.event_name == 'pull_request' && github.event.pull_request.user.login != github.repository_owner && 'max' || 'single' }}
env:
RUSTFLAGS: -C debuginfo=line-tables-only