diff --git a/.azure-pipelines/client.test.yml b/.azure-pipelines/client.test.yml new file mode 100644 index 0000000000..1c1fd14118 --- /dev/null +++ b/.azure-pipelines/client.test.yml @@ -0,0 +1,49 @@ +parameters: + name: '' + vmImage: '' + +jobs: + - job: ${{ format('Test_{0}', parameters.name) }} + dependsOn: + - 'Publish' + + pool: + vmImage: ${{ parameters.vmImage }} + + variables: + build.path: 'test/services/keyVault' + + strategy: + matrix: + Node6: + node.version: '6.x' + Node8: + node.version: '8.x' + Node10: + node.version: '10.x' + Node11: + node.version: '11.x' + + steps: + - task: NodeTool@0 + inputs: + versionSpec: '$(node.version)' + displayName: 'Install Node.js $(node.version)' + + - task: Npm@1 + inputs: + command: 'install' + displayName: 'npm install' + + - task: Npm@1 + inputs: + command: 'custom' + customCommand: 'run mocha -- $(build.path) --reporter mocha-junit-reporter' + displayName: 'npm run mocha' + + - task: PublishTestResults@2 + inputs: + testResultsFiles: '**/test-results.xml' + testRunTitle: ${{ format('{0} Node $(node.version)', parameters.name) }} + condition: succeededOrFailed() + displayName: 'Publish test results' diff --git a/.azure-pipelines/client.yml b/.azure-pipelines/client.yml new file mode 100644 index 0000000000..7cb32093d4 --- /dev/null +++ b/.azure-pipelines/client.yml @@ -0,0 +1,83 @@ +trigger: + - master + +variables: + node.version: '10.x' + build.path: 'lib/services/keyVault' + +jobs: + - job: 'Publish' + + pool: + vmImage: 'ubuntu-16.04' + + steps: + - task: NodeTool@0 + inputs: + versionSpec: '$(node.version)' + displayName: 'Install Node.js $(node.version)' + + - task: Npm@1 + inputs: + command: 'install' + workingDir: '$(build.path)' + displayName: 'npm install' + + - task: Npm@1 + inputs: + command: 'custom' + customCommand: 'pack' + workingDir: '$(build.path)' + displayName: 'npm pack' + + - task: CopyFiles@2 + inputs: + sourceFolder: '$(build.path)' + contents: '*.tgz' + targetFolder: $(Build.ArtifactStagingDirectory) + displayName: 'Copy Package' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Package' + + - job: 'Audit' + + pool: + vmImage: 'ubuntu-16.04' + + steps: + - task: NodeTool@0 + inputs: + versionSpec: '$(node.version)' + displayName: 'Install Node.js $(node.version)' + + - task: Npm@1 + inputs: + command: 'custom' + customCommand: 'i --package-lock-only' + workingDir: '$(build.path)' + displayName: 'npm i --package-lock-only' + + - powershell: "npm audit --json | ConvertFrom-Json | Select-Object -expandProperty 'metadata' | select-object -expandproperty 'vulnerabilities' | %{ if ($_.low + $_.moderate + $_.high + $_.critical -ne 0) { write-error 'FAILED! Your package has vulnerabilities. Check npm audit' }}" + workingDirectory: '$(build.path)' + displayName: 'npm audit' + + - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 + condition: succeededOrFailed() + displayName: 'Component Detection' + + - template: client.test.yml + parameters: + name: Linux + vmImage: 'ubuntu-16.04' + + - template: client.test.yml + parameters: + name: macOS + vmImage: 'macOS-10.13' + + - template: client.test.yml + parameters: + name: Windows + vmImage: 'vs2017-win2016' + diff --git a/.gitignore b/.gitignore index 7b45e47f78..37e0f7715b 100644 --- a/.gitignore +++ b/.gitignore @@ -55,4 +55,10 @@ packages # Coverage report coverage -.nyc_output \ No newline at end of file +.nyc_output + +# Output of 'npm pack' +*.tgz + +# Test Results +test-results.xml diff --git a/package.json b/package.json index 32457f2674..2d2d73b3b2 100644 --- a/package.json +++ b/package.json @@ -139,6 +139,7 @@ "json-stable-stringify": "^1.0.1", "minami": "devigned/minami#master", "mocha": "^5.2.0", + "mocha-junit-reporter": "^1.18.0", "nock": "0.16", "node-forge": "0.6.30", "nyc": "^11.2.1", @@ -168,6 +169,7 @@ "ci": "node scripts/unit.js testlist.txt", "runtime-install": "node scripts/runtime-install.js", "coverage": "node scripts/unit-coverage.js testlistarm.txt testlist.txt", - "debug": "node --inspect scripts/unit-arm.js testlistarm.txt" + "debug": "node --inspect scripts/unit-arm.js testlistarm.txt", + "mocha": "mocha" } }