diff --git a/.gitignore b/.gitignore index 289503b..2f845bd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ out node_modules .vscode-test/ *.vsix -.ionide \ No newline at end of file +.ionide +test-output.xml \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5d04980..b48db59 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,25 +1,144 @@ trigger: + branches: + include: + - master +pr: - master -pool: - vmImage: 'ubuntu-latest' +jobs: +- job: Linux + pool: + name: ubuntu-latest + demands: npm + strategy: + matrix: + node_10_x: + node_version: 10.x + node_12_x: + node_version: 12.x + steps: + - task: NodeTool@0 + displayName: 'Use $(node_version)' + inputs: + versionSpec: $(node_version) -steps: -- task: NodeTool@0 - inputs: - versionSpec: '10.x' - displayName: 'Install Node.js' + - task: Npm@1 + displayName: 'Install dependencies' + inputs: + verbose: false + command: install -- script: | - npm install - npm run compile - displayName: 'npm install and build' + - task: Npm@1 + displayName: 'Compile Extension' + inputs: + command: custom + verbose: false + customCommand: 'run compile' -- script: | - npm run package -- -o release.vsix - displayName: 'create vsix' + # starts a process that allows the vscode test environment to run + - script: | + set -e + /usr/bin/Xvfb :10 -ac >> /tmp/Xvfb.out 2>&1 & + disown -ar + displayName: 'Start xvfb' -- task: PublishPipelineArtifact@0 - displayName: 'Publish Pipeline Artifact' - inputs: - targetPath: release.vsix \ No newline at end of file + - task: Npm@1 + displayName: 'Run tests via npm script' + inputs: + command: custom + verbose: false + customCommand: 'run test:ci' + env: + DISPLAY: :10 + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFiles: '*-results.xml' + testRunTitle: '$(Agent.OS)' + condition: succeededOrFailed() + + - script: | + npx vsce package -o release.vsix + displayName: 'create vsix' + + - task: PublishPipelineArtifact@0 + displayName: 'Publish Pipeline Artifact' + inputs: + targetPath: release.vsix + +- job: Windows + pool: + name: Hosted VS2017 + demands: npm + steps: + - task: NodeTool@0 + displayName: 'Use Node 10.x' + inputs: + versionSpec: 10.x + + - task: Npm@1 + displayName: 'Install dependencies' + inputs: + verbose: false + command: install + + - task: Npm@1 + displayName: 'Compile Extension' + inputs: + command: custom + verbose: false + customCommand: 'run compile' + + - task: Npm@1 + displayName: 'Run tests via npm script' + inputs: + command: custom + verbose: false + customCommand: 'run test:ci' + env: + DISPLAY: :10 + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFiles: '*-results.xml' + testRunTitle: '$(Agent.OS)' + condition: succeededOrFailed() + +- job: macOS + pool: + name: Hosted macOS + demands: npm + steps: + - task: NodeTool@0 + displayName: 'Use Node 10.x' + inputs: + versionSpec: 10.x + + - task: Npm@1 + displayName: 'Install dependencies' + inputs: + verbose: false + command: install + + - task: Npm@1 + displayName: 'Compile Extension' + inputs: + command: custom + verbose: false + customCommand: 'run compile' + + - task: Npm@1 + displayName: 'Run tests via npm script' + inputs: + command: custom + verbose: false + customCommand: 'run test:ci' + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFiles: '*-results.xml' + testRunTitle: '$(Agent.OS)' + condition: succeededOrFailed() diff --git a/package-lock.json b/package-lock.json index f626cc0..7390320 100644 --- a/package-lock.json +++ b/package-lock.json @@ -577,6 +577,12 @@ "verror": "1.10.0" } }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + }, "mime-db": { "version": "1.40.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", @@ -677,6 +683,16 @@ } } }, + "mocha-multi-reporters": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/mocha-multi-reporters/-/mocha-multi-reporters-1.1.7.tgz", + "integrity": "sha1-zH8/TTL0eFIJQdhSq7ZNmYhYfYI=", + "dev": true, + "requires": { + "debug": "^3.1.0", + "lodash": "^4.16.4" + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", diff --git a/package.json b/package.json index f54bad5..5767e17 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ "watch": "tsc -watch -p ./", "postinstall": "node ./node_modules/vscode/bin/install", "test": "npm run compile && node ./node_modules/vscode/bin/test", + "test:ci": "node ./node_modules/vscode/bin/test", "package": "npx vsce package", "publish": "npx vsce publish", "lint": "tslint --project tsconfig.json -e src/*.d.ts -t verbose" @@ -93,6 +94,7 @@ "@types/mocha": "^2.2.42", "@types/node": "^11.13.0", "chai": "^4.2.0", + "mocha-multi-reporters": "^1.1.7", "tslint": "^5.12.1", "typescript": "^3.3.1", "vscode": "^1.1.28" diff --git a/src/test/index.ts b/src/test/index.ts index b7b1655..122573c 100644 --- a/src/test/index.ts +++ b/src/test/index.ts @@ -11,6 +11,7 @@ // a possible error to the callback or null if none. import * as testRunner from "vscode/lib/testrunner"; +import * as path from "path"; // You can directly control Mocha options by configuring the test runner below // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options @@ -18,7 +19,14 @@ import * as testRunner from "vscode/lib/testrunner"; testRunner.configure({ ui: "tdd", // the TDD UI is being used in extension.test.ts (suite, test, etc.) useColors: true, // colored output from test results, - timeout: 7500 + timeout: 7500, + reporter: "mocha-multi-reporters", + reporterOptions: { + reporterEnabled: "spec, xunit", + xunitReporterOptions: { + output: path.join(__dirname, "..", "..", "test-results.xml") + } + } }); module.exports = testRunner;