From fd3cd9b3ff7f66e730aa7322780b50a9a960624e Mon Sep 17 00:00:00 2001 From: Dmitry Maslennikov Date: Thu, 25 Jun 2020 15:06:56 +0300 Subject: [PATCH 1/8] added github actions --- .github/workflows/main.yml | 152 +++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..c7c7207 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,152 @@ +name: CI + +on: + push: + branches: + - master + paths-ignore: + - '*.md' + - '**/*.md' + pull_request: + branches: + - master + release: + types: + - created +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + steps: + - uses: actions/checkout@master + - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + - name: Set an output + id: set-version + if: runner.os == 'Linux' + run: | + set -x + VERSION=$(jq -r '.version' package.json | cut -d- -f1) + [ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/} + CHANGELOG=$(cat CHANGELOG.md | sed -n "/## \[${VERSION}\]/,/## /p" | sed '/^$/d;1d;$d') + CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" + echo ::set-output name=changelog::$CHANGELOG + git tag -l | cat + [ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1)) + [ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev + echo ::set-output name=version::$VERSION + NAME=$(jq -r '.name' package.json)-$VERSION + echo ::set-output name=name::$NAME + tmp=$(mktemp) + jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json + mkdir dist + echo $VERSION > ./dist/.version + echo $NAME > ./dist/.name + - name: Use Node.js + uses: actions/setup-node@master + with: + node-version: 12.x + - run: npm install + - run: npm run compile + - name: npm test + uses: GabrielBB/xvfb-action@v1.0 + with: + run: npm run test + - name: Build package + if: runner.os == 'Linux' + run: | + ./node_modules/.bin/vsce package -o ./dist/package.vsix + - uses: actions/upload-artifact@master + if: runner.os == 'Linux' + with: + name: vsix + path: ./dist/ + beta: + if: (github.event_name == 'push') + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/download-artifact@master + with: + name: vsix + path: ./dist/ + - name: Set an output + id: set-version + if: runner.os == 'Linux' + run: | + set -x + echo ::set-output name=version::`cat ./dist/.version` + echo ::set-output name=name::`cat ./dist/.name` + - name: Create Release + id: create_release + uses: actions/create-release@master + if: runner.os == 'Linux' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ steps.set-version.outputs.version }} + release_name: v${{ steps.set-version.outputs.version }} + prerelease: ${{ github.event_name != 'release' }} + body: | + Changes in this release + ${{ steps.set-version.outputs.changelog }} + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@master + if: runner.os == 'Linux' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./dist/package.vsix + asset_name: ${{ steps.set-version.outputs.name }}.vsix + asset_content_type: application/zip + publish: + if: github.event_name == 'release' + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v2 + with: + ref: master + - uses: actions/download-artifact@master + with: + name: vsix + path: ./dist/ + - name: Use Node.js + uses: actions/setup-node@master + with: + node-version: 12.x + - name: Prepare build + id: set-version + run: | + VERSION=`cat ./dist/.version` + echo ::set-output name=name::`cat ./dist/.name` + tmp=$(mktemp) + git config --global user.name 'ProjectBot' + git config --global user.email 'bot@users.noreply.github.com' + jq --arg version "${VERSION}-SNAPSHOT" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json + git add package.json + git commit -m 'auto bump version with release' + jq --arg version "$VERSION" '.version = $version' package.json > "$tmp" && mv "$tmp" package.json + jq '.enableProposedApi = false' package.json > "$tmp" && mv "$tmp" package.json + npm install + npm i -g vsce ovsx + git push + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@master + if: runner.os == 'Linux' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./dist/package.vsix + asset_name: ${{ steps.set-version.outputs.name }}.vsix + asset_content_type: application/zip + - name: Publish to Marketplaces + run: | + vsce publish -p ${{ secrets.VSCE_TOKEN }} + ovsx publish --pat ${{ secrets.OVSX_TOKEN }} + From 35e701697aae209a61b4d0f9138172b47e8cd605 Mon Sep 17 00:00:00 2001 From: Dmitry Maslennikov Date: Thu, 25 Jun 2020 15:14:47 +0300 Subject: [PATCH 2/8] simple tests --- package-lock.json | 93 ++---------------------------------- package.json | 16 +++++-- test/runTest.ts | 25 ++++++++++ test/suite/extension.test.ts | 18 +++++++ test/suite/index.ts | 37 ++++++++++++++ 5 files changed, 96 insertions(+), 93 deletions(-) create mode 100644 test/runTest.ts create mode 100644 test/suite/extension.test.ts create mode 100644 test/suite/index.ts diff --git a/package-lock.json b/package-lock.json index a3907cd..2867448 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "intersystems.servermanager", - "version": "0.0.1", + "name": "servermanager", + "version": "0.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -103,17 +103,6 @@ "picomatch": "^2.0.4" } }, - "applicationinsights": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/applicationinsights/-/applicationinsights-1.7.4.tgz", - "integrity": "sha512-XFLsNlcanpjFhHNvVWEfcm6hr7lu9znnb6Le1Lk5RE03YUV9X2B2n2MfM4kJZRrUdV+C0hdHxvWyv+vWoLfY7A==", - "requires": { - "cls-hooked": "^4.2.2", - "continuation-local-storage": "^3.2.1", - "diagnostic-channel": "0.2.0", - "diagnostic-channel-publishers": "^0.3.3" - } - }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -123,23 +112,6 @@ "sprintf-js": "~1.0.2" } }, - "async-hook-jl": { - "version": "1.7.6", - "resolved": "https://registry.npmjs.org/async-hook-jl/-/async-hook-jl-1.7.6.tgz", - "integrity": "sha512-gFaHkFfSxTjvoxDMYqDuGHlcRyUuamF8s+ZTtJdDzqjws4mCt7v0vuV79/E2Wr2/riMQgtG4/yUtXWs1gZ7JMg==", - "requires": { - "stack-chain": "^1.3.7" - } - }, - "async-listener": { - "version": "0.6.10", - "resolved": "https://registry.npmjs.org/async-listener/-/async-listener-0.6.10.tgz", - "integrity": "sha512-gpuo6xOyF4D5DE5WvyqZdPA3NGhiT6Qf07l7DCB0wwDEsLvDIbCr6j9S5aj5Ch96dLace5tXVzWBZkxU/c5ohw==", - "requires": { - "semver": "^5.3.0", - "shimmer": "^1.1.0" - } - }, "azure-devops-node-api": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/azure-devops-node-api/-/azure-devops-node-api-7.2.0.tgz", @@ -310,16 +282,6 @@ } } }, - "cls-hooked": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/cls-hooked/-/cls-hooked-4.2.2.tgz", - "integrity": "sha512-J4Xj5f5wq/4jAvcdgoGsL3G103BtWpZrMo8NEinRltN+xpTZdI+M38pyQqhuFU/P792xkMFvnKSf+Lm81U1bxw==", - "requires": { - "async-hook-jl": "^1.7.6", - "emitter-listener": "^1.0.1", - "semver": "^5.4.1" - } - }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -347,15 +309,6 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "continuation-local-storage": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/continuation-local-storage/-/continuation-local-storage-3.2.1.tgz", - "integrity": "sha512-jx44cconVqkCEEyLSKWwkvUXwO561jXMa3LPjTPsm5QR22PA0/mhe33FT4Xb5y74JDvt/Cq+5lm8S8rskLv9ZA==", - "requires": { - "async-listener": "^0.6.0", - "emitter-listener": "^1.1.1" - } - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -410,19 +363,6 @@ "integrity": "sha1-OjYof1A05pnnV3kBBSwubJQlFjE=", "dev": true }, - "diagnostic-channel": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/diagnostic-channel/-/diagnostic-channel-0.2.0.tgz", - "integrity": "sha1-zJmvlhLCP7H/8TYSxy8sv6qNWhc=", - "requires": { - "semver": "^5.3.0" - } - }, - "diagnostic-channel-publishers": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/diagnostic-channel-publishers/-/diagnostic-channel-publishers-0.3.5.tgz", - "integrity": "sha512-AOIjw4T7Nxl0G2BoBPhkQ6i7T4bUd9+xvdYizwvG7vVAM1dvr+SDrcUudlmzwH0kbEwdR2V1EcnKT0wAeYLQNQ==" - }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", @@ -464,14 +404,6 @@ "domelementtype": "1" } }, - "emitter-listener": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/emitter-listener/-/emitter-listener-1.1.2.tgz", - "integrity": "sha512-Bt1sBAGFHY9DKY+4/2cV6izcKJUf5T7/gkdmkxzX/qv9CcGH8xSwVRW5mtX03SWJtRTWSOpzCuWN9rBFYZepZQ==", - "requires": { - "shimmer": "^1.2.0" - } - }, "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", @@ -1319,7 +1251,8 @@ "semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true }, "set-blocking": { "version": "2.0.0", @@ -1327,22 +1260,12 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, - "shimmer": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.1.tgz", - "integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==" - }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "stack-chain": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-1.3.7.tgz", - "integrity": "sha1-0ZLJ/06moiyUxN1FkXHj8AzqEoU=" - }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -1591,14 +1514,6 @@ "yazl": "^2.2.2" } }, - "vscode-extension-telemetry": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/vscode-extension-telemetry/-/vscode-extension-telemetry-0.1.6.tgz", - "integrity": "sha512-rbzSg7k4NnsCdF4Lz0gI4jl3JLXR0hnlmfFgsY8CSDYhXgdoIxcre8jw5rjkobY0xhSDhbG7xCjP8zxskySJ/g==", - "requires": { - "applicationinsights": "1.7.4" - } - }, "vscode-test": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/vscode-test/-/vscode-test-1.4.0.tgz", diff --git a/package.json b/package.json index dbe4262..ae3801b 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,10 @@ "scheme": { "type": "string", "description": "Protocol used for connections.", - "enum": ["http", "https"], + "enum": [ + "http", + "https" + ], "default": "http" }, "host": { @@ -134,7 +137,10 @@ "description": "Optional prefix for the path to the resource. Only needed when one web server publishes services on behalf of multiple InterSystems® servers." } }, - "required": ["host", "port"], + "required": [ + "host", + "port" + ], "additionalProperties": false }, "username": { @@ -150,7 +156,9 @@ "description": "Optional description of the server." } }, - "required": ["webServer"], + "required": [ + "webServer" + ], "additionalProperties": false } }, @@ -158,7 +166,7 @@ "/default": { "type": "string", "description": "Name of the default server." - } + } }, "additionalProperties": false } diff --git a/test/runTest.ts b/test/runTest.ts new file mode 100644 index 0000000..113f7cd --- /dev/null +++ b/test/runTest.ts @@ -0,0 +1,25 @@ +import * as path from "path"; + +import { runTests } from "vscode-test"; + +async function main() { + try { + // The folder containing the Extension Manifest package.json + // Passed to `--extensionDevelopmentPath` + const extensionDevelopmentPath = path.resolve(__dirname, "../../"); + + // The path to the extension test script + // Passed to --extensionTestsPath + const extensionTestsPath = path.resolve(__dirname, "./suite/index"); + + const launchArgs = ["--enable-proposed-api", "intersystems.servermanager"]; + + // Download VS Code, unzip it and run the integration test + await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs }); + } catch (err) { + console.error("Failed to run tests", err); + process.exit(1); + } +} + +main(); diff --git a/test/suite/extension.test.ts b/test/suite/extension.test.ts new file mode 100644 index 0000000..6d05ab7 --- /dev/null +++ b/test/suite/extension.test.ts @@ -0,0 +1,18 @@ +import * as assert from "assert"; +import { before } from "mocha"; + +// You can import and use all API from the 'vscode' module +// as well as import your extension to test it +import * as vscode from "vscode"; +// import * as myExtension from '../extension'; + +suite("Extension Test Suite", () => { + before(() => { + vscode.window.showInformationMessage("Start all tests."); + }); + + test("Sample test", () => { + assert.equal([1, 2, 3].indexOf(5), -1); + assert.equal([1, 2, 3].indexOf(0), -1); + }); +}); diff --git a/test/suite/index.ts b/test/suite/index.ts new file mode 100644 index 0000000..c87081f --- /dev/null +++ b/test/suite/index.ts @@ -0,0 +1,37 @@ +import * as path from "path"; +import * as Mocha from "mocha"; +import * as glob from "glob"; + +export function run(): Promise { + // Create the mocha test + const mocha = new Mocha({ + ui: "tdd", + }); + mocha.useColors(true); + + const testsRoot = path.resolve(__dirname, ".."); + + return new Promise((c, e) => { + glob("**/**.test.js", { cwd: testsRoot }, (err, files) => { + if (err) { + return e(err); + } + + // Add files to the test suite + files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); + + try { + // Run the mocha test + mocha.run(failures => { + if (failures > 0) { + e(new Error(`${failures} tests failed.`)); + } else { + c(); + } + }); + } catch (err) { + e(err); + } + }); + }); +} From 4d26545629b2764bbcc94942bc70f32296b97879 Mon Sep 17 00:00:00 2001 From: Dmitry Maslennikov Date: Thu, 25 Jun 2020 15:22:07 +0300 Subject: [PATCH 3/8] added keywords, and fixed compilation outDir --- package.json | 2 ++ tsconfig.json | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ae3801b..16121f1 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ }, "license": "MIT", "keywords": [ + "intersystems", + "objectscript", "multi-root ready" ], "engines": { diff --git a/tsconfig.json b/tsconfig.json index be4a5bb..9791640 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,17 +2,16 @@ "compilerOptions": { "module": "commonjs", "target": "es2016", - "noImplicitAny": false, "removeComments": false, "noUnusedLocals": true, "noImplicitThis": true, "inlineSourceMap": false, "sourceMap": true, - "outDir": "../out", + "outDir": "out", "preserveConstEnums": true, "strictNullChecks": true, "noUnusedParameters": false }, - "exclude": ["node_modules"] + "exclude": ["node_modules", ".vscode-test"] } From 010b9c93242a890c750674755a8a98aa54d1aadb Mon Sep 17 00:00:00 2001 From: Dmitry Maslennikov Date: Thu, 25 Jun 2020 15:37:08 +0300 Subject: [PATCH 4/8] updated vscodeignore --- .vscodeignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.vscodeignore b/.vscodeignore index 3345558..3d5e559 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,2 +1,10 @@ +.github/** +.vscode/** +.vscode-test/** +out/test/** **/*.ts +**/*.map +.gitignore **/tsconfig.json +**/tslint.json +**/.eslintrc.json From 2e42b0b9fc153cb6e0b3e8a88030bd58e8a2aeea Mon Sep 17 00:00:00 2001 From: Dmitry Maslennikov Date: Thu, 25 Jun 2020 16:01:59 +0300 Subject: [PATCH 5/8] just moved test to src --- {test => src/test}/runTest.ts | 0 {test => src/test}/suite/extension.test.ts | 0 {test => src/test}/suite/index.ts | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {test => src/test}/runTest.ts (100%) rename {test => src/test}/suite/extension.test.ts (100%) rename {test => src/test}/suite/index.ts (100%) diff --git a/test/runTest.ts b/src/test/runTest.ts similarity index 100% rename from test/runTest.ts rename to src/test/runTest.ts diff --git a/test/suite/extension.test.ts b/src/test/suite/extension.test.ts similarity index 100% rename from test/suite/extension.test.ts rename to src/test/suite/extension.test.ts diff --git a/test/suite/index.ts b/src/test/suite/index.ts similarity index 100% rename from test/suite/index.ts rename to src/test/suite/index.ts From 5d2751bce20e2aa8dfa0f61edc2087ea1269ce5b Mon Sep 17 00:00:00 2001 From: Dmitry Maslennikov Date: Fri, 26 Jun 2020 17:50:02 +0300 Subject: [PATCH 6/8] check for activation extension --- src/extension.ts | 1 + src/test/suite/extension.test.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 2d99392..2161a90 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,4 +1,5 @@ 'use strict'; +export const extensionId = "intersystems.servermanager"; import * as vscode from 'vscode'; diff --git a/src/test/suite/extension.test.ts b/src/test/suite/extension.test.ts index 6d05ab7..5c708d1 100644 --- a/src/test/suite/extension.test.ts +++ b/src/test/suite/extension.test.ts @@ -3,12 +3,18 @@ import { before } from "mocha"; // You can import and use all API from the 'vscode' module // as well as import your extension to test it -import * as vscode from "vscode"; -// import * as myExtension from '../extension'; +import { window, extensions } from "vscode"; +import { extensionId } from "../../extension"; suite("Extension Test Suite", () => { + suiteSetup(async function () { + // make sure git is activated + const ext = extensions.getExtension(extensionId); + await ext?.activate(); + }); + before(() => { - vscode.window.showInformationMessage("Start all tests."); + window.showInformationMessage("Start all tests."); }); test("Sample test", () => { From f8ec3b916244f1bd3154389a001dda7db2f4cd1d Mon Sep 17 00:00:00 2001 From: Dmitry Maslennikov Date: Fri, 26 Jun 2020 18:06:29 +0300 Subject: [PATCH 7/8] removed mentioing proposed api --- src/test/runTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/runTest.ts b/src/test/runTest.ts index 113f7cd..888dadb 100644 --- a/src/test/runTest.ts +++ b/src/test/runTest.ts @@ -12,7 +12,7 @@ async function main() { // Passed to --extensionTestsPath const extensionTestsPath = path.resolve(__dirname, "./suite/index"); - const launchArgs = ["--enable-proposed-api", "intersystems.servermanager"]; + const launchArgs = []; // Download VS Code, unzip it and run the integration test await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs }); From 94c46e58d40d72a47d13659fcbdce92cf5de4afd Mon Sep 17 00:00:00 2001 From: Dmitry Maslennikov Date: Fri, 26 Jun 2020 18:07:41 +0300 Subject: [PATCH 8/8] changed publisher --- src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 2161a90..b57bb6e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,5 +1,5 @@ 'use strict'; -export const extensionId = "intersystems.servermanager"; +export const extensionId = "intersystems-community.servermanager"; import * as vscode from 'vscode';