Skip to content

chore: update vscode to 1.64 #4902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 9, 2022
13 changes: 10 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,19 @@ jobs:
run: echo "::set-output name=rev::$(jq -r '.devDependencies["code-oss-dev"]' vendor/package.json | sed -r 's|.*#(.*)$|\1|')"

- name: Attempt to fetch vscode build from cache
id: cache-vscode
id: cache-vscode-2
uses: actions/cache@v2
with:
path: |
vendor/modules/code-oss-dev/.build
vendor/modules/code-oss-dev/package.json
vendor/modules/code-oss-dev/out-build
vendor/modules/code-oss-dev/out-vscode-reh-web
vendor/modules/code-oss-dev/out-vscode-reh-web-min
key: vscode-reh-build-${{ steps.vscode-rev.outputs.rev }}
key: vscode-reh-build-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}

- name: Build vscode
if: steps.cache-vscode.outputs.cache-hit != 'true'
if: steps.cache-vscode-2.outputs.cache-hit != 'true'
run: yarn build:vscode

# Our code imports code from VS Code's `out` directory meaning VS Code
Expand Down Expand Up @@ -445,6 +446,12 @@ jobs:
./test/node_modules/.bin/playwright install-deps
./test/node_modules/.bin/playwright install
# TODO@jsjoeio - remove once we switch to submodules.
- name: Create package.json for testing
run: |
mkdir -p ./vendor/modules/code-oss-dev
echo '{ "version": "test" }' > ./vendor/modules/code-oss-dev/package.json
- name: Run end-to-end tests
run: yarn test:e2e

Expand Down
10 changes: 5 additions & 5 deletions src/node/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export function getPackageJson(relativePath: string): JSONSchemaForNPMPackageJso
return pkg
}

const pkg = getPackageJson("../../package.json")
const codePkg = getPackageJson("../../vendor/modules/code-oss-dev/package.json")

