Skip to content

Commit

Permalink
Make CI stable on Mac+GitHub Actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunabe committed May 29, 2023
1 parent dcbf2b3 commit 2e01c9c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/executor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as executor from "./executor";
import { createConverter } from "./converter";
import {
createConverterWithFileWatcher,
isPerformanceUnstableEnv,
isTsWatchBroken,
runInTmpAsync,
WaitFileEventFunc,
Expand Down Expand Up @@ -392,8 +393,9 @@ describe("execute", () => {
end = Date.now();
let t1 = end - start;
expect(ex.locals.got).toBe(want);
expect(t1 / t0).toBeGreaterThan(0.5);
expect(t0 / t1).toBeGreaterThan(0.5);
const threshold = isPerformanceUnstableEnv() ? 0.1 : 0.5;
expect(t1 / t0).toBeGreaterThan(threshold);
expect(t0 / t1).toBeGreaterThan(threshold);
});

it("overhead", async () => {
Expand Down
8 changes: 8 additions & 0 deletions src/testutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,11 @@ export function createConverterWithFileWatcher(): {
export function isTsWatchBroken(): boolean {
return os.platform() === "darwin" && process.env.GITHUB_ACTIONS === "true";
}

/**
* Performance tests on Mac eivnronment on GitHub Actions sometimes fail.
* @returns
*/
export function isPerformanceUnstableEnv(): boolean {
return os.platform() === "darwin" && process.env.GITHUB_ACTIONS === "true";
}

0 comments on commit 2e01c9c

Please sign in to comment.