forked from gradle/actions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MultiCI: Abstract gh action exec calls to wrapper
- Loading branch information
Showing
13 changed files
with
180 additions
and
22 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
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
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,89 @@ | ||
/** | ||
* Provides a wrapper for execution of system commands in a job. | ||
*/ | ||
export interface GradleEnvExecutionImpl { | ||
/** | ||
* Wrap an asynchronous function call in a "group" of execution in a CI pipeline. | ||
* @param name Name of the group. | ||
* @param fn | ||
*/ | ||
group<R>(name: string, fn: () => Promise<R>): Promise<R> | ||
|
||
/** | ||
* Executes | ||
* @param command | ||
* @param args | ||
*/ | ||
run(command: string, args?: string[], options?: GradleEnvExecOptions): Promise<void> | ||
|
||
/** | ||
* Executes command and returns the output. | ||
* @param command | ||
* @param args | ||
* @param options | ||
*/ | ||
getExecOutput( | ||
command: string, | ||
args?: string[], | ||
options?: GradleEnvExecOptions | ||
): Promise<{stdout: string; stderr: string}> | ||
|
||
/** | ||
* Exec a command. | ||
* Output will be streamed to the live console. | ||
* Returns promise with return code | ||
* | ||
* @param commandLine command to execute (can include additional args). Must be correctly escaped. | ||
* @param args optional arguments for tool. Escaping is handled by the lib. | ||
* @param options optional exec options. See ExecOptions | ||
* @returns Promise<number> exit code | ||
*/ | ||
exec(command: string, args?: string[], options?: GradleEnvExecOptions): Promise<number> | ||
} | ||
|
||
/** | ||
* Interface for exec options | ||
*/ | ||
export interface GradleEnvExecOptions { | ||
/** optional working directory. defaults to current */ | ||
cwd?: string | ||
|
||
silent?: boolean | ||
|
||
ignoreReturnCode?: boolean | ||
|
||
/** optional envvar dictionary. defaults to current process's env */ | ||
env?: { | ||
[key: string]: string | ||
} | ||
} | ||
|
||
class GradleExec implements GradleEnvExecutionImpl { | ||
private impl!: GradleEnvExecutionImpl | ||
|
||
setImpl(impl: GradleEnvExecutionImpl): void { | ||
this.impl = impl | ||
} | ||
|
||
async group<R>(name: string, fn: () => Promise<R>): Promise<R> { | ||
return await this.impl.group(name, fn) | ||
} | ||
|
||
async run(command: string, args?: string[], options?: GradleEnvExecOptions): Promise<void> { | ||
await this.impl.run(command, args, options) | ||
} | ||
|
||
async exec(command: string, args?: string[], options?: GradleEnvExecOptions): Promise<number> { | ||
return await this.impl.exec(command, args, options) | ||
} | ||
|
||
async getExecOutput( | ||
command: string, | ||
args?: string[], | ||
options?: GradleEnvExecOptions | ||
): Promise<{stdout: string; stderr: string}> { | ||
return await this.impl.getExecOutput(command, args, options) | ||
} | ||
} | ||
|
||
export const exec = new GradleExec() |
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
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