-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env node | ||
import { parseArgs } from 'node:util'; | ||
import * as ci from './ci.js'; | ||
|
||
const { values: options, positionals } = parseArgs({ | ||
options: { | ||
create: { type: 'boolean', default: false }, | ||
start: { type: 'boolean', default: false }, | ||
complete: { type: 'string' }, | ||
help: { short: 'h', type: 'boolean', default: false }, | ||
exit: { short: 'e', type: 'boolean', default: false }, | ||
}, | ||
allowPositionals: true, | ||
}); | ||
|
||
if (options.help) { | ||
console.log(`Usage: zenfs-ci [options] <check names...> | ||
Options: | ||
-R, --run <command> Run a command and use that for statuses. Implies --exit | ||
--create Create check(s) in a queued state for all positional check names | ||
--start Move check(s) from queued to in_progress | ||
--complete <status> Complete the check(s) with a conclusion: success, failure, etc. | ||
-e, --exit Set the exit code based on the status of --complete | ||
-h, --help Show this help message`); | ||
process.exit(); | ||
} | ||
|
||
for (const name of positionals) { | ||
if (options.create) await ci.createCheck(name); | ||
if (options.start) await ci.startCheck(name); | ||
if (options.complete) await ci.completeCheck(name, options.complete); | ||
if (options.complete && options.exit) process.exitCode = +(options.complete == 'failure'); | ||
if (options.run) { | ||
await ci.startCheck(name); | ||
|
||
const result = spawnSync(options.run, { shell: true, stdio: 'inherit' }); | ||
const exitCode = result.status; | ||
|
||
await ci.completeCheck(name, exitCode ? 'failure' : 'success'); | ||
|
||
if (!exitCode) process.exitCode = exitCode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters