Skip to content

Commit

Permalink
feat: add verbose option (#46)
Browse files Browse the repository at this point in the history
* add verbose option

* formatting

* lint

* update README
  • Loading branch information
JoshMcCullough authored May 24, 2023
1 parent 6912820 commit a75b0a1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,17 @@ When running a job (which ever way), you can optionally pass run options

```typescript
{
cwd?: string; // overrides the global cwd and uses the one passed in options
workflowFile?: string; // overrides the global workflow file path and uses the one passed in options
bind?: boolean; // bind the cwd instead of copying it during workflow execution
// activates the artifact server
artifactServer?: {
path: string; // where to store the uploaded artifacts
port: string; // where to run the artifact server
cwd?: string; // overrides the global cwd and uses the one passed in options
workflowFile?: string; // overrides the global workflow file path and uses the one passed in options
bind?: boolean; // bind the cwd instead of copying it during workflow execution
artifactServer?: { // activates the artifact server
path: string; // where to store the uploaded artifacts
port: string; // where to run the artifact server
};
mockApi: ResponseMocker[]; // specify the apis you want to mock. ResponseMocker is from mock-github
mockSteps: MockStep; // specify which steps you want to mock
logFile?: string; // write the raw output act produces to this file for debugging purposes
mockApi: ResponseMocker[]; // specify the apis you want to mock. ResponseMocker is from mock-github
mockSteps: MockStep; // specify which steps you want to mock
logFile?: string; // write the raw output act produces to this file for debugging purposes
verbose?: true; // enable versbose logging
}
```

Expand Down
19 changes: 12 additions & 7 deletions src/act/act.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,16 @@ export class Act {
}

private async parseRunOpts(opts?: RunOpts) {
let proxy: ForwardProxy | undefined = undefined;
const actArguments: string[] = [];
const cwd = opts?.cwd ?? this.cwd;
const workflowFile = opts?.workflowFile ?? this.workflowFile;
let proxy: ForwardProxy | undefined = undefined;

if (opts?.mockApi) {
proxy = new ForwardProxy(opts.mockApi);

const address = await proxy.start();

this.setEnv("http_proxy", `http://${address}`);
this.setEnv("https_proxy", `http://${address}`);
this.setEnv("HTTP_PROXY", `http://${address}`);
Expand All @@ -295,17 +300,19 @@ export class Act {

if (opts?.artifactServer) {
actArguments.push(
"--artifact-server-path",
opts?.artifactServer.path,
"--artifact-server-port",
opts?.artifactServer.port
"--artifact-server-path", opts?.artifactServer.path,
"--artifact-server-port", opts?.artifactServer.port
);
}

if (opts?.bind) {
actArguments.push("--bind");
}

if (opts?.verbose) {
actArguments.push("--verbose");
}

if (this.containerOpts.containerArchitecture) {
actArguments.push("--container-architecture", this.containerOpts.containerArchitecture);
}
Expand All @@ -318,8 +325,6 @@ export class Act {
actArguments.push("--container-options", this.containerOpts.containerOptions);
}

const cwd = opts?.cwd ?? this.cwd;
const workflowFile = opts?.workflowFile ?? this.workflowFile;
actArguments.push("-W", workflowFile);

return { cwd, proxy, actArguments };
Expand Down
1 change: 1 addition & 0 deletions src/act/act.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type RunOpts = {
mockApi?: ResponseMocker<unknown, number>[];
mockSteps?: MockStep;
logFile?: string;
verbose?: boolean;
};

export type ContainerOpts = {
Expand Down

0 comments on commit a75b0a1

Please sign in to comment.