Skip to content

Commit

Permalink
Use different Node versions for build and test (Azure#8804)
Browse files Browse the repository at this point in the history
- Update pnpm to latest (known to fail on Node 8)
- Reinstall packages with native dependencies after swapping node version
- Delete Rush install folder after swapping node versions
  - Workaround for microsoft/rushstack#1878
  • Loading branch information
mikeharder authored May 20, 2020
1 parent 4997350 commit f323b68
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 17 deletions.
14 changes: 8 additions & 6 deletions eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ parameters:
Matrix:
Linux_Node8:
OSVmImage: "ubuntu-18.04"
NodeVersion: "8.x"
NodeTestVersion: "8.x"
TestType: "node"
Windows_Node10:
OSVmImage: "windows-2019"
NodeVersion: "10.x"
NodeTestVersion: "10.x"
TestType: "node"
macOS_Node12:
OSVmImage: "macOS-10.15"
NodeVersion: "12.x"
NodeTestVersion: "12.x"
TestType: "node"
Browser_Linux_Node12:
OSVmImage: "ubuntu-18.04"
NodeVersion: "12.x"
NodeTestVersion: "12.x"
TestType: "browser"

jobs:
Expand Down Expand Up @@ -221,6 +221,8 @@ jobs:
node eng/tools/rush-runner.js build:test --verbose -p max
displayName: "Build test assets"
- template: ../steps/use-node-test-version.yml

# Option "-p max" ensures parallelism is set to the number of cores on all platforms, which improves build times.
# The default on Windows is "cores - 1" (microsoft/rushstack#436).
- script: |
Expand Down Expand Up @@ -258,7 +260,7 @@ jobs:
inputs:
searchFolder: '$(System.DefaultWorkingDirectory)/sdk'
testResultsFiles: "**/test-results.xml"
testRunTitle: "$(OSName) - NodeJS - Unit Tests - [Node $(NodeVersion)]"
testRunTitle: "$(OSName) - NodeJS - Unit Tests - [Node $(NodeTestVersion)]"
condition: and(always(),eq(variables['TestType'], 'node'))
displayName: "Publish NodeJS unit test results"

Expand All @@ -268,6 +270,6 @@ jobs:
inputs:
searchFolder: '$(System.DefaultWorkingDirectory)/sdk'
testResultsFiles: "**/test-results.browser.xml"
testRunTitle: "$(OSName) - Browser - Unit Tests - [Node $(NodeVersion)]"
testRunTitle: "$(OSName) - Browser - Unit Tests - [Node $(NodeTestVersion)]"
condition: and(always(),eq(variables['TestType'], 'browser'))
displayName: "Publish browser unit test results"
16 changes: 9 additions & 7 deletions eng/pipelines/templates/jobs/archetype-sdk-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ parameters:
Linux Node 8:
OSVmImage: "ubuntu-18.04"
TestType: "node"
NodeVersion: "8.x"
NodeTestVersion: "8.x"
PublishCodeCoverage: true
Windows Node 10:
OSVmImage: "windows-2019"
TestType: "node"
NodeVersion: "10.x"
NodeTestVersion: "10.x"
MacOS Node 12:
OSVmImage: "macOS-10.15"
TestType: "node"
NodeVersion: "12.x"
NodeTestVersion: "12.x"

jobs:
- job: "IntegrationTest"
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
Windows Browser:
OSVmImage: "windows-2019"
TestType: "browser"
NodeVersion: "12.x"
NodeTestVersion: "12.x"
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
TestResultsFiles: "**/test-results.browser.xml"

Expand All @@ -61,7 +61,7 @@ jobs:
Samples Linux Node 10:
OSVmImage: "ubuntu-18.04"
TestType: "sample"
NodeVersion: "10.x"
NodeTestVersion: "10.x"
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)

pool:
Expand Down Expand Up @@ -103,6 +103,8 @@ jobs:
workingDirectory: $(Build.SourcesDirectory)/eng/tools/eng-package-utils
displayName: "Get package path"
- template: ../steps/use-node-test-version.yml

