From 855de8f09ef41909dc65a51adf4b954272a51dd2 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 9 Aug 2023 18:06:11 -0700 Subject: ci: :green_heart: testing testing in ci --- .github/workflows/main.yaml | 84 ++++++++++++----------- .vscode/launch.json | 31 +++------ extension/src/continueIdeClient.ts | 13 ++-- extension/src/test-suite/environmentSetup.test.ts | 12 ++-- 4 files changed, 69 insertions(+), 71 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 03c33dba..9431e878 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -3,8 +3,7 @@ name: Publish Extension on: push: branches: - - main - - package-python + - ci-testing jobs: pyinstaller: @@ -99,43 +98,48 @@ jobs: cd extension/react-app npm ci --legacy-peer-deps - - name: Build and Publish + - name: Test extension run: | cd extension - npm run package - npx vsce publish patch -p ${{ secrets.VSCE_TOKEN }} - - name: Commit changes - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git commit -am "ci: 💚 Update package.json version [skip ci]" - - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref }} - - - name: Upload .vsix artifact - uses: actions/upload-artifact@v2 - with: - name: vsix-artifact - path: extension/build/* - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - - name: Upload binaries to S3 - uses: jakejarvis/s3-sync-action@master - with: - args: --acl public-read --follow-symlinks --delete - env: - AWS_S3_BUCKET: continue-server-binaries - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: "us-west-1" - SOURCE_DIR: "exe" + npm run test + + # - name: Build and Publish + # run: | + # cd extension + # npm run package + # npx vsce publish patch -p ${{ secrets.VSCE_TOKEN }} + # - name: Commit changes + # run: | + # git config --local user.email "action@github.com" + # git config --local user.name "GitHub Action" + # git commit -am "ci: 💚 Update package.json version [skip ci]" + + # - name: Push changes + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ github.ref }} + + # - name: Upload .vsix artifact + # uses: actions/upload-artifact@v2 + # with: + # name: vsix-artifact + # path: extension/build/* + + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v1 + # with: + # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # aws-region: us-west-2 + + # - name: Upload binaries to S3 + # uses: jakejarvis/s3-sync-action@master + # with: + # args: --acl public-read --follow-symlinks --delete + # env: + # AWS_S3_BUCKET: continue-server-binaries + # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # AWS_REGION: "us-west-1" + # SOURCE_DIR: "exe" diff --git a/.vscode/launch.json b/.vscode/launch.json index bbe1fd2e..12cfaef8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,18 +7,12 @@ { "name": "Server + Extension (VSCode)", "stopAll": true, - "configurations": [ - "Server", - "Extension (VSCode)" - ] + "configurations": ["Server", "Extension (VSCode)"] }, { "name": "Server + Tests (VSCode)", "stopAll": true, - "configurations": [ - "Server", - "Tests (VSCode)" - ] + "configurations": ["Server", "Tests (VSCode)"] } ], "configurations": [ @@ -27,12 +21,9 @@ "type": "python", "request": "launch", "module": "continuedev.src.continuedev.server.main", - "args": [ - "--port", - "8001" - ], + "args": ["--port", "8001"], "justMyCode": false, - "subProcess": false, + "subProcess": false // Does it need a build task? // What about a watch task? - type errors? }, @@ -45,11 +36,9 @@ // Pass a directory to manually test in "${workspaceFolder}/extension/manual-testing-sandbox", "${workspaceFolder}/extension/manual-testing-sandbox/example.ts", - "--extensionDevelopmentPath=${workspaceFolder}/extension", - ], - "outFiles": [ - "${workspaceFolder}/extension/out/**/*.js" + "--extensionDevelopmentPath=${workspaceFolder}/extension" ], + "outFiles": ["${workspaceFolder}/extension/out/**/*.js"], "preLaunchTask": "vscode-extension:build", "env": { "CONTINUE_SERVER_URL": "http://localhost:8001" @@ -77,10 +66,10 @@ "internalConsoleOptions": "openOnSessionStart", "preLaunchTask": "vscode-extension:tests:build", "env": { - "CONTINUE_SERVER_URL": "http://localhost:8001", + "CONTINUE_SERVER_URL": "http://localhost:65432", // Avoid timing out when stopping on breakpoints during debugging in VSCode - "MOCHA_TIMEOUT": "0", - }, + "MOCHA_TIMEOUT": "0" + } } ] -} \ No newline at end of file +} diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index d89093ca..5b9e285d 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -12,7 +12,7 @@ import { rejectSuggestionCommand, } from "./suggestions"; import { FileEditWithFullContents } from "../schema/FileEditWithFullContents"; -import * as fs from 'fs'; +import * as fs from "fs"; import { WebsocketMessenger } from "./util/messenger"; import { diffManager } from "./diffs"; const os = require("os"); @@ -30,13 +30,12 @@ class IdeProtocolClient { private _lastReloadTime: number = 16; private _reconnectionTimeouts: NodeJS.Timeout[] = []; - private _sessionId: string | null = null; + sessionId: string | null = null; private _serverUrl: string; private _newWebsocketMessenger() { const requestUrl = - this._serverUrl + - (this._sessionId ? `?session_id=${this._sessionId}` : ""); + this._serverUrl + (this.sessionId ? `?session_id=${this.sessionId}` : ""); const messenger = new WebsocketMessenger(requestUrl); this.messenger = messenger; @@ -383,7 +382,9 @@ class IdeProtocolClient { async getUserSecret(key: string) { // Check if secret already exists in VS Code settings (global) let secret = vscode.workspace.getConfiguration("continue").get(key); - if (typeof secret !== "undefined" && secret !== null) {return secret;} + if (typeof secret !== "undefined" && secret !== null) { + return secret; + } // If not, ask user for secret secret = await vscode.window.showInputBox({ @@ -420,7 +421,7 @@ class IdeProtocolClient { console.log("Getting session ID"); const resp = await this.messenger?.sendAndReceive("getSessionId", {}); console.log("New Continue session with ID: ", resp.sessionId); - this._sessionId = resp.sessionId; + this.sessionId = resp.sessionId; return resp.sessionId; } diff --git a/extension/src/test-suite/environmentSetup.test.ts b/extension/src/test-suite/environmentSetup.test.ts index 9a478522..a6aa3433 100644 --- a/extension/src/test-suite/environmentSetup.test.ts +++ b/extension/src/test-suite/environmentSetup.test.ts @@ -2,18 +2,22 @@ import { test, describe } from "mocha"; import * as assert from "assert"; import { getContinueServerUrl } from "../bridge"; -import { startContinuePythonServer } from "../activation/environmentSetup"; +import { ideProtocolClient } from "../activation/activate"; import fetch from "node-fetch"; +import fkill from "fkill"; describe("Can start python server", () => { test("Can start python server in under 10 seconds", async function () { - this.timeout(17_000); - await startContinuePythonServer(); + fkill(65432, { force: true, silent: true }); + const allowedTime = 10_000; + this.timeout(allowedTime + 1000); - await new Promise((resolve) => setTimeout(resolve, 15_000)); + // If successful, the server is started by the extension while we wait + await new Promise((resolve) => setTimeout(resolve, allowedTime)); // Check if server is running const serverUrl = getContinueServerUrl(); + console.log("Server URL: ", serverUrl); const response = await fetch(`${serverUrl}/health`); assert.equal(response.status, 200); }); -- cgit v1.2.3-70-g09d2