Skip to content

Commit

Permalink
recordEvent isn't need async
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Mar 15, 2024
1 parent e53cf29 commit f72fbb0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
44 changes: 40 additions & 4 deletions dist/index.js

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

13 changes: 5 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class IdsToolbox {

{
const phase = actions_core.getState("idstoolbox_execution_phase");
if (phase == "") {
if (phase === "") {
actions_core.saveState("idstoolbox_execution_phase", "post");
this.executionPhase = "action";
} else {
Expand Down Expand Up @@ -249,11 +249,11 @@ export class IdsToolbox {
true,
)
) {
await this.recordEvent("artifact_cache_hit");
this.recordEvent("artifact_cache_hit");
return `${tempDir}/${this.options.name}`;
}

await this.recordEvent("artifact_cache_miss");
this.recordEvent("artifact_cache_miss");
return undefined;
} finally {
process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP;
Expand Down Expand Up @@ -284,18 +284,15 @@ export class IdsToolbox {
undefined,
true,
);
await this.recordEvent("artifact_cache_hit");
this.recordEvent("artifact_cache_hit");
} finally {
process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP;
delete process.env.GITHUB_WORKSPACE_BACKUP;
process.chdir(startCwd);
}
}

async recordEvent(
event_name: string,
context: Record<string, unknown> = {},
): Promise<void> {
recordEvent(event_name: string, context: Record<string, unknown> = {}): void {
this.events.push({
event_name: `${this.options.eventPrefix}${event_name}`,
context,
Expand Down
5 changes: 3 additions & 2 deletions src/test-run.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// eslint-disable-next-line import/no-unresolved
import { IdsToolbox } from "./main.js";

process.env["RUNNER_ARCH"] = "ARM64";
process.env["RUNNER_OS"] = "macOS";
process.env["IDS_HOST"] = "http://localhost:8080";
Expand All @@ -11,8 +14,6 @@ process.env["GITHUB_RUN_ID"] = "58";
process.env["GITHUB_RUN_NUMBER"] = "78";
process.env["GITHUB_RUN_ATTEMPT"] = "1";

import { IdsToolbox } from "./main.js";

async function main(): Promise<void> {
{
const toolbox = new IdsToolbox({
Expand Down

0 comments on commit f72fbb0

Please sign in to comment.