# Option "-p max" ensures parallelism is set to the number of cores on all platforms, which improves build times.
# The default on Windows is "cores - 1" (microsoft/rushstack#436).
- script: |
Expand Down Expand Up @@ -170,7 +172,7 @@ jobs:
inputs:
searchFolder: "$(System.DefaultWorkingDirectory)/sdk"
testResultsFiles: "**/test-results.xml"
testRunTitle: "$(OSName) - NodeJS - Integration Tests - [Node $(NodeVersion)]"
testRunTitle: "$(OSName) - NodeJS - Integration Tests - [Node $(NodeTestVersion)]"
condition: and(always(), eq(variables['TestType'], 'node'))
displayName: "Publish NodeJS integration test results"

Expand All @@ -180,6 +182,6 @@ jobs:
inputs:
searchFolder: "$(System.DefaultWorkingDirectory)/sdk"
testResultsFiles: "**/test-results.browser.xml"
testRunTitle: "$(OSName) - Browser - Integration Tests - [Node $(NodeVersion)]"
testRunTitle: "$(OSName) - Browser - Integration Tests - [Node $(NodeTestVersion)]"
condition: and(always(), eq(variables['TestType'], 'browser'))
displayName: "Publish browser integration test results"
2 changes: 1 addition & 1 deletion eng/pipelines/templates/stages/cosmos-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ stages:
Matrix:
Windows_Node8:
OSVmImage: "windows-2019"
NodeVersion: "8.x"
NodeTestVersion: "8.x"
TestType: "node"
PreIntegrationSteps: cosmos-integration-public
PostIntegrationSteps: cosmos-additional-steps
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/templates/steps/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ steps:
displayName: "Use NodeJS $(NodeVersion)"

- script: |
npm --version
displayName: NPM version
node --version && npm --version
displayName: Node versions
37 changes: 37 additions & 0 deletions eng/pipelines/templates/steps/use-node-test-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
steps:
- task: NodeTool@0
inputs:
versionSpec: $(NodeTestVersion)
displayName: "Use NodeJS $(NodeTestVersion)"

- script: |
node --version && npm --version
displayName: Node versions
# Packages with native dependencies must be reinstalled after changing Node versions
- pwsh: |
$KeytarSymlinkPath = "common/temp/node_modules/.pnpm/node_modules/keytar"
# Map from the symlink path to the target path (npm has issues installing into symlink dirs)
# Example: common/temp/node_modules/.pnpm/registry.npmjs.org/keytar/5.4.0/node_modules/keytar
$KeytarTargetPath = (Get-Item $KeytarSymlinkPath).Target
# Need to run "npm install" at path containing "node_modules" folder
# Example: common/temp/node_modules/.pnpm/registry.npmjs.org/keytar/5.4.0
$KeytarInstallPath = Join-Path $KeytarTargetPath "../.."
# The version is the leaf node of the path
# Example: 5.4.0
$KeytarVersion = Split-Path -Leaf $KeytarInstallPath
Set-Location $KeytarInstallPath
# Install matching version of package
npm install --no-package-lock keytar@$KeytarVersion
displayName: Reinstall native dependencies
# After changing Node versions, Rush will attempt to reinstall itself, but will be blocked on
# Windows due to issue microsoft/rushstack#1878. A workaround is to manually delete the Rush
# install folder.
- pwsh: Remove-Item -Recurse -Force common/temp/install-run
displayName: Delete Rush install folder
2 changes: 1 addition & 1 deletion rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Specify one of: "pnpmVersion", "npmVersion", or "yarnVersion". See the Rush documentation
* for details about these alternatives.
*/
"pnpmVersion": "4.12.5",
"pnpmVersion": "4.14.2",
// "npmVersion": "4.5.0",
// "yarnVersion": "1.9.4",
/**
Expand Down

0 comments on commit f323b68

Please sign in to comment.