Skip to content

Commit

Permalink
create build and test pipeline with Azure Pipelines (#21)
Browse files Browse the repository at this point in the history
* add azure-pipelines.yml
* update pipelines.yml
* update build.yml according to vscode sample
* correc to use vmImage for windows-2019
* update compile command to build only once
* fix typo for run tests command
* move steps into templates
* update template file path
* update template file path
* update template file path
* update templates and add file associations
* try run test script in document
* xvfb related changes for tests on Linux
* update yml
* update gitignore to ignore .vscode-test
* move package to separate step
* update job names
* turn off verbose flag for npm commands
* add triggers
* make publish artiface one of the steps
  • Loading branch information
kejxu committed May 2, 2019
1 parent e2ddc07 commit c26f6bc
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
@@ -1,2 +1,6 @@
# node.js
out
node_modules

# vscode-test
.vscode-test
7 changes: 6 additions & 1 deletion .vscode/settings.json
@@ -1,5 +1,10 @@
// Place your settings in this file to overwrite default and user settings.
// Workspace settings used to overwrite default and user settings
{
// build
"files.associations": {
"**/ci/**/*.yml": "azure-pipelines"
},

"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
Expand Down
87 changes: 87 additions & 0 deletions ci/azure-pipelines.yml
@@ -0,0 +1,87 @@
name: $(BuildID).$(Date:yyMMdd)$(Rev:.r)

# auto-trigger build on merge
trigger:
batch: false
branches:
include:
[
'master',
]
paths:
exclude:
[
'.vscode',
'.github',
'*.md',
]

# auto-trigger build on pull request
pr:
branches:
include:
[
'master',
]
paths:
exclude:
[
'.vscode',
'.github',
'*.md',
]

variables:
nodeVersion: '>=10.15.3'
npmVersion: 'latest'

jobs:
- job: Build_Ubuntu
pool:
vmImage: 'ubuntu-16.04'
demands: npm
steps:
- template: templates/setup-environment.yml
- template: templates/install-dependencies.yml
- template: templates/compile.yml
- script: |
set -e
/usr/bin/Xvfb :10 -ac >> /tmp/Xvfb.out 2>&1 &
disown -ar
displayName: 'Start xvfb'
- script: 'node node_modules/vscode/bin/test'
displayName: 'Run tests'
env:
DISPLAY: :10

- job: Build_macOS
pool:
vmImage: 'macOS-10.14'
demands: npm
steps:
- template: templates/setup-environment.yml
- template: templates/install-dependencies.yml
- template: templates/compile.yml
- script: |
node node_modules/vscode/bin/test
displayName: 'Run tests'
- job: Build_Windows
dependsOn:
[
'Build_Ubuntu',
'Build_macOS',
]
pool:
vmImage: 'windows-2019'
demands: npm
steps:
- template: templates/setup-environment.yml
- template: templates/install-dependencies.yml
- template: templates/compile.yml
- script: |
node node_modules/vscode/bin/test
displayName: 'Run tests'
# only publish artifact once
- template: templates/package-artifact.yml
8 changes: 8 additions & 0 deletions ci/templates/compile.yml
@@ -0,0 +1,8 @@
steps:
- task: Npm@1
displayName: 'Compile sources'
inputs:
command: custom
verbose: false
customCommand: |
run buildOnce
8 changes: 8 additions & 0 deletions ci/templates/install-dependencies.yml
@@ -0,0 +1,8 @@
steps:
- task: Npm@1
displayName: 'Install dependencies with package-lock.json'
inputs:
command: custom
verbose: false
customCommand: |
ci
40 changes: 40 additions & 0 deletions ci/templates/package-artifact.yml
@@ -0,0 +1,40 @@
steps:
- script: |
npm install --global vsce
displayName: 'Install vsce'
# condition:
# and(
# succeeded(),
# eq(variables['build'], 'true')
# )
- script: |
npm run package:dev
displayName: 'Create dev-version .vsix package'
# condition:
# and(
# succeeded(),
# eq(variables['build'], 'true')
# )
- task: CopyFiles@2
inputs:
contents: "*.vsix"
targetFolder: $(Build.ArtifactStagingDirectory)
displayName: "Stage .vsix"
# condition:
# and(
# succeeded(),
# eq(variables['build'], 'true')
# )

- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: VSIX
displayName: "Publish .vsix to Arifacts"
# condition:
# and(
# succeeded(),
# eq(variables['build'], 'true')
# )
4 changes: 4 additions & 0 deletions ci/templates/publish-test-results.yml
@@ -0,0 +1,4 @@
# steps:
# - task: PublishTestResults@2
# displayName: 'Publish tests results'
# inputs:
24 changes: 24 additions & 0 deletions ci/templates/setup-environment.yml
@@ -0,0 +1,24 @@
steps:
- bash: |
printenv
displayName: 'Dump environment variables'
condition: and(succeeded(), eq(variables['system.debug'], 'true'))
- task: NodeTool@0
displayName: 'Use Node version: $(nodeVersion)'
inputs:
versionSpec: $(nodeVersion)

- task: Npm@1
displayName: "Use NPM version: $(npmVersion)"
inputs:
command: custom
verbose: false
customCommand: |
install -g npm@$(npmVersion)
- bash: |
echo Node Version = `node --version`
echo NPM Version = `npm --version`
displayName: 'Check environment versions'
condition: and(succeeded(), eq(variables['system.debug'], 'true'))
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -211,7 +211,9 @@
]
},
"scripts": {
"buildOnce": "tsc -p ./",
"compile": "tsc -watch -p ./",
"package:dev": "vsce package -o vscode-ros-dev.vsix",
"postinstall": "node ./node_modules/vscode/bin/install",
"vscode:prepublish": "tsc -p ./"
},
Expand Down

0 comments on commit c26f6bc

Please sign in to comment.