Skip to content

Commit

Permalink
Merge pull request #31 from hashicorp-forge/dependabot/npm_and_yarn/p…
Browse files Browse the repository at this point in the history
…rettier-3.3.2

Bump prettier from 2.7.1 to 3.3.2
  • Loading branch information
brandonc authored Jul 1, 2024
2 parents 276f5d7 + 8f487c5 commit bb25fc5
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 59 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@vercel/ncc": "^0.38.1",
"husky": "^9.0.11",
"jest": "^29.2.2",
"prettier": "^2.7.1",
"prettier": "^3.3.2",
"ts-jest": "^29.1.5",
"typescript": "^5.5.2"
}
Expand Down
12 changes: 6 additions & 6 deletions src/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("action output", () => {
const lister = configure(await io.which("go"), exampleAppEnv);

expect(await lister.outputTestListForRunArg()).toStrictEqual(
"^(?:TestExample0|TestExample1|TestExample2|TestExample3|TestExample4)$"
"^(?:TestExample0|TestExample1|TestExample2|TestExample3|TestExample4)$",
);
});

Expand All @@ -61,7 +61,7 @@ describe("action output", () => {
const lister = configure(await io.which("go"), exampleAppEnv);

expect(await lister.outputTestListForRunArg()).toStrictEqual(
"^(?:TestExample0)$"
"^(?:TestExample0)$",
);
});

Expand All @@ -72,7 +72,7 @@ describe("action output", () => {
const lister = configure(await io.which("go"), exampleAppEnv);

expect(await lister.outputTestListForRunArg()).toStrictEqual(
"^(?:TestExample0|TestExample3)$"
"^(?:TestExample0|TestExample3)$",
);
});

Expand All @@ -83,7 +83,7 @@ describe("action output", () => {
const lister = configure(await io.which("go"), exampleAppEnv);

expect(await lister.outputTestListForRunArg()).toStrictEqual(
"^(?:TestExample1|TestExample4)$"
"^(?:TestExample1|TestExample4)$",
);
});

Expand All @@ -94,7 +94,7 @@ describe("action output", () => {
const lister = configure(await io.which("go"), exampleAppEnv);

expect(await lister.outputTestListForRunArg()).toStrictEqual(
"^(?:TestExample2)$"
"^(?:TestExample2)$",
);
});

Expand Down Expand Up @@ -123,7 +123,7 @@ describe("action output", () => {

const lister = configure(await io.which("go"), exampleAppEnv);
expect(await lister.outputTestListForRunArg()).toStrictEqual(
"^(?:TestExample2|TestExample3)$"
"^(?:TestExample2|TestExample3)$",
);
});
});
10 changes: 5 additions & 5 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {GoTestLister, ListerOptions} from "./go-test-lister";

