Skip to content

Commit

Permalink
Add sub-check cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Jan 17, 2025
1 parent c81ff78 commit cc7d5f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install dependencies
run: npm install

- name: Create checks
- name: Create sub-checks
run: npx zci init

- name: Formatting
Expand Down Expand Up @@ -65,3 +65,7 @@ jobs:

- name: Report coverage
run: npx zenfs-test --report

- name: Cleanup sub-checks
if: always()
run: npx zci cleanup
15 changes: 10 additions & 5 deletions scripts/ci-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@ if (options.help || !subcommand) {
console.log(`Usage:
zci [-h | --help] Show this help message
zci init Create checks in a queued state
zci cleanup Mark all remaining checks are completed with a neutral status
zci run <name> <cmd> Run a command and use its exit code as the completion status
zci list List checks`);
process.exit();
}

const ciNames = Object.entries(ci.checkNames);

switch (subcommand) {
case 'init':
for (const [id, name] of ciNames) {
for (const [id, name] of Object.entries(ci.checkNames)) {
await ci.createCheck(id, name);
}
break;
case 'list': {
const max = Math.max(...ciNames.map(([id]) => id.length)) + 1;
for (const [id, name] of ciNames) {
const max = Math.max(...Object.keys(ci.checkNames).map(id => id.length)) + 1;
for (const [id, name] of Object.entries(ci.checkNames)) {
console.log(id.padEnd(max), name);
}
break;
Expand All @@ -48,6 +47,12 @@ switch (subcommand) {

process.exit(status);
}
case 'cleanup': {
for (const id of Object.keys(ci.checkNames)) {
await ci.completeCheck(id, 'neutral');
}
break;
}
default:
console.error('Unknown subcommand:', subcommand);
process.exit(1);
Expand Down
1 change: 1 addition & 0 deletions scripts/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ export async function completeCheck(id, conclusion, title = '', summary = '') {
conclusion,
output: { title, summary },
});
check.completed = true;
}

0 comments on commit cc7d5f5

Please sign in to comment.