-
-
Notifications
You must be signed in to change notification settings - Fork 23.2k
Setting Up CI With Azure Pipelines #3924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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'` | ||
|
|
||
| [ -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 | ||
| 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' |
| 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' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment.
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?