-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build by service directory (part 2) (#3647)
* Setup CI pipelines to run at the service directory level.
- Loading branch information
1 parent
0870a48
commit cdf431a
Showing
42 changed files
with
348 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,33 @@ | ||
jobs: | ||
- job: Prepare | ||
variables: | ||
- template: ../variables/globals.yml | ||
|
||
pool: | ||
vmImage: "ubuntu-16.04" | ||
|
||
steps: | ||
- task: NodeTool@0 | ||
inputs: | ||
versionSpec: "$(NodeVersion)" | ||
displayName: "Install Node.js $(NodeVersion)" | ||
|
||
- script: | | ||
npm install -g [email protected] | ||
displayName: "Install npm version 6.9.0" | ||
- template: ../steps/select-packages.yml | ||
parameters: | ||
ServiceDirectory: ${{parameters.ServiceDirectory}} | ||
|
||
- job: "Build" | ||
variables: | ||
- template: ../variables/globals.yml | ||
- name: GeneratedPackageTargets | ||
value: $[dependencies.Prepare.outputs['SelectPackages.GeneratedPackageTargets']] | ||
|
||
dependsOn: | ||
- Prepare | ||
|
||
pool: | ||
vmImage: "ubuntu-16.04" | ||
|
@@ -20,21 +46,12 @@ jobs: | |
node common/scripts/install-run-rush.js install | ||
displayName: "Install dependencies" | ||
- ${{ if eq(parameters.PackageName,'')}}: | ||
- script: | | ||
node common/scripts/install-run-rush.js build --verbose | ||
displayName: "Build libraries" | ||
- script: | | ||
node common/scripts/install-run-rush.js pack --verbose | ||
displayName: "Pack libraries" | ||
- ${{ if ne(parameters.PackageName,'')}}: | ||
- script: | | ||
node common/scripts/install-run-rush.js build --verbose --to ${{parameters.PackageName}} | ||
displayName: "Build libraries" | ||
- script: | | ||
node common/scripts/install-run-rush.js pack --verbose --to ${{parameters.PackageName}} | ||
displayName: "Pack libraries" | ||
- script: | | ||
node common/scripts/install-run-rush.js build --verbose $(GeneratedPackageTargets) | ||
displayName: "Build libraries" | ||
- script: | | ||
node common/scripts/install-run-rush.js pack --verbose $(GeneratedPackageTargets) | ||
displayName: "Pack libraries" | ||
- task: CopyFiles@2 | ||
inputs: | ||
|
@@ -51,8 +68,14 @@ jobs: | |
targetPath: $(Build.ArtifactStagingDirectory) | ||
|
||
- job: "Analyze" | ||
|
||
dependsOn: | ||
- Prepare | ||
|
||
variables: | ||
- template: ../variables/globals.yml | ||
- name: GeneratedPackageTargets | ||
value: $[dependencies.Prepare.outputs['SelectPackages.GeneratedPackageTargets']] | ||
|
||
pool: | ||
vmImage: "ubuntu-16.04" | ||
|
@@ -74,19 +97,11 @@ jobs: | |
ward scan -d $(Build.SourcesDirectory) -c $(Build.SourcesDirectory)/.docsettings.yml | ||
displayName: "Verify Readmes" | ||
- ${{ if eq(parameters.PackageName,'')}}: | ||
- script: | | ||
node common/scripts/install-run-rush.js install | ||
node common/scripts/install-run-rush.js audit | ||
condition: and(succeeded(), eq(variables['RunNpmAudit'], 'true')) | ||
displayName: "Audit packages" | ||
- ${{ if ne(parameters.PackageName,'')}}: | ||
- script: | | ||
node common/scripts/install-run-rush.js install | ||
node common/scripts/install-run-rush.js audit --to ${{parameters.PackageName}} | ||
condition: and(succeeded(), eq(variables['RunNpmAudit'], 'true')) | ||
displayName: "Audit packages" | ||
- script: | | ||
node common/scripts/install-run-rush.js install | ||
node common/scripts/install-run-rush.js audit $(GeneratedPackageTargets) | ||
condition: and(succeeded(), eq(variables['RunNpmAudit'], 'true')) | ||
displayName: "Audit packages" | ||
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 | ||
# ComponentGovernance is currently unable to run on pull requests of public projects. Running on non-PR | ||
|
@@ -96,6 +111,9 @@ jobs: | |
|
||
- job: "Test" | ||
|
||
dependsOn: | ||
- Prepare | ||
|
||
strategy: | ||
matrix: | ||
Linux_Node8: | ||
|
@@ -138,6 +156,9 @@ jobs: | |
pool: | ||
vmImage: "$(OSVmImage)" | ||
|
||
variables: | ||
GeneratedPackageTargets: $[dependencies.Prepare.outputs['SelectPackages.GeneratedPackageTargets']] | ||
|
||
steps: | ||
- task: NodeTool@0 | ||
inputs: | ||
|
@@ -148,29 +169,15 @@ jobs: | |
node common/scripts/install-run-rush.js install | ||
displayName: "Install dependencies" | ||
# If there is no package name, then don't use the --to option. | ||
- ${{ if eq(parameters.PackageName,'')}}: | ||
- script: | | ||
node common/scripts/install-run-rush.js build --verbose | ||
displayName: "Build libraries" | ||
- script: | | ||
node common/scripts/install-run-rush.js build:test --verbose | ||
displayName: "Build test assets" | ||
- script: | | ||
node common/scripts/install-run-rush.js unit-test --verbose | ||
displayName: "Test libraries" | ||
# On the other hand, if there is a PackageName, supply the --to option. | ||
- ${{ if ne(parameters.PackageName,'')}}: | ||
- script: | | ||
node common/scripts/install-run-rush.js build --verbose --to ${{parameters.PackageName}} | ||
displayName: "Build libraries" | ||
- script: | | ||
node common/scripts/install-run-rush.js build:test --verbose --to ${{parameters.PackageName}} | ||
displayName: "Build test assets" | ||
- script: | | ||
node common/scripts/install-run-rush.js unit-test --verbose --to ${{parameters.PackageName}} | ||
displayName: "Test libraries" | ||
- script: | | ||
node common/scripts/install-run-rush.js build --verbose $(GeneratedPackageTargets) | ||
displayName: "Build libraries" | ||
- script: | | ||
node common/scripts/install-run-rush.js build:test --verbose $(GeneratedPackageTargets) | ||
displayName: "Build test assets" | ||
- script: | | ||
node common/scripts/install-run-rush.js unit-test --verbose $(GeneratedPackageTargets) | ||
displayName: "Test libraries" | ||
- task: PublishTestResults@2 | ||
inputs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
steps: | ||
- script: | | ||
npm ci # This causes us to download packages exclusively based on the lock file, faster and more secure. | ||
npm run select-packages "$(System.DefaultWorkingDirectory)/sdk/${{parameters.ServiceDirectory}}/!(arm-*)/package.json" | ||
workingDirectory: $(System.DefaultWorkingDirectory)/eng/tools/select-packages | ||
name: SelectPackages | ||
displayName: "Selecting packages to build" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See the @microsoft/rush package's LICENSE file for license information. | ||
|
||
// This script searches for package.json files recursively under a given path | ||
// excluding packages under a node_modules folder and opens them to determine | ||
// whether they contain a "sdk-archetype" field with the value of "client". | ||
// | ||
// If they do, then the package name is recorded and then after all package.json files | ||
// have been scanned a single string is output using the Azure Pipelines Commands special | ||
// syntax which creates a variable for use within a later stage of the pipeine. | ||
var glob = require("glob"); | ||
|
||
let logLineCounter = 0; | ||
const log = message => { | ||
console.log(`select-packages(${logLineCounter++}): ${message}`); | ||
}; | ||
|
||
log(`Working directory is "${process.cwd()}".`); | ||
|
||
let filter = process.argv[2]; | ||
log(`Specified glob filter is "${filter}".`); | ||
|
||
// This code assumes that in the service directory, packages that we want to publish | ||
// exist only in directories that are immediate children of the service directory. | ||
glob(filter, (err, files) => { | ||
if (err) { | ||
log(`An error occured: ${err}`); | ||
process.exit(1); | ||
} | ||
|
||
let packageTargets = ""; | ||
|
||
if (files) { | ||
log(`Found ${files.length} packages under service directory.`); | ||
|
||
for (let fileIndex in files) { | ||
log(`Processing package file ${fileIndex} at "${files[fileIndex]}"`); | ||
let packageContents = require(files[fileIndex]); | ||
|
||
log( | ||
`Package name for package ${fileIndex} is "${packageContents.name}".` | ||
); | ||
|
||
if (packageContents["sdk-type"] == "client") { | ||
log( | ||
`Package "${packageContents.name}" has sdk-type of "${ | ||
packageContents["sdk-type"] | ||
}".` | ||
); | ||
packageTargets += `--to "${packageContents.name}" `; | ||
} else { | ||
log( | ||
`Package "${ | ||
packageContents.name | ||
}" DOES NOT have an sdk-type of "client".` | ||
); | ||
} | ||
} | ||
|
||
log( | ||
`Finished processing packages. Emitting variable using: ${packageTargets}` | ||
); | ||
|
||
// Can't use regular logging here because the pattern for Azure Pipelines requires ##vso to be the first chars. | ||
console.log( | ||
`##vso[task.setvariable variable=GeneratedPackageTargets;isOutput=true;]${packageTargets}` | ||
); | ||
|
||
log( | ||
`Emitted variable "GeneratedPackageTargets" with content: ${packageTargets}` | ||
); | ||
} else { | ||
log("Did not find any packages under service directory."); | ||
process.exit(2); | ||
} | ||
|
||
log("Done!"); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "select-packages", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"select-packages": "node index.js" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"glob": "^7.1.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.