Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions azure-pipelines-install-node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Template file to install node using NVM on linux and manual install on windows
steps:
- ${{ if eq(parameters.OS, 'unix') }}:
- script: |
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh -o install.sh
bash install.sh
export NVM_DIR="$HOME/.nvm"

# crude version selector since nvm doesn't support it
nodeVersion=`echo ${{ parameters.NODE_VERSION }} | sed -e 's/\.x$//g'`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this sed removes a ".x" on the end, but I couldn't figure out how that would end up on the version numbers. Did I misunderstand the sed here, or maybe just don't understand how the version numbers end up in this parameter?


[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install "$nodeVersion" || (echo "npm install failed"; exit 1)
nvm use "$nodeVersion"

# make the new set path to be available in subsequent steps
echo "##vso[task.setvariable variable=PATH;]$PATH"
displayName: "Install Node ${{ parameters.NODE_VERSION }}"
- ${{ if eq(parameters.OS, 'windows') }}:
- powershell: |
$nodeVersion = "${{ parameters.NODE_VERSION }}"
if($nodeVersion.ToLower().EndsWith(".x")) {
$nodeVersion = $nodeVersion.Substring(0, $nodeVersion.Length -1)
}
$targetDir = "c:\myiojs"
$iojsValues = '1.8','2.5','3.3'
if ("$nodeVersion" -In $iojsValues)
{
$distJsonUrl = "https://iojs.org/dist/index.json"
$baseName = "iojs"
$baseURL = "https://iojs.org/dist/"
$folderName = "iojs"
$isIOJS = $true
} else {
$distJsonUrl = "https://nodejs.org/dist/index.json"
$baseName = "node"
$baseURL = "https://nodejs.org/dist"
$folderName = "nodejs"
}

# Get Latest Version
$versionsList = Invoke-WebRequest -Uri $distJsonUrl
$versionsListObject = ConvertFrom-Json -InputObject $versionsList

$matchValues = $versionsListObject | Where-Object {$_.version -match "v$nodeVersion"}
$ver = $matchValues[0].version

Write-Output "Using version $ver"

if ("$ver".StartsWith("v0.10`.") -or "$ver".StartsWith("v0.12`."))
{
$msi = "$baseName-$ver-x86.msi"
}
else
{
$msi = "$baseName-$ver-x64.msi"
}

# Download MSI
$file = Join-Path "$(agent.tempDirectory)" "$msi"

$nodeUrl = "$baseURL/$ver/$msi"

Write-Output "Downloading $nodeUrl to $file"

Invoke-WebRequest -Uri $nodeUrl -OutFile $file

# extract files from MSI
$MSIArguments = @("/a", "$file", "/qn", "TARGETDIR=$targetDir")
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow

$nodejsDir = Join-Path "$targetDir" "$folderName"
$newPath = "$nodejsDir;$env:Path"
$installPath = $nodejsDir

# copy the file from iojs.exe to node.exe since everybody expects node to exist
if($isIOJS) {
$oldexe = Join-Path "$nodejsDir" "iojs.exe"
$newexe = Join-Path "$nodejsDir" "node.exe"
copy "$oldexe" "$newexe"
}

Write-Host "##vso[task.setvariable variable=PATH;]$newPath";
Write-Output ("##vso[task.setvariable variable=NPM_CONFIG_CACHE;]$installPath")
Write-Output ("##vso[task.setvariable variable=NPM_CONFIG_PREFIX;]$installPath")

displayName: "Install Node ${{ parameters.NODE_VERSION }}"
- ${{ if and(ne(parameters.OS, 'windows'),ne(parameters.OS, 'unix')) }}:
- script: |
echo ##vso[task.logissue type=error;]Invalid OS. Allowed values unix or windows.
exit 1
displayName: Invalid operating system
67 changes: 67 additions & 0 deletions azure-pipelines-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
steps:
- powershell: |
$nodeVersion = "${{ parameters.NODE_VERSION }}"
$nodeMajorVersion = $nodeVersion.split(".")[0]
Write-Output ("##vso[task.setvariable variable=NodeMajorVersion;]$nodeMajorVersion")
displayName: "Get Major Version Number of NodeJS Using PowerShell"

- template: azure-pipelines-install-node.yml
parameters:
NODE_VERSION : ${{ parameters.NODE_VERSION }}
OS: ${{ parameters.OS }}


#Start The Before Install Tasks
- script: |
node --version
npm config set shrinkwrap false
displayName: 'Skip updating shrinkwrap / lock'

- script: |
npm rm --silent --save-dev connect-redis
displayName: 'Remove all non-test dependencies'

- script: |
npm install --silent --save-dev mocha@3.5.3
displayName: 'Setup Node.js version-specific dependencies: mocha for testing: use 3.x for Node.js < 6'
condition: lt(variables['NodeMajorVersion'], 6)

- script: |
npm install --silent --save-dev supertest@2.0.0
displayName: 'Setup Node.js version-specific dependencies: supertest for http calls: use 2.0.0 for Node.js < 4'
condition: lt(variables['NodeMajorVersion'], 4)

- powershell: |
# Prune & rebuild node_modules
if (Test-Path -Path node_modules) {
npm prune
npm rebuild
}
displayName: 'Update Node.js modules'

#Finish With Before Install Tasks. Time to install dependencies
- script: |
npm install
displayName: 'npm install'

#Testing
- script: |
npm run test-ci
displayName: 'Run test script'

- script: |
npm run lint
displayName: 'Run linting'

- template: azure-pipelines-install-node.yml
parameters:
NODE_VERSION : 9.x
OS: ${{ parameters.OS }}

- script: |
npm install --save-dev coveralls@2.10.0
node_modules/.bin/coveralls < ./coverage/lcov.info
displayName: 'Upload coverage to coveralls'
env:
COVERALLS_REPO_TOKEN: $(coveralls.key.express)
COVERALLS_SERVICE_NAME: 'AzureDevOps'
74 changes: 74 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
jobs:
- job: Linux
strategy:
matrix:
Node.js 0.10:
NODE_VERSION: '0.10'
Node.js 0.12:
NODE_VERSION: '0.12'
Node.js 1.8:
NODE_VERSION: '1.8'
Node.js 2.5:
NODE_VERSION: '2.5'
Node.js 3.3:
NODE_VERSION: '3.3'
Node.js 4.9:
NODE_VERSION: '4.9'
Node.js 5.12:
NODE_VERSION: '5.12'
Node.js 6.14:
NODE_VERSION: '6.14'
Node.js 7.10:
NODE_VERSION: '7.10'
Node.js 8.12:
NODE_VERSION: '8.12'
Node.js 9:
NODE_VERSION: '9'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this downloading the nightly version like we currently do or is it now downloaded the last released version?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is not downloading the nightly version, it is downloading the latest released version. I could add that to my script which does the install.

The Node Tool task (mentioned earlier) also doesn't support nightly versions at this time.

Node.js 10:
NODE_VERSION: '10'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current config has a failure on this version not considered an overall failure. Is this sey up this way / is there a method to set that up? It is used a lot along with the nightlys as sometimes a bad version can get published which will stay until at least the next day.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So yes, I could make that work. What I would do is create a separate matrix for the ones that can fail and the build still be considered successful. If one of those builds then fails, I can mark the build as Partially Successful.

continueOnError: false
pool:
vmImage: 'ubuntu-16.04'

steps:
- template: "azure-pipelines-steps.yml"
parameters:
NODE_VERSION: $(NODE_VERSION)
OS: unix

- job: Windows
strategy:
matrix:
Node.js 0.10:
NODE_VERSION: '0.10'
Node.js 0.12:
NODE_VERSION: '0.12'
Node.js 1.8:
NODE_VERSION: '1.8'
Node.js 2.5:
NODE_VERSION: '2.5'
Node.js 3.3:
NODE_VERSION: '3.3'
Node.js 4.9:
NODE_VERSION: '4.9'
Node.js 5.12:
NODE_VERSION: '5.12'
Node.js 6.14:
NODE_VERSION: '6.14'
Node.js 7.10:
NODE_VERSION: '7.10'
Node.js 8.12:
NODE_VERSION: '8.12'
Node.js 9:
NODE_VERSION: '9'
Node.js 10:
NODE_VERSION: '10'
continueOnError: false
pool:
vmImage: 'vs2017-win2016'

steps:
- template: "azure-pipelines-steps.yml"
parameters:
NODE_VERSION: $(NODE_VERSION)
OS: windows