Skip to content

Commit 0e92391

Browse files
jsjoeioTinLe
authored andcommitted
chore: update vscode to 1.64 (coder#4902)
* chore: update vscode server files * chore: update code to 1.64 * refactor: clean up code in constants.ts * chore: keep package.json vscode cache * fixup!: formatting * feat(ci): add VSCODE_CACHE_VERSION * fix(ci): add package.json for e2e tests * fix: TS errors * refactor: remove isConnected e2e tests
1 parent bfb2426 commit 0e92391

File tree

8 files changed

+165
-158
lines changed

8 files changed

+165
-158
lines changed

.github/workflows/ci.yaml

+10-3
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,19 @@ jobs:
143143
run: echo "::set-output name=rev::$(jq -r '.devDependencies["code-oss-dev"]' vendor/package.json | sed -r 's|.*#(.*)$|\1|')"
144144

145145
- name: Attempt to fetch vscode build from cache
146-
id: cache-vscode
146+
id: cache-vscode-2
147147
uses: actions/cache@v2
148148
with:
149149
path: |
150150
vendor/modules/code-oss-dev/.build
151+
vendor/modules/code-oss-dev/package.json
151152
vendor/modules/code-oss-dev/out-build
152153
vendor/modules/code-oss-dev/out-vscode-reh-web
153154
vendor/modules/code-oss-dev/out-vscode-reh-web-min
154-
key: vscode-reh-build-${{ steps.vscode-rev.outputs.rev }}
155+
key: vscode-reh-build-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}
155156

156157
- name: Build vscode
157-
if: steps.cache-vscode.outputs.cache-hit != 'true'
158+
if: steps.cache-vscode-2.outputs.cache-hit != 'true'
158159
run: yarn build:vscode
159160

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

src/node/constants.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ export function getPackageJson(relativePath: string): JSONSchemaForNPMPackageJso
1616
return pkg
1717
}
1818

19-
const pkg = getPackageJson("../../package.json")
20-
const codePkg = getPackageJson("../../vendor/modules/code-oss-dev/package.json")
21-
19+
export const rootPath = path.resolve(__dirname, "../..")
20+
export const vsRootPath = path.join(rootPath, "vendor/modules/code-oss-dev")
21+
const PACKAGE_JSON = "package.json"
22+
const pkg = getPackageJson(`${rootPath}/${PACKAGE_JSON}`)
23+
const codePkg = getPackageJson(`${vsRootPath}/${PACKAGE_JSON}`) || { version: "0.0.0" }
2224
export const pkgName = pkg.name || "code-server"
2325
export const version = pkg.version || "development"
2426
export const commit = pkg.commit || "development"
25-
export const rootPath = path.resolve(__dirname, "../..")
26-
export const vsRootPath = path.join(rootPath, "vendor/modules/code-oss-dev")
2727
export const codeVersion = codePkg.version || "development"
2828
export const tmpdir = path.join(os.tmpdir(), "code-server")
2929
export const isDevMode = commit === "development"

