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
8 changes: 8 additions & 0 deletions scripts/ci/test_ci_monitor.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ result = run(['runs', '--repo', 'RandomCodeSpace/kb', '--branch', 'main', '--lim
assert.equal(result.status, 0, result.stderr);
assert.deepEqual(readFileSync(log, 'utf8').trim().split('\n'), ['run', 'list', '--limit', '5', '--branch', 'main', '-R', 'RandomCodeSpace/kb']);

result = run(['runs', '--repo', 'RandomCodeSpace/kb'], { CI_MONITOR_GH: 'gh' });
assert.equal(result.status, 2);
assert.match(result.stderr, /CI_MONITOR_GH must be an absolute path/);

result = run(['runs'], { CI_MONITOR_GIT: 'git', GITHUB_REPOSITORY: '' });
assert.equal(result.status, 2);
assert.match(result.stderr, /CI_MONITOR_GIT must be an absolute path/);

result = run(['check-actions']);
assert.equal(result.status, 0, result.stderr);
assert.match(result.stdout, /immutable SHAs/);
Expand Down
17 changes: 13 additions & 4 deletions scripts/ci_monitor.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

const { execFileSync, spawnSync } = require('node:child_process');
const { existsSync, readFileSync, readdirSync } = require('node:fs');
const { join } = require('node:path');
const { isAbsolute, join } = require('node:path');

const HELP = `usage: node scripts/ci_monitor.cjs <command> [arguments]

Expand All @@ -28,6 +28,12 @@ function die(message) {
process.exit(2);
}

function executable(envName, fallback) {
const value = process.env[envName] || fallback;
if (!isAbsolute(value)) die(`${envName} must be an absolute path`);
return value;
}

function extractOption(args, name, fallback) {
const index = args.indexOf(name);
if (index < 0) return fallback;
Expand All @@ -45,7 +51,11 @@ function repository(args) {
}
let remote;
try {
remote = execFileSync('git', ['remote', 'get-url', 'origin'], { encoding: 'utf8' }).trim();
remote = execFileSync(
executable('CI_MONITOR_GIT', '/usr/bin/git'),
['remote', 'get-url', 'origin'],
{ encoding: 'utf8' },
).trim();
} catch {
die('cannot detect repository; pass --repo OWNER/REPO');
}
Expand All @@ -55,8 +65,7 @@ function repository(args) {
}

function gh(repo, args, capture = false) {
const executable = process.env.CI_MONITOR_GH || 'gh';
const result = spawnSync(executable, [...args, '-R', repo], {
const result = spawnSync(executable('CI_MONITOR_GH', '/usr/bin/gh'), [...args, '-R', repo], {
encoding: 'utf8',
stdio: capture ? ['ignore', 'pipe', 'pipe'] : 'inherit',
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/outbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export class MetadataOutbox {
const key = this.storage.key(i);
if (key && namespaceStorageSuffix(PREFIX, this.ns, key) !== null) keys.push(key);
}
return keys.sort();
return keys.sort((left, right) => left.localeCompare(right));
}

private async locked<T>(fn: () => T | Promise<T>): Promise<T | undefined> {
Expand Down