Fix broken user and docker tests (#42431)

* Add --force to npm install script for user tests

* Migrate prettier to docker

* Fix vscode Dockerfile

* Fix stack space issue in isJSLiteralType

* Use --legacy-peer-deps based on npm version

* Fix xterm.js Dockerfile
This commit is contained in:
Ron Buckton 2021-01-22 13:23:41 -08:00 committed by GitHub
parent 80dfc6a45b
commit ee3fe472d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 27 deletions

View File

@ -14109,7 +14109,8 @@ namespace ts {
return some((type as IntersectionType).types, isJSLiteralType);
}
if (type.flags & TypeFlags.Instantiable) {
return isJSLiteralType(getResolvedBaseConstraint(type));
const constraint = getResolvedBaseConstraint(type);
return constraint !== type && isJSLiteralType(constraint);
}
return false;
}

View File

@ -68,6 +68,9 @@ namespace Harness {
cwd = config.path ? path.join(cwd, config.path) : submoduleDir;
}
const npmVersionText = exec("npm", ["--version"], { cwd, stdio: "pipe" })?.trim();
const npmVersion = npmVersionText ? ts.Version.tryParse(npmVersionText.trim()) : undefined;
const isV7OrLater = !!npmVersion && npmVersion.major >= 7;
if (fs.existsSync(path.join(cwd, "package.json"))) {
if (fs.existsSync(path.join(cwd, "package-lock.json"))) {
fs.unlinkSync(path.join(cwd, "package-lock.json"));
@ -75,24 +78,25 @@ namespace Harness {
if (fs.existsSync(path.join(cwd, "node_modules"))) {
del.sync(path.join(cwd, "node_modules"), { force: true });
}
exec("npm", ["i", "--ignore-scripts"], { cwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure
exec("npm", ["i", "--ignore-scripts", ...(isV7OrLater ? ["--legacy-peer-deps"] : [])], { cwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure
}
const args = [path.join(IO.getWorkspaceRoot(), "built/local/tsc.js")];
if (types) {
args.push("--types", types.join(","));
// Also actually install those types (for, eg, the js projects which need node)
if (types.length) {
exec("npm", ["i", ...types.map(t => `@types/${t}`), "--no-save", "--ignore-scripts"], { cwd: originalCwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure
exec("npm", ["i", ...types.map(t => `@types/${t}`), "--no-save", "--ignore-scripts", ...(isV7OrLater ? ["--legacy-peer-deps"] : [])], { cwd: originalCwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure
}
}
args.push("--noEmit");
Baseline.runBaseline(`${cls.kind()}/${directoryName}.log`, cls.report(cp.spawnSync(`node`, args, { cwd, timeout, shell: true }), cwd));
function exec(command: string, args: string[], options: { cwd: string, timeout?: number }): void {
function exec(command: string, args: string[], options: { cwd: string, timeout?: number, stdio?: import("child_process").StdioOptions }): string | undefined {
const res = cp.spawnSync(isWorker ? `${command} 2>&1` : command, args, { shell: true, stdio, ...options });
if (res.status !== 0) {
throw new Error(`${command} ${args.join(" ")} for ${directoryName} failed: ${res.stdout && res.stdout.toString()}`);
}
return options.stdio === "pipe" ? res.stdout.toString("utf8") : undefined;
}
});
});

View File

@ -0,0 +1,13 @@
FROM node:current
RUN npm i -g yarn --force
RUN git clone https://github.com/prettier/prettier.git /prettier
WORKDIR /prettier
RUN git pull
COPY --from=typescript/typescript /typescript/typescript-*.tgz /typescript.tgz
RUN mkdir /typescript
RUN tar -xzvf /typescript.tgz -C /typescript
RUN yarn add typescript@/typescript.tgz
RUN yarn
ENTRYPOINT [ "yarn" ]
# Build
CMD [ "build" ]

View File

@ -10,6 +10,7 @@ COPY --from=typescript/typescript /typescript/typescript-*.tgz /typescript.tgz
WORKDIR /vscode/build
RUN yarn add typescript@/typescript.tgz
WORKDIR /vscode/extensions
RUN yarn add rimraf
RUN yarn add typescript@/typescript.tgz
WORKDIR /vscode
RUN yarn add typescript@/typescript.tgz

View File

@ -1,5 +1,5 @@
# node-pty doesn't build on node 12 right now, so we lock to 8 - the version xterm itself tests against :(
FROM node:8
# node-pty doesn't build on node 12 right now, so we lock to 10
FROM node:10
RUN git clone https://github.com/xtermjs/xterm.js.git /xtermjs
WORKDIR /xtermjs
RUN git pull

View File

@ -1,4 +0,0 @@
{
"cloneUrl": "https://github.com/prettier/prettier.git",
"types": ["node"]
}

View File

@ -1,17 +0,0 @@
{
"compilerOptions": {
"noImplicitAny": false,
"noImplicitThis": false,
"maxNodeModuleJsDepth": 0,
"strict": true,
"noEmit": true,
"allowJs": true,
"checkJs": true,
"types": ["node"],
"lib": ["esnext", "dom"],
"target": "esnext",
"module": "commonjs",
"pretty": false,
},
"include": ["prettier/src"]
}