export const rootPath = path.resolve(__dirname, "../..")
export const vsRootPath = path.join(rootPath, "vendor/modules/code-oss-dev")
const PACKAGE_JSON = "package.json"
const pkg = getPackageJson(`${rootPath}/${PACKAGE_JSON}`)
const codePkg = getPackageJson(`${vsRootPath}/${PACKAGE_JSON}`) || { version: "0.0.0" }
export const pkgName = pkg.name || "code-server"
export const version = pkg.version || "development"
export const commit = pkg.commit || "development"
export const rootPath = path.resolve(__dirname, "../..")
export const vsRootPath = path.join(rootPath, "vendor/modules/code-oss-dev")
export const codeVersion = codePkg.version || "development"
export const tmpdir = path.join(os.tmpdir(), "code-server")
export const isDevMode = commit === "development"
Expand Down
4 changes: 2 additions & 2 deletions src/node/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const shouldSpawnCliProcess = (args: UserProvidedArgs): boolean => {
export const runVsCodeCli = async (args: DefaultedArgs): Promise<void> => {
logger.debug("Running VS Code CLI")

// See ../../vendor/modules/code-oss-dev/src/vs/server/main.js.
const spawnCli = await loadAMDModule<CodeServerLib.SpawnCli>("vs/server/remoteExtensionHostAgent", "spawnCli")
// See ../../vendor/modules/code-oss-dev/src/vs/server/node/server.main.js.
const spawnCli = await loadAMDModule<CodeServerLib.SpawnCli>("vs/server/node/server.main", "spawnCli")

try {
await spawnCli(await toVsCodeArgs(args))
Expand Down
7 changes: 2 additions & 5 deletions src/node/routes/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,9 @@ export class CodeServerRouteWrapper {
const { args } = req

/**
* @file ../../../vendor/modules/code-oss-dev/src/vs/server/main.js
* @file ../../../vendor/modules/code-oss-dev/src/vs/server/node/server.main.js
*/
const createVSServer = await loadAMDModule<CodeServerLib.CreateServer>(
"vs/server/remoteExtensionHostAgent",
"createServer",
)
const createVSServer = await loadAMDModule<CodeServerLib.CreateServer>("vs/server/node/server.main", "createServer")

try {
this._codeServerMain = await createVSServer(null, {
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/codeServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ describe("code-server", true, [], {}, () => {
expect(await codeServerPage.isEditorVisible()).toBe(true)
})

test("should always have a connection", async ({ codeServerPage }) => {
expect(await codeServerPage.isConnected()).toBe(true)
})

test("should show the Integrated Terminal", async ({ codeServerPage }) => {
await codeServerPage.focusTerminal()
expect(await codeServerPage.page.isVisible("#terminal")).toBe(true)
Expand Down
48 changes: 15 additions & 33 deletions test/e2e/models/CodeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class Context {
public canceled(): boolean {
return this._canceled
}
public done(): void {
this._done = true
public finished(): boolean {
return this._done
}
public cancel(): void {
this._canceled = true
}
public finish(): boolean {
return this._done
public finish(): void {
this._done = true
}
}

Expand All @@ -43,7 +43,7 @@ export class CodeServer {
name: string,
private readonly args: string[],
private readonly env: NodeJS.ProcessEnv,
private readonly _workspaceDir: Promise<string> | string | undefined,
private _workspaceDir: Promise<string> | string | undefined,
private readonly entry = process.env.CODE_SERVER_TEST_ENTRY || ".",
) {
this.logger = logger.named(name)
Expand All @@ -64,7 +64,7 @@ export class CodeServer {
/**
* The workspace directory code-server opens with.
*/
get workspaceDir(): Promise<string> {
get workspaceDir(): Promise<string> | string {
if (!this._workspaceDir) {
this._workspaceDir = tmpdir(workspaceDir)
}
Expand Down Expand Up @@ -198,7 +198,7 @@ export class CodeServerPage {
private readonly authenticated: boolean,
) {
this.page.on("console", (message) => {
this.codeServer.logger.debug(message)
this.codeServer.logger.debug(message.text())
})
this.page.on("pageerror", (error) => {
logError(this.codeServer.logger, "page", error)
Expand Down Expand Up @@ -241,22 +241,21 @@ export class CodeServerPage {
this.codeServer.logger.debug("Waiting for editor to be ready...")

const editorIsVisible = await this.isEditorVisible()
const editorIsConnected = await this.isConnected()
let reloadCount = 0

// Occassionally code-server timeouts in Firefox
// we're not sure why
// but usually a reload or two fixes it
// TODO@jsjoeio @oxy look into Firefox reconnection/timeout issues
while (!editorIsVisible && !editorIsConnected) {
while (!editorIsVisible) {
// When a reload happens, we want to wait for all resources to be
// loaded completely. Hence why we use that instead of DOMContentLoaded
// Read more: https://thisthat.dev/dom-content-loaded-vs-load/
await this.page.waitForLoadState("load")
// Give it an extra second just in case it's feeling extra slow
await this.page.waitForTimeout(1000)
reloadCount += 1
if ((await this.isEditorVisible()) && (await this.isConnected())) {
if (await this.isEditorVisible()) {
this.codeServer.logger.debug(`editor became ready after ${reloadCount} reloads`)
break
}
Expand All @@ -280,23 +279,6 @@ export class CodeServerPage {
return visible
}

/**
* Checks if the editor is visible
*/
async isConnected() {
this.codeServer.logger.debug("Waiting for network idle...")

await this.page.waitForLoadState("networkidle")

const host = new URL(await this.codeServer.address()).host
// NOTE: This seems to be pretty brittle between version changes.
const hostSelector = `[aria-label="remote ${host}"]`
this.codeServer.logger.debug(`Waiting selector: ${hostSelector}`)
await this.page.waitForSelector(hostSelector)

return await this.page.isVisible(hostSelector)
}

/**
* Focuses Integrated Terminal
* by using "Terminal: Focus Terminal"
Expand Down Expand Up @@ -326,13 +308,13 @@ export class CodeServerPage {
* Wait for a tab to open for the specified file.
*/
async waitForTab(file: string): Promise<void> {
return this.page.waitForSelector(`.tab :text("${path.basename(file)}")`)
await this.page.waitForSelector(`.tab :text("${path.basename(file)}")`)
}

/**
* See if the specified tab is open.
*/
async tabIsVisible(file: string): Promise<void> {
async tabIsVisible(file: string): Promise<boolean> {
return this.page.isVisible(`.tab :text("${path.basename(file)}")`)
}

Expand Down Expand Up @@ -368,8 +350,8 @@ export class CodeServerPage {
try {
await this.page.waitForSelector(`${selector}:not(:focus-within)`)
} catch (error) {
if (!ctx.done()) {
this.codeServer.logger.debug(`${selector} navigation: ${error.message || error}`)
if (!ctx.finished()) {
this.codeServer.logger.debug(`${selector} navigation: ${(error as any).message || error}`)
}
}
return false
Expand Down Expand Up @@ -423,7 +405,7 @@ export class CodeServerPage {
return false
}
} catch (error) {
logger.debug(`navigation: ${error.message || error}`)
logger.debug(`navigation: ${(error as any).message || error}`)
return false
}
}
Expand All @@ -436,7 +418,7 @@ export class CodeServerPage {
// time we lose focus or there is an error.
let attempts = 1
let context = new Context()
while (!(await Promise.race([openThenWaitClose(), navigate(context)]))) {
while (!(await Promise.race([openThenWaitClose(context), navigate(context)]))) {
++attempts
logger.debug("closed, retrying (${attempt}/∞)")
context.cancel()
Expand Down
2 changes: 1 addition & 1 deletion vendor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"postinstall": "./postinstall.sh"
},
"devDependencies": {
"code-oss-dev": "coder/vscode#94384412221f432c15bb679315c49964925090be"
"code-oss-dev": "coder/vscode#a13f6e1434ad6ab820eef0ecca5b923b3e275667"
}
}
Loading