Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/scripts/d1-prepare-migrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# prefixed — TABLE_PREFIX is in use; migrations/*.sql are not prefix-aware,
# so d1-prefixed-migrations.sh applies the setup-route migrations
#
# Three-state TABLE_PREFIX (unset → 'sl', '' → no prefix, other → as-is) is
# Three-state TABLE_PREFIX (unset → 'hop', '' → no prefix, other → as-is) is
# resolved by the deploy workflow before this script runs; a silent switch
# (database already initialised under a different prefix) aborts with an error.
#
Expand All @@ -33,7 +33,7 @@ if [[ "$location" != remote && "$location" != local ]]; then
fi

# Three-state resolution: the deploy workflow already resolves vars.TABLE_PREFIX
# (none → '', unset/empty → 'sl') before calling this script. When invoked
# (none → '', unset/empty → 'hop') before calling this script. When invoked
# directly with TABLE_PREFIX unset, resolve it to the project default.
# `${TABLE_PREFIX+x}` is empty when unset and 'x' when set (even to ''), which
# is portable across bash 3.x and 5.x.
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/resolve-table-prefix.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GitHub Actions `vars.TABLE_PREFIX` cannot distinguish "unset" from "empty",
// so the deploy workflow uses a reserved word to preserve the three runtime
// states:
// unset / empty → DEFAULT_TABLE_PREFIX ('sl')
// unset / empty → DEFAULT_TABLE_PREFIX ('hop')
// 'none' → '' (explicit no prefix; the deployer accepts the
// table-collision risk)
// anything else → as-is
Expand Down
6 changes: 3 additions & 3 deletions .github/scripts/test-d1-migrations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ const scripts = fileURLToPath(new URL('.', import.meta.url));
const worker = fileURLToPath(new URL('../../apps/worker/', import.meta.url));

function fixture(t) {
const cwd = mkdtempSync(join(tmpdir(), 'Hop-d1-test-'));
const cwd = mkdtempSync(join(tmpdir(), 'hop-d1-test-'));
t.after(() => rmSync(cwd, { recursive: true, force: true }));
writeFileSync(join(cwd, 'package.json'), '{"private":true}');
writeFileSync(
join(cwd, 'wrangler.toml'),
`name = "Hop-migration-test"
`name = "hop-migration-test"
compatibility_date = "2025-04-01"
[[d1_databases]]
binding = "DB"
database_name = "Hop-test"
database_name = "hop-test"
database_id = "00000000-0000-0000-0000-000000000000"
migrations_dir = "migrations"
`,
Expand Down
10 changes: 5 additions & 5 deletions .github/scripts/test-deploy-checks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const scripts = fileURLToPath(new URL('.', import.meta.url));
const exec = promisify(execFile);

function fixture(t) {
const dir = mkdtempSync(join(tmpdir(), 'Hop-deploy-test-'));
const dir = mkdtempSync(join(tmpdir(), 'hop-deploy-test-'));
t.after(() => rmSync(dir, { recursive: true, force: true }));
// 仅跳过重试等待,不替换 curl 或 jq。
writeFileSync(join(dir, 'sleep'), '#!/bin/sh\nexit 0\n', { mode: 0o755 });
Expand Down Expand Up @@ -159,8 +159,8 @@ esac
// ─── CI 三态解析(none 约定)─────────────────────────────────────────────────

for (const scenario of [
{ name: 'vars 未设 → 默认 sl', env: undefined, expected: 'sl' },
{ name: 'vars 为空 → 默认 sl', env: '', expected: 'sl' },
{ name: 'vars 未设 → 默认 hop', env: undefined, expected: 'hop' },
{ name: 'vars 为空 → 默认 hop', env: '', expected: 'hop' },
{ name: 'vars 为保留字 none → 空字符串', env: 'none', expected: '' },
{ name: 'vars 为其他值 → 原样(含大小写)', env: 'SL', expected: 'SL' },
]) {
Expand All @@ -184,7 +184,7 @@ for (const scenario of [
});
}

test('worker-table-prefix.sh:未设置绑定 → 默认 sl', (t) => {
test('worker-table-prefix.sh:未设置绑定 → 默认 hop', (t) => {
const f = fixture(t);
writeFileSync(
join(f.dir, 'pnpm'),
Expand All @@ -202,5 +202,5 @@ esac
[join(scripts, 'worker-table-prefix.sh'), 'v1'],
{ env: f.env, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] },
);
assert.equal(out, 'sl');
assert.equal(out, 'hop');
});
2 changes: 1 addition & 1 deletion .github/scripts/verify-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ done
live="$(bash "$here/worker-table-prefix.sh" "$version")"
live="${live//[^A-Za-z0-9_]/}"
# worker-table-prefix.sh already maps an unset Worker binding to the default
# 'sl'; compare literally (case-sensitive) so e.g. production `SL` is never
# 'hop'; compare literally (case-sensitive) so e.g. production `SL` is never
# folded into `sl` and reported as a false match.
expected="${TABLE_PREFIX:-}"
if [[ "$live" != "$expected" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/worker-table-prefix.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Prints the effective TABLE_PREFIX of a deployed Worker version. When the
# Worker has no TABLE_PREFIX binding, the project default ('sl') is printed —
# Worker has no TABLE_PREFIX binding, the project default ('hop') is printed —
# matching the runtime three-state resolution in src/lib/table-prefix.ts.
# Run from apps/worker (needs wrangler.toml with real IDs injected).
#
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Inject resource IDs
env:
D1_DATABASE_ID: ${{ vars.D1_DATABASE_ID }}
D1_DATABASE_NAME: ${{ vars.D1_DATABASE_NAME || 'Hop' }}
D1_DATABASE_NAME: ${{ vars.D1_DATABASE_NAME || 'shortlink' }}
KV_NAMESPACE_ID: ${{ vars.KV_NAMESPACE_ID }}
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
run: |
Expand Down
Loading
Loading