mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-22 08:01:32 +01:00
fix: gstack-skill-end releases its run on the workflow lease, so a finished /ship stops blocking gstack-upgrade (GST-1205)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
c197a139b7
commit
03ada799e8
8 files changed
+100
-22
No files matched your search
@@ -91,7 +91,7 @@ describe('gstack-lease', () => {
|
||||
const r = spawnSync('bash', ['-n', LEASE], { encoding: 'utf8', timeout: 30_000 });
|
||||
expect(r.status, r.stderr).toBe(0);
|
||||
const help = spawnSync('bash', [LEASE, '--help'], { encoding: 'utf8', timeout: 30_000 });
|
||||
expect(help.stdout).toContain('print `<pid> <age>m alive|dead|stale` for every lease');
|
||||
expect(help.stdout).toContain('print `<pid> <age>m alive|idle|dead|stale` for every lease');
|
||||
});
|
||||
|
||||
test('touch writes <git dir>/gstack-leases/<pid> for --pid and prunes leases older than 120 minutes', () => {
|
||||
@@ -716,6 +716,30 @@ describe('gstack-lease', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// GST-1205: gstack-skill-end releases the run gstack-skill-start opened, so a finished run stops holding the lease.
|
||||
test('gstack-skill-start opens a run on the lease and gstack-skill-end with its SESSION_ID releases it; another holder still counts', () => {
|
||||
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-lease-home-'));
|
||||
const state = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-lease-state-'));
|
||||
dirs.push(home, state);
|
||||
fs.writeFileSync(path.join(state, 'config.yaml'), 'update_check: false\n');
|
||||
const leaseDir = path.join(state, 'leases');
|
||||
const env = { PATH: process.env.PATH!, HOME: home, GSTACK_HOME: state, GSTACK_LEASE_DIR: leaseDir };
|
||||
const holder = sleeper();
|
||||
const start = spawnSync(START, ['--skill', 'ship', '--parent-pid', String(holder)], { encoding: 'utf8', cwd: home, env, timeout: 30_000 });
|
||||
expect(start.status, start.stdout + start.stderr).toBe(0);
|
||||
const sid = start.stdout.match(/^SESSION_ID: (\S+)$/m)?.[1] ?? '';
|
||||
expect(sid.startsWith(`${holder}-`), sid).toBe(true);
|
||||
expect(run(['live'], env).status).toBe(0);
|
||||
const end = spawnSync(path.join(REPO, 'bin/gstack-skill-end'), ['--skill', 'ship', '--outcome', 'success', '--session-id', sid, '--tel-start', '0'], { encoding: 'utf8', cwd: home, env, timeout: 30_000 });
|
||||
expect(end.status, end.stdout + end.stderr).toBe(0);
|
||||
const after = run(['live'], env);
|
||||
expect(after.status, after.stdout + after.stderr).toBe(1);
|
||||
expect(run(['list'], env).stdout).toMatch(new RegExp(`^${holder} \\d+m idle$`, 'm'));
|
||||
const other = sleeper();
|
||||
expect(run(['touch', '--pid', String(other)], env).status).toBe(0);
|
||||
expect(run(['live'], env).stdout).toMatch(new RegExp(`^${other} \\d+m sleep$`, 'm'));
|
||||
});
|
||||
|
||||
test('gstack-skill-start reports a lease the held lock kept from being written, and still starts', () => {
|
||||
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-lease-home-'));
|
||||
const state = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-lease-state-'));
|
||||
|
||||
Reference in new issue
Block a user