Skip to content

Commit

Permalink
Fix #49: Hide most output behind output groups
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-carlborg committed Mar 4, 2023
1 parent 60f0906 commit 051bf5e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
17 changes: 16 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/action/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class Action {
}

async run(): Promise<void> {
core.startGroup('Setting up VM')
core.debug('Running action')
const [diskImagePath, hypervisorArchivePath, resourcesArchivePath] =
await Promise.all([
Expand Down Expand Up @@ -117,12 +118,15 @@ export class Action {
)
core.info('VM is ready')
try {
core.endGroup()
await this.runCommand(vm)
} finally {
core.startGroup('Tearing down VM')
await this.syncBack(vm.ipAddress)
await vm.stop()
}
} finally {
core.endGroup()
await vm.terminate()
fs.rmdirSync(this.tempPath, {recursive: true})
}
Expand Down
10 changes: 10 additions & 0 deletions src/utility.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as exec from '@actions/exec'
import * as core from '@actions/core'

export type Class<T> = new (...args: any[]) => T

Expand Down Expand Up @@ -52,3 +53,12 @@ export function getImplementation<T>(
const name = object.constructor.name.toLocaleLowerCase()
return getOrDefaultOrThrow(implementation, name)
}

export function group(name: string, block: () => void): void {
try {
core.startGroup(name)
block()
} finally {
core.endGroup()
}
}

0 comments on commit 051bf5e

Please sign in to comment.