Skip to content

Commit

Permalink
perf(interop): parallelize and accept tarballs (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomaash committed Aug 8, 2020
1 parent bf52750 commit d62dfd1
Show file tree
Hide file tree
Showing 11 changed files with 428 additions and 234 deletions.
11 changes: 7 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ jobs:

- install-deps-for-screenshot-taking

- run: npm pack

- run:
command: npm run test:interop
# One of the examples in Vis Network sports really massive network
# that takes long to render and would regularly exceed the default
# timeout of 10 minues.
no_output_timeout: 20m
# This runs multiple things in parallel and only reports start and end
# of individual commands, the full logs are printed at the end. Due to
# this it's quite likely to go a long time without any output and
# still finish successfully.
no_output_timeout: 60m

release:
executor: node
Expand Down
37 changes: 37 additions & 0 deletions interop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env node

// Ideally this would be just a Shell script but Windows exists and I don't want
// to force Windows users to install Shell and configure it to be used to run
// npm scripts (and break their Windows only projects?).

const { spawnSync } = require("child_process");

const { status } = spawnSync(
"node",
[
"./bin/test-e2e-interop.js",
// This is the shared stuff used in all of our projects.
"--config",
"./public/interop/base-config.json",
// This is specific to this project.
"--project",
"vis-charts https://github.com/visjs/vis-charts.git",
"--project",
"vis-data https://github.com/visjs/vis-data.git",
"--project",
"vis-dev-utils ./vis-dev-utils-0.0.0-no-version.tgz",
"--project",
"vis-graph3d https://github.com/visjs/vis-graph3d.git",
"--project",
"vis-network https://github.com/visjs/vis-network.git",
"--project",
"vis-timeline https://github.com/visjs/vis-timeline.git",
"--project",
"vis-util https://github.com/visjs/vis-util.git",
// Any additional options passed from the command line (e.g. a fail command
// for debugging).
...process.argv.slice(2),
],
{ stdio: "inherit" }
);
process.exitCode = status;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"postinstall": "opencollective postinstall || exit 0",
"prepublishOnly": "npm run build",
"test": "npm run test:unit && npm run test:interop",
"test:interop": "node ./bin/test-e2e-interop.js --config ./public/interop/base-config.json --local-project \"vis-dev-utils .\"",
"test:interop": "node interop.js",
"test:interop:debug": "npm run test:interop -- --fail-command \"$SHELL\"",
"test:unit": "mocha --exit",
"watch": "rollup --watch --config rollup.config.js"
Expand Down
24 changes: 7 additions & 17 deletions public/interop/base-config.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
{
"package-script": [
"clean! build! test!",
"vis-charts generate-examples-index!",
"vis-data lint!",
"vis-dev-utils lint!",
"vis-graph3d lint! generate-examples-index!",
"vis-network lint! generate-examples-index!",
"vis-timeline generate-examples-index!",
"vis-util lint!"
],
"remote-project": [
"vis-charts https://github.com/visjs/vis-charts.git",
"vis-data https://github.com/visjs/vis-data.git",
"vis-dev-utils https://github.com/visjs/vis-dev-utils.git",
"vis-graph3d https://github.com/visjs/vis-graph3d.git",
"vis-network https://github.com/visjs/vis-network.git",
"vis-timeline https://github.com/visjs/vis-timeline.git",
"vis-util https://github.com/visjs/vis-util.git"
"vis-charts clean! build! test! generate-examples-index!",
"vis-data clean! lint! build! test!",
"vis-dev-utils clean! lint! build! test!",
"vis-graph3d clean! lint! build! test! generate-examples-index!",
"vis-network clean! lint! build! test! generate-examples-index!",
"vis-timeline clean! build! test! generate-examples-index!",
"vis-util clean! lint! build! test!"
]
}
12 changes: 2 additions & 10 deletions src/test-e2e-interop/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ const y = yargs
'This command will be run in a shell (therefore commands like "$SHELL" will work) after failure to inspect the state.',
type: "string",
})
.option("local-project", {
array: true,
default: [] as string[],
demandOption: false,
describe:
'Projects to copy from local dirs. This has the same format as --remote-project ("package-name URL/path") and if the package names are the same it takes precedence over --remote-project.',
type: "string",
})
.option("package-script", {
array: true,
default: ["clean?", "build!", "test!", "generate-examples-index?"],
Expand All @@ -29,12 +21,12 @@ const y = yargs
'The package scripts to run with each package, either "script-name!" to fail or "script-name?" to skip if the script doesn\'t exist in given package. By default the script is used for all packages, if you want to use it only for one add package name: "package-name script-name!". Scripts are invoked sequentially and command line order is preserved.',
type: "string",
})
.option("remote-project", {
.option("project", {
array: true,
default: [] as string[],
demandOption: false,
describe:
'Projects to clone using Git. The format is "package-name URL/path".',
'Projects to clone using Git, copy from directory or install from tarball. The format is "package-name URL/path".',
type: "string",
})
.option("tmp-dir", {
Expand Down
12 changes: 9 additions & 3 deletions src/test-e2e-interop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { ProjectPaths, PackageScript, test } from "./test";

const argv = parseArguments();

const rawProjectPathArg = [...argv["remote-project"], ...argv["local-project"]];
const projectPaths: ProjectPaths = rawProjectPathArg
const projectPaths: ProjectPaths = argv["project"]
.map((raw): [string, string] => {
const [name, path] = raw.split(" ", 2);

Expand Down Expand Up @@ -57,4 +56,11 @@ const tmpPath = argv["tmp-dir"] ? resolve(argv["tmp-dir"]) : undefined;

const failCommand = argv["fail-command"];

test({ failCommand, packageScripts, projectPaths, tmpPath });
test({ failCommand, packageScripts, projectPaths, tmpPath }).catch(
(reason): void => {
console.error(reason);
if (process.exitCode === 0) {
process.exitCode = 1;
}
}
);
Loading

0 comments on commit d62dfd1

Please sign in to comment.