forked from mongodb-js/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
99 lines (88 loc) · 2.95 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
variables:
npm_config_cache: $(Pipeline.Workspace)/.npm-cache
node_version: '12.4.0'
trigger:
- master
# For current versions of vm's using the `*-latest` alias:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops
strategy:
matrix:
linux:
imageName: 'ubuntu-latest'
mac:
imageName: 'macos-latest'
windows:
imageName: 'windows-latest'
pool:
vmImage: $(imageName)
steps:
- script: |
set -e
sudo apt-get update
displayName: 'Install native Linux dependencies'
condition: in(variables['agent.os'], 'Linux')
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
displayName: 'Install node@$(node_version)'
# TODO (rhys): re-enable caching for npm.
# Proper caching for `npm ci` to be fast.
# https://docs.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops#nodejsnpm
# - task: Cache@2
# inputs:
# key: 'npm | "$(Agent.OS)" | package-lock.json'
# restoreKeys: |
# npm | "$(Agent.OS)"
# npm
# path: $(npm_config_cache)
# displayName: Cache npm
# TODO (lucas): Caching `./.vscode-test` in the future would be nice
# so vscode-test isn't downloading the vscode zip everytime. same goes for mongoddb-runner.
- task: Npm@1
displayName: 'Install npm dependencies'
- bash: npm run test
displayName: 'Run Tests'
env:
SEGMENT_KEY: $(segmentKey)
- bash: ls -alh
displayName: 'Post Tests'
- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: 'test*-results.xml'
failTaskOnFailedTests: true
- bash: |
npm i -g vsce;
vsce package
displayName: 'Build .vsix'
env:
SEGMENT_KEY: $(segmentKey)
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#set-variables-in-scripts
- bash: |
echo "##vso[task.setvariable variable=extension_version]`npx json -f package.json version`"
displayName: 'Set extension_version variable from package.json version'
- bash: |
vsixFilename=./mongodb-vscode-$(extension_version).vsix
maxsize=5000000 # 5MB
filesize=$(stat -c%s "$vsixFilename")
echo "Size of $vsixFilename = $filesize bytes."
if (( filesize > maxsize )); then
echo "File is over 5MB."
exit 1
fi
displayName: 'Check .vsix filesize'
# On linux create and publish a .vsix artifact for the build.
- task: CopyFiles@2
displayName: 'Copy vsix to staging directory'
inputs:
Contents: '**/*.vsix'
TargetFolder: '$(build.artifactstagingdirectory)'
condition: in(variables['agent.os'], 'Linux')
- task: PublishBuildArtifacts@1
displayName: 'Publish vsix artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: vsix
condition: in(variables['agent.os'], 'Linux')