export function configure(
whichGo: string,
env?: NodeJS.ProcessEnv
env?: NodeJS.ProcessEnv,
): GoTestLister {
let opts: ListerOptions = {
// The go binary-- in GHA, this should be the result of await io.which("go")
Expand All @@ -32,7 +32,7 @@ export function configure(
// Env
workingDirectory: path.join(
process.env.GITHUB_WORKSPACE,
core.getInput("working-directory")
core.getInput("working-directory"),
),
env,
};
Expand All @@ -41,14 +41,14 @@ export function configure(
if (Number.isNaN(opts.total) || Number.isNaN(opts.index)) {
throw new Error(
`Unexpected input: index "${core.getInput("index")}" of "${core.getInput(
"total"
)}" total`
"total",
)}" total`,
);
}

if (opts.index > opts.total - 1 || opts.index < 0) {
throw new Error(
`Slice index out of range: Requested index ${opts.index} of ${opts.total} total slices`
`Slice index out of range: Requested index ${opts.index} of ${opts.total} total slices`,
);
}

Expand Down
16 changes: 8 additions & 8 deletions src/go-test-lister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class GoTestLister {
];

log.info(
`Listing go tests with the following command: ${g} ${args.join(" ")}`
`Listing go tests with the following command: ${g} ${args.join(" ")}`,
);
const cmd = spawnSync(g, args, {
cwd: this.opts.workingDirectory,
Expand All @@ -70,7 +70,7 @@ export class GoTestLister {

if (cmd.status != 0) {
throw new Error(
`go test failed (exit code ${cmd.status}) The error output was:\n\n${cmd.stderr}\n\n${cmd.stdout}`
`go test failed (exit code ${cmd.status}) The error output was:\n\n${cmd.stderr}\n\n${cmd.stdout}`,
);
}

Expand All @@ -87,7 +87,7 @@ export class GoTestLister {
this.opts.total,
this.opts.index,
this.opts.junitSummary,
allTests
allTests,
);
testsForIndex = allTests.filter(strategy.listFilterFunc.bind(strategy));

Expand All @@ -96,27 +96,27 @@ export class GoTestLister {
const seconds = Math.ceil(duration - minutes * 60);

log.info(
`This slice has ${testsForIndex.length} tests and is estimated to finish in ${minutes}m ${seconds}s`
`This slice has ${testsForIndex.length} tests and is estimated to finish in ${minutes}m ${seconds}s`,
);
}
} catch (error) {
log.warning(
`Failed to use junit splitting strategy (falling back to naive strategy): ${error}`
`Failed to use junit splitting strategy (falling back to naive strategy): ${error}`,
);
}

if (testsForIndex === null) {
const fallbackStrategy = new NaiveStrategy(
this.opts.total,
this.opts.index
this.opts.index,
);
testsForIndex = allTests.filter(
fallbackStrategy.listFilterFunc.bind(fallbackStrategy)
fallbackStrategy.listFilterFunc.bind(fallbackStrategy),
);
}

log.debug(
`Output populated with these specific tests:\n${testsForIndex.join("\n")}`
`Output populated with these specific tests:\n${testsForIndex.join("\n")}`,
);

return this.formatTests(testsForIndex);
Expand Down
28 changes: 14 additions & 14 deletions src/strategies/junit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("junit splitting strategy", () => {
it("includes all tests", () => {
const strategy = new JUnitStrategy(1, 0, suite, tests);
expect<string[]>(
tests.filter(strategy.listFilterFunc.bind(strategy))
tests.filter(strategy.listFilterFunc.bind(strategy)),
).toStrictEqual(tests);
});
});
Expand All @@ -30,10 +30,10 @@ describe("junit splitting strategy", () => {
const node1 = new JUnitStrategy(2, 1, suite, tests);

expect<string[]>(
tests.filter(node0.listFilterFunc.bind(node0)).sort()
tests.filter(node0.listFilterFunc.bind(node0)).sort(),
).toStrictEqual(["Test3"].sort());
expect<string[]>(
tests.filter(node1.listFilterFunc.bind(node1)).sort()
tests.filter(node1.listFilterFunc.bind(node1)).sort(),
).toStrictEqual(["Test0", "Test1", "Test2"].sort());
});
});
Expand All @@ -45,13 +45,13 @@ describe("junit splitting strategy", () => {
const node2 = new JUnitStrategy(3, 2, suite, tests);

expect<string[]>(
tests.filter(node0.listFilterFunc.bind(node0)).sort()
tests.filter(node0.listFilterFunc.bind(node0)).sort(),
).toStrictEqual(["Test3"].sort());
expect<string[]>(
tests.filter(node1.listFilterFunc.bind(node1)).sort()
tests.filter(node1.listFilterFunc.bind(node1)).sort(),
).toStrictEqual(["Test0"].sort());
expect<string[]>(
tests.filter(node2.listFilterFunc.bind(node2)).sort()
tests.filter(node2.listFilterFunc.bind(node2)).sort(),
).toStrictEqual(["Test1", "Test2"].sort());
});
});
Expand All @@ -71,7 +71,7 @@ describe("junit splitting strategy", () => {
it("can parse testcases", () => {
const strategy = new JUnitStrategy(1, 0, suite, tests);
expect<string[]>(
tests.filter(strategy.listFilterFunc.bind(strategy))
tests.filter(strategy.listFilterFunc.bind(strategy)),
).toStrictEqual(tests);
});
});
Expand All @@ -94,7 +94,7 @@ describe("junit splitting strategy", () => {
it("includes all tests", () => {
const strategy = new JUnitStrategy(1, 0, suite, tests);
expect<string[]>(
tests.filter(strategy.listFilterFunc.bind(strategy))
tests.filter(strategy.listFilterFunc.bind(strategy)),
).toStrictEqual(tests);
});
});
Expand All @@ -105,10 +105,10 @@ describe("junit splitting strategy", () => {
const node1 = new JUnitStrategy(2, 1, suite, tests);

expect<string[]>(
tests.filter(node0.listFilterFunc.bind(node0)).sort()
tests.filter(node0.listFilterFunc.bind(node0)).sort(),
).toStrictEqual(["Test2", "Test4", "Test5"].sort());
expect<string[]>(
tests.filter(node1.listFilterFunc.bind(node1)).sort()
tests.filter(node1.listFilterFunc.bind(node1)).sort(),
).toStrictEqual(["Test0", "Test1", "Test3"].sort());
});
});
Expand All @@ -120,13 +120,13 @@ describe("junit splitting strategy", () => {
const node2 = new JUnitStrategy(3, 2, suite, tests);

expect<string[]>(
tests.filter(node0.listFilterFunc.bind(node0)).sort()
tests.filter(node0.listFilterFunc.bind(node0)).sort(),
).toStrictEqual(["Test4"].sort()); // 2.40
expect<string[]>(
tests.filter(node1.listFilterFunc.bind(node1)).sort()
tests.filter(node1.listFilterFunc.bind(node1)).sort(),
).toStrictEqual(["Test3", "Test2"].sort()); // 1.99
expect<string[]>(
tests.filter(node2.listFilterFunc.bind(node2)).sort()
tests.filter(node2.listFilterFunc.bind(node2)).sort(),
).toStrictEqual(["Test0", "Test5", "Test1"].sort()); // 1.90
});
});
Expand All @@ -149,7 +149,7 @@ describe("junit splitting strategy", () => {
const node0 = new JUnitStrategy(1, 0, suite, tests);

expect<string[]>(
tests.filter(node0.listFilterFunc.bind(node0)).sort()
tests.filter(node0.listFilterFunc.bind(node0)).sort(),
).toStrictEqual(tests.sort());
});
});
Expand Down
12 changes: 6 additions & 6 deletions src/strategies/junit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class JUnitStrategy {
total: number,
index: number,
junitSummaryPath: string,
allTestNames: string[]
allTestNames: string[],
) {
this.total = total;
this.index = index;
Expand Down Expand Up @@ -66,7 +66,7 @@ export default class JUnitStrategy {

if (!junitData?.testsuites?.testsuite) {
throw new Error(
"junit-summary is invalid. Expected testsuites/testsuite elements"
"junit-summary is invalid. Expected testsuites/testsuite elements",
);
}

Expand All @@ -76,7 +76,7 @@ export default class JUnitStrategy {
const cases = [junitData?.testsuites?.testsuite]
.flat()
.flatMap((suite: any) =>
suite.testcase ? [suite.testcase].flat().flatMap((tc: any) => tc) : []
suite.testcase ? [suite.testcase].flat().flatMap((tc: any) => tc) : [],
);

let casesByName: {[key: string]: any} = {};
Expand Down Expand Up @@ -104,7 +104,7 @@ export default class JUnitStrategy {

const averageTiming = index > 0 ? totalTiming / (index + 1) : 1.0;
log.debug(
`Could not find timing data for ${name}, substituting default value of ${averageTiming}s (the average so far)`
`Could not find timing data for ${name}, substituting default value of ${averageTiming}s (the average so far)`,
);

return {
Expand All @@ -121,7 +121,7 @@ export default class JUnitStrategy {
`Found ${timingsFound} testcase timings, which is ${(
(timingsFound / this.allTestNames.length) *
100
).toFixed(1)}% of all tests`
).toFixed(1)}% of all tests`,
);
} else {
log.warning("No tests were specified");
Expand Down Expand Up @@ -149,7 +149,7 @@ export default class JUnitStrategy {
bestList.caseTimeTotal
} estimated runtime (previously ${
bestList.caseTimeTotal - testWithTiming.timing
})`
})`,
);
});
}
Expand Down
Loading

0 comments on commit bb25fc5

Please sign in to comment.