Skip to content

Commit 8ffc496

Browse files
committed
Add setFailed to ActionsEnv
1 parent 1e377bc commit 8ffc496

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/actions-util.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ declare const __CODEQL_ACTION_VERSION__: string;
3030
export interface ActionsEnv {
3131
getRequiredInput: (name: string) => string;
3232
getOptionalInput: (name: string) => string | undefined;
33+
setFailed: (message: string) => void;
3334
}
3435

3536
/**
@@ -39,6 +40,7 @@ export function getActionsEnv(): ActionsEnv {
3940
return {
4041
getRequiredInput,
4142
getOptionalInput,
43+
setFailed: core.setFailed,
4244
};
4345
}
4446

‎src/testing-utils.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,13 @@ export function getTestEnv(testEnv: NodeJS.ProcessEnv = {}): Env {
227227
return getEnv(testEnv);
228228
}
229229

230-
/** An implementation of `ActionsEnv` for use in tests. */
230+
/**
231+
* An implementation of {@link ActionsEnv} for use in tests.
232+
* The methods of instances of this class are intended to be stubbed.
233+
*/
231234
class TestActionsEnv implements ActionsEnv {
235+
private failed: boolean = false;
236+
232237
constructor(private readonly env: Env) {}
233238

234239
public clone(env: Env): this {
@@ -242,6 +247,14 @@ class TestActionsEnv implements ActionsEnv {
242247
public getOptionalInput(_name: string): string | undefined {
243248
return undefined;
244249
}
250+
251+
public setFailed(_message: string) {
252+
this.failed = true;
253+
}
254+
255+
get hasFailed() {
256+
return this.failed;
257+
}
245258
}
246259

247260
/**

0 commit comments

Comments
 (0)