Skip to content

Commit

Permalink
Merge branch 'main' into validate-types-in-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike committed Jan 23, 2025
2 parents ab65adc + 1ef38cd commit 240e76d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 168 deletions.
162 changes: 9 additions & 153 deletions stressor/package-lock.json

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

5 changes: 2 additions & 3 deletions stressor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
"description": "Stress test Test Plans via CI workflows",
"main": "stress-test.mts",
"scripts": {
"cancel-runs": "node --loader ts-node/esm cancel-all-workflows.mts",
"cancel-runs": "tsx cancel-all-workflows.mts",
"test-types": "tsc --noEmit"
},
"author": "",
"license": "MIT",
"dependencies": {
"@commander-js/extra-typings": "^13.0.0",
"@octokit/rest": "^21.0.1",
"@types/lodash.isequal": "^4.5.8",
"commander": "^13.0.0",
"jest-diff": "^29.7.0",
"lodash.isequal": "^4.5.0",
"ngrok": "^5.0.0-beta.2",
"p-limit": "^6.1.0",
"ts-node": "^10.9.2",
"typescript": "^5.5.4",
"word-wrap": "^1.2.5"
},
Expand Down
47 changes: 35 additions & 12 deletions stressor/stress-test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import wrap from "word-wrap";
import pLimit from "p-limit";
import isEqual from "lodash.isequal";
import { readFile, writeFile } from "node:fs/promises";
import { Command, InvalidArgumentError } from "commander";
import { Command, InvalidArgumentError } from "@commander-js/extra-typings";

const DEBUG = process.env.DEBUG === "true" || process.env.DEBUG === "1";
const limitWorkflows = pLimit(8);
Expand All @@ -18,17 +18,7 @@ function parseIntOption(value: string, dummyPrevious: number) {
}
return parsedValue;
}
const program = new Command()
.requiredOption("-o, --owner <string>", "repository owner")
.requiredOption("-r, --repo <string>", "repository name")
.option("-b, --branch <string>", "Git branch", "main")
.option("-f, --results-from-file", "Load results from local 'allResults.json' file")
.option("-n, --num-runs <int>", "Number of times to run each test plan", parseIntOption, 5)
.option("-p, --port <int>", "Port number on which to bind the local results-accepting server", parseIntOption, 8888);
program.parse();
const options = program.opts();

const testPlans = [
const defaultTestPlans = [
"tests/menu-button-actions-active-descendant",
"tests/alert",
"tests/horizontal-slider",
Expand All @@ -40,6 +30,39 @@ const testPlans = [
"tests/radiogroup-aria-activedescendant",
"tests/toggle-button",
];
function parseTestPlanOption(value: string, previous: string[]) {
if (!value.startsWith("tests/")) {
throw new InvalidArgumentError(
`Test plan specified without "tests/" directory: "${value}"`
);
}
// When parsing a repeatable option, Commander supplies the default value as
// the initial "previous" value. Without special handling like the one below
// (which regrettably must rely on Array identity), user-specified values
// would be appended to the set of defaults.
if (previous === defaultTestPlans) {
return [value];
}
return previous.concat(value);
}

const program = new Command()
.requiredOption("-o, --owner <string>", "repository owner")
.requiredOption("-r, --repo <string>", "repository name")
.option("-b, --branch <string>", "Git branch", "main")
.option("-f, --results-from-file", "Load results from local 'allResults.json' file")
.option("-n, --num-runs <int>", "Number of times to run each test plan", parseIntOption, 5)
.option("-p, --port <int>", "Port number on which to bind the local results-accepting server", parseIntOption, 8888)
.option("-t, --test-plan <string>", "Test plan to run (repeatable)", parseTestPlanOption, defaultTestPlans);
program.parse();
const options = program.opts();
// Rename "options.testPlan" (named for coherence to the CLI user) to
// "testPlans" (named for accuracy of the value type it holds). (Commander
// conflates the name of CLI options with the JavaScript property where the
// corresponding values are stored. This creates tension for repeatable options
// because the final value is a collection composed of many individual input
// values.)
const testPlans = options.testPlan;

// ordered this way because voiceover usually finishes quicker, and when you only
// have 3 jobs left it matters... :)
Expand Down

0 comments on commit 240e76d

Please sign in to comment.