mirror of
https://github.com/bitbaum/fleet.git
synced 2026-12-04 04:47:24 +01:00
* fix(packages): tell the fleet about a release once its tag exists release-notify.yml asks on CI completion, but a version bump merged by pull request is tagged by git-release.yml seconds later, so the notice found no tag and stood down. Publish cannot repeat it (GITHUB_TOKEN runs chain no further). ai-kit 1.26-1.28 reached consumers only on the six-hourly schedule. A new template workflow, release-notify-tagged.yml, asks again when the tag workflow completes; the template sync adds it to every package repo. Its step is release-notify.yml's, held equal by the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtUQb9BM11ycpApwGq * fix(currency): a merge of main into the bump branch is not a repair Any non-bot commit on fleet/internal-currency counted as a person's repair, so the updater preserved it and stopped refreshing the pull request. A plain "Merge branch 'main'" commit carries nothing a fresh branch from main lacks; once main moved on, evig#682 and solon#398 sat in conflict since 6-10 Nov and both apps stayed behind. Such a merge (two parents, the default branch, the merge subjects git and GitHub write) is now replaceable; any other merge or commit is still preserved, and a branch with no bump commit is not the bot's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmtUQb9BM11ycpApwGq --------- Co-authored-by: Claude <noreply@anthropic.com>
43 lines
3.4 KiB
JavaScript
43 lines
3.4 KiB
JavaScript
import { mkdtempSync, writeFileSync, readFileSync, rmSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
import assert from 'node:assert/strict';
|
|
|
|
const workflow = new URL('../../templates/package/.github/workflows/release-notify.yml', import.meta.url);
|
|
const script = execFileSync('python3', ['-c', 'import yaml,sys; print(yaml.safe_load(open(sys.argv[1]))["jobs"]["notify"]["steps"][0]["run"])', workflow.pathname], {encoding:'utf8'});
|
|
const dir = mkdtempSync(join(tmpdir(), 'release-notify-'));
|
|
try {
|
|
writeFileSync(join(dir,'gh'), `#!/usr/bin/env node
|
|
const args=process.argv.slice(2), f=JSON.parse(process.env.FIXTURE);
|
|
if(args.includes('--method')) {require('node:fs').writeFileSync(process.env.POST,require('node:fs').readFileSync(0)); process.exit(0);}
|
|
if(args[1].includes('/contents/')) console.log(Buffer.from(JSON.stringify({version:f.version})).toString('base64'));
|
|
else if(args[1].includes('/commits/')) {if(!f.tagged) process.exit(1); console.log(f.tagged);}
|
|
else if(args[1].includes('/actions/runs?')) console.log(f.ci);
|
|
else throw new Error('Unexpected API request: '+args.join(' '));
|
|
`, {mode:0o755});
|
|
const sha='a'.repeat(40), valid={version:'0.7.2',tagged:sha,ci:'success'};
|
|
const run=(fixture,token='synthetic-maintenance-token')=>{
|
|
rmSync(join(dir,'post'),{force:true});
|
|
return spawnSync('bash',['-euo','pipefail','-c',script],{encoding:'utf8',env:{...process.env,PATH:dir+':'+process.env.PATH,FIXTURE:JSON.stringify(fixture),SHA:sha,GH_REPO:'bitbaum/accountkit',FLEET_TOKEN:token,POST:join(dir,'post'),GITHUB_STEP_SUMMARY:join(dir,'summary')}});
|
|
};
|
|
for(const fixture of [{...valid,version:'0.7.2-beta.1'},{...valid,tagged:null},{...valid,tagged:'b'.repeat(40)},{...valid,ci:'failure'},{...valid,ci:'null'}]) {
|
|
const result=run(fixture); assert.equal(result.status,0,result.stderr);
|
|
assert.throws(()=>readFileSync(join(dir,'post')));
|
|
}
|
|
assert.equal(run(valid,'').status,1,'missing cross-repo authority must be visible');
|
|
const result=run(valid);assert.equal(result.status,0,result.stderr);
|
|
assert.deepEqual(JSON.parse(readFileSync(join(dir,'post'),'utf8')),{event_type:'shared-package-release',client_payload:{repository:'bitbaum/accountkit',version:'0.7.2',commit:sha}});
|
|
console.log('7 release-notification scenarios pass: only verified tagged releases notify; missing authority fails visibly.');
|
|
|
|
// The second notice (release-notify-tagged.yml) runs once the tag exists. It
|
|
// is only a fix while it asks the same question, on the tag workflow's name.
|
|
const yamlOf = file => JSON.parse(execFileSync('python3', ['-c', 'import yaml,sys,json; print(json.dumps(yaml.safe_load(open(sys.argv[1])), default=str))', new URL(`../../templates/package/.github/workflows/${file}`, import.meta.url).pathname], {encoding:'utf8'}));
|
|
const tagged = yamlOf('release-notify-tagged.yml');
|
|
const tagger = yamlOf('git-release.yml');
|
|
assert.equal(tagged.jobs.notify.steps[0].run.trimEnd(), script.trimEnd(), 'release-notify-tagged.yml must run release-notify.yml\'s step unchanged');
|
|
assert.deepEqual(tagged.true.workflow_run.workflows, [tagger.name], 'it must listen to the workflow that creates the tag');
|
|
assert.match(tagged.jobs.notify.if, /conclusion == 'success'/);
|
|
console.log('the tagged notice asks the same question, after the tag workflow.');
|
|
} finally {rmSync(dir,{recursive:true,force:true});}
|