From 4e133114610dbfc66cd43b2703885b39cf1ca534 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Tue, 5 Dec 2023 09:32:00 -0500 Subject: [PATCH] Add missing OS to our CI --- .github/workflows/ci.yml | 25 +++++++++++++++++++--- src/test/suite/client.test.ts | 38 ++++++++++++++++++++++++--------- src/test/suite/debugger.test.ts | 2 +- src/test/suite/ruby.test.ts | 12 ++++++----- 4 files changed, 58 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b9799c7..7d4b5973 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,8 +3,29 @@ name: CI on: [push, pull_request] jobs: - build: + lint: runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: "18" + cache: "yarn" + + - name: 📦 Install dependencies + run: yarn --frozen-lockfile + + - name: Lint + run: yarn run lint + + build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -24,8 +45,6 @@ jobs: - name: 📦 Install dependencies run: yarn --frozen-lockfile - - run: yarn run lint - - run: /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - run: yarn run test env: diff --git a/src/test/suite/client.test.ts b/src/test/suite/client.test.ts index 3da37b6b..e2894d59 100644 --- a/src/test/suite/client.test.ts +++ b/src/test/suite/client.test.ts @@ -29,13 +29,6 @@ suite("Client", () => { let client: Client | undefined; const managerConfig = vscode.workspace.getConfiguration("rubyLsp"); const currentManager = managerConfig.get("rubyVersionManager"); - const tmpPath = fs.mkdtempSync(path.join(os.tmpdir(), "ruby-lsp-test-")); - const workspaceFolder: vscode.WorkspaceFolder = { - uri: vscode.Uri.parse(`file://${tmpPath}`), - name: path.basename(tmpPath), - index: 0, - }; - fs.writeFileSync(path.join(tmpPath, ".ruby-version"), "3.2.2"); afterEach(async () => { if (client && client.state === State.Running) { @@ -44,7 +37,6 @@ suite("Client", () => { } managerConfig.update("rubyVersionManager", currentManager, true, true); - fs.rmSync(tmpPath, { recursive: true, force: true }); }); test("Starting up the server succeeds", async () => { @@ -58,6 +50,14 @@ suite("Client", () => { ); } + const tmpPath = fs.mkdtempSync(path.join(os.tmpdir(), "ruby-lsp-test-")); + const workspaceFolder: vscode.WorkspaceFolder = { + uri: vscode.Uri.from({ scheme: "file", path: tmpPath }), + name: path.basename(tmpPath), + index: 0, + }; + fs.writeFileSync(path.join(tmpPath, ".ruby-version"), "3.2.2"); + const context = { extensionMode: vscode.ExtensionMode.Test, subscriptions: [], @@ -83,7 +83,25 @@ suite("Client", () => { () => {}, workspaceFolder, ); - await client.start(); + + try { + await client.start(); + } catch (error: any) { + assert.fail(`Failed to start server ${error.message}`); + } assert.strictEqual(client.state, State.Running); - }).timeout(30000); + + try { + await client.stop(); + await client.dispose(); + } catch (error: any) { + assert.fail(`Failed to stop server: ${error.message}`); + } + + try { + fs.rmSync(tmpPath, { recursive: true, force: true }); + } catch (error: any) { + // On Windows, sometimes removing the directory fails with EBUSY on CI + } + }).timeout(60000); }); diff --git a/src/test/suite/debugger.test.ts b/src/test/suite/debugger.test.ts index c5df9be7..72343ec1 100644 --- a/src/test/suite/debugger.test.ts +++ b/src/test/suite/debugger.test.ts @@ -125,7 +125,7 @@ suite("Debugger", () => { { parallel: "1", ...ruby.env, - BUNDLE_GEMFILE: `${tmpPath}/.ruby-lsp/Gemfile`, + BUNDLE_GEMFILE: path.join(tmpPath, ".ruby-lsp", "Gemfile"), }, configs.env, ); diff --git a/src/test/suite/ruby.test.ts b/src/test/suite/ruby.test.ts index 22778a9f..5de90527 100644 --- a/src/test/suite/ruby.test.ts +++ b/src/test/suite/ruby.test.ts @@ -11,8 +11,10 @@ suite("Ruby environment activation", () => { let ruby: Ruby; test("Activate fetches Ruby information when outside of Ruby LSP", async () => { - // eslint-disable-next-line no-process-env - process.env.SHELL = "/bin/bash"; + if (os.platform() !== "win32") { + // eslint-disable-next-line no-process-env + process.env.SHELL = "/bin/bash"; + } const tmpPath = fs.mkdtempSync(path.join(os.tmpdir(), "ruby-lsp-test-")); fs.writeFileSync(path.join(tmpPath, ".ruby-version"), "3.2.2"); @@ -30,10 +32,10 @@ suite("Ruby environment activation", () => { ); assert.ok(ruby.rubyVersion, "Expected Ruby version to be set"); - assert.strictEqual( + assert.notStrictEqual( ruby.supportsYjit, - true, - "Expected YJIT support to be enabled", + undefined, + "Expected YJIT support to be set to true or false", ); fs.rmSync(tmpPath, { recursive: true, force: true });