src/node/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export const shouldSpawnCliProcess = (args: UserProvidedArgs): boolean => {
3131
export const runVsCodeCli = async (args: DefaultedArgs): Promise<void> => {
3232
logger.debug("Running VS Code CLI")
3333

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

3737
try {
3838
await spawnCli(await toVsCodeArgs(args))

src/node/routes/vscode.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,9 @@ export class CodeServerRouteWrapper {
118118
const { args } = req
119119

120120
/**
121-
* @file ../../../vendor/modules/code-oss-dev/src/vs/server/main.js
121+
* @file ../../../vendor/modules/code-oss-dev/src/vs/server/node/server.main.js
122122
*/
123-
const createVSServer = await loadAMDModule<CodeServerLib.CreateServer>(
124-
"vs/server/remoteExtensionHostAgent",
125-
"createServer",
126-
)
123+
const createVSServer = await loadAMDModule<CodeServerLib.CreateServer>("vs/server/node/server.main", "createServer")
127124

128125
try {
129126
this._codeServerMain = await createVSServer(null, {

test/e2e/codeServer.test.ts

-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ describe("code-server", true, [], {}, () => {
5555
expect(await codeServerPage.isEditorVisible()).toBe(true)
5656
})
5757

58-
test("should always have a connection", async ({ codeServerPage }) => {
59-
expect(await codeServerPage.isConnected()).toBe(true)
60-
})
61-
6258
test("should show the Integrated Terminal", async ({ codeServerPage }) => {
6359
await codeServerPage.focusTerminal()
6460
expect(await codeServerPage.page.isVisible("#terminal")).toBe(true)

test/e2e/models/CodeServer.ts

+15-33
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ class Context {
2020
public canceled(): boolean {
2121
return this._canceled
2222
}
23-
public done(): void {
24-
this._done = true
23+
public finished(): boolean {
24+
return this._done
2525
}
2626
public cancel(): void {
2727
this._canceled = true
2828
}
29-
public finish(): boolean {
30-
return this._done
29+
public finish(): void {
30+
this._done = true
3131
}
3232
}
3333

@@ -43,7 +43,7 @@ export class CodeServer {
4343
name: string,
4444
private readonly args: string[],
4545
private readonly env: NodeJS.ProcessEnv,
46-
private readonly _workspaceDir: Promise<string> | string | undefined,
46+
private _workspaceDir: Promise<string> | string | undefined,
4747
private readonly entry = process.env.CODE_SERVER_TEST_ENTRY || ".",
4848
) {
4949
this.logger = logger.named(name)
@@ -64,7 +64,7 @@ export class CodeServer {
6464
/**
6565
* The workspace directory code-server opens with.
6666
*/
67-
get workspaceDir(): Promise<string> {
67+
get workspaceDir(): Promise<string> | string {
6868
if (!this._workspaceDir) {
6969
this._workspaceDir = tmpdir(workspaceDir)
7070
}
@@ -198,7 +198,7 @@ export class CodeServerPage {
198198
private readonly authenticated: boolean,
199199
) {
200200
this.page.on("console", (message) => {
201-
this.codeServer.logger.debug(message)
201+
this.codeServer.logger.debug(message.text())
202202
})
203203
this.page.on("pageerror", (error) => {
204204
logError(this.codeServer.logger, "page", error)
@@ -241,22 +241,21 @@ export class CodeServerPage {
241241
this.codeServer.logger.debug("Waiting for editor to be ready...")
242242

243243
const editorIsVisible = await this.isEditorVisible()
244-
const editorIsConnected = await this.isConnected()
245244
let reloadCount = 0
246245

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

283-
/**
284-
* Checks if the editor is visible
285-
*/
286-
async isConnected() {
287-
this.codeServer.logger.debug("Waiting for network idle...")
288-
289-
await this.page.waitForLoadState("networkidle")
290-
291-
const host = new URL(await this.codeServer.address()).host
292-
// NOTE: This seems to be pretty brittle between version changes.
293-
const hostSelector = `[aria-label="remote ${host}"]`
294-
this.codeServer.logger.debug(`Waiting selector: ${hostSelector}`)
295-
await this.page.waitForSelector(hostSelector)
296-
297-
return await this.page.isVisible(hostSelector)
298-
}
299-
300282
/**
301283
* Focuses Integrated Terminal
302284
* by using "Terminal: Focus Terminal"
@@ -326,13 +308,13 @@ export class CodeServerPage {
326308
* Wait for a tab to open for the specified file.
327309
*/
328310
async waitForTab(file: string): Promise<void> {
329-
return this.page.waitForSelector(`.tab :text("${path.basename(file)}")`)
311+
await this.page.waitForSelector(`.tab :text("${path.basename(file)}")`)
330312
}
331313

332314
/**
333315
* See if the specified tab is open.
334316
*/
335-
async tabIsVisible(file: string): Promise<void> {
317+
async tabIsVisible(file: string): Promise<boolean> {
336318
return this.page.isVisible(`.tab :text("${path.basename(file)}")`)
337319
}
338320

@@ -368,8 +350,8 @@ export class CodeServerPage {
368350
try {
369351
await this.page.waitForSelector(`${selector}:not(:focus-within)`)
370352
} catch (error) {
371-
if (!ctx.done()) {
372-
this.codeServer.logger.debug(`${selector} navigation: ${error.message || error}`)
353+
if (!ctx.finished()) {
354+
this.codeServer.logger.debug(`${selector} navigation: ${(error as any).message || error}`)
373355
}
374356
}
375357
return false
@@ -423,7 +405,7 @@ export class CodeServerPage {
423405
return false
424406
}
425407
} catch (error) {
426-
logger.debug(`navigation: ${error.message || error}`)
408+
logger.debug(`navigation: ${(error as any).message || error}`)
427409
return false
428410
}
429411
}
@@ -436,7 +418,7 @@ export class CodeServerPage {
436418
// time we lose focus or there is an error.
437419
let attempts = 1
438420
let context = new Context()
439-
while (!(await Promise.race([openThenWaitClose(), navigate(context)]))) {
421+
while (!(await Promise.race([openThenWaitClose(context), navigate(context)]))) {
440422
++attempts
441423
logger.debug("closed, retrying (${attempt}/∞)")
442424
context.cancel()

vendor/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"postinstall": "./postinstall.sh"
88
},
99
"devDependencies": {
10-
"code-oss-dev": "coder/vscode#94384412221f432c15bb679315c49964925090be"
10+
"code-oss-dev": "coder/vscode#a13f6e1434ad6ab820eef0ecca5b923b3e275667"
1111
}
1212
}

0 commit comments

Comments
 (0)