Build by service directory (part 2) (#3647)

* Setup CI pipelines to run at the service directory level.
This commit is contained in:
Mitch Denny 2019-06-12 16:07:07 -07:00 коммит произвёл GitHub
Родитель 0870a48d3d
Коммит cdf431a1e6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
42 изменённых файлов: 348 добавлений и 81 удалений

Просмотреть файл

@ -1,5 +1,6 @@
omitted_paths:
- documentation/ServicePrincipal/*
- eng/tools/select-packages/**
- "sdk/*/arm-*"
- "sdk/cognitiveservices/*"
language: js
@ -62,7 +63,7 @@ known_content_issues:
- ["sdk/eventgrid/eventgrid/README.md", "#1583"]
- ["sdk/core/abort-controller/README.md", "#1583"]
- ["sdk/core/core-http/README.md", "#1583"]
- ['sdk/identity/identity/README.md', '#1583']
- ["sdk/identity/identity/README.md", "#1583"]
- ["sdk/cosmosdb/cosmos/README.md", "#1583"]
- ["sdk/cosmosdb/cosmos/src/test/readme.md", "#1583"]
- ["sdk/cosmosdb/cosmos/samples/readme.md", "#1583"]

Просмотреть файл

@ -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 npm@6.9.0
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:

Просмотреть файл

@ -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"

Просмотреть файл

@ -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!");
});

96
eng/tools/select-packages/package-lock.json сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,96 @@
{
"name": "select-packages",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
},
"glob": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
"integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"dev": true
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"requires": {
"wrappy": "1"
}
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
}
}
}

Просмотреть файл

@ -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"
}
}

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/abort-controller",
"sdk-type": "client",
"version": "1.0.0",
"description": "Microsoft Azure SDK for JavaScript - Aborter",
"main": "./dist/index.js",

Просмотреть файл

@ -9,9 +9,9 @@ pr:
- master
paths:
include:
- sdk/core/amqp-common/
- sdk/core/
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/amqp-common"
ServiceDirectory: core

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/amqp-common",
"sdk-type": "client",
"version": "1.0.0-preview.5",
"description": "Common library for amqp based azure sdks like @azure/event-hubs.",
"author": "Microsoft Corporation",

Просмотреть файл

@ -20,4 +20,4 @@ pr:
jobs:
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/core-http"
ServiceDirectory: core

Просмотреть файл

@ -9,9 +9,9 @@ pr:
- master
paths:
include:
- sdk/core/http/
- sdk/core/
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/core-http"
ServiceDirectory: core

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/core-http",
"sdk-type": "client",
"author": {
"name": "Microsoft Corporation",
"email": "azsdkteam@microsoft.com",

Просмотреть файл

@ -20,7 +20,7 @@ pr:
jobs:
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/cosmos"
ServiceDirectory: cosmosdb
- template: ../../eng/pipelines/templates/jobs/node6-test-sdk-client.yml
parameters:

Просмотреть файл

@ -9,13 +9,15 @@ pr:
- master
paths:
include:
- sdk/cosmosdb/cosmos/
- sdk/cosmosdb/
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/cosmos"
ServiceDirectory: cosmosdb
# HACK: Because Rush doesn't support Node 6.x this is done to use NPM to build
# and test on that version of Node.
- template: ../../../eng/pipelines/templates/jobs/node6-test-sdk-client.yml
parameters:
PackagePath: "sdk/cosmosdb/cosmos/"

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/cosmos",
"sdk-type": "client",
"description": "Azure Cosmos DB Service Node.js SDK for SQL API",
"keywords": [
"cosmosdb",

Просмотреть файл

@ -20,4 +20,4 @@ pr:
jobs:
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/event-hubs"
ServiceDirectory: eventhub

Просмотреть файл

@ -14,4 +14,4 @@ pr:
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/event-hubs"
ServiceDirectory: eventhub

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/event-hubs",
"sdk-type": "client",
"version": "2.1.0",
"description": "Azure Event Hubs SDK for JS.",
"author": "Microsoft Corporation",

Просмотреть файл

@ -14,4 +14,4 @@ pr:
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/event-processor-host"
ServiceDirectory: eventhub

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/event-processor-host",
"sdk-type": "client",
"version": "1.0.6",
"description": "Azure Event Processor Host (Event Hubs) SDK for JS.",
"author": "Microsoft Corporation",

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "testhub",
"sdk-type": "client",
"version": "0.1.0",
"license": "MIT",
"engine": {

23
sdk/identity/ci.yml Normal file
Просмотреть файл

@ -0,0 +1,23 @@
# DO NOT EDIT THIS FILE
# This file is generated automatically and any changes will be lost.
trigger:
branches:
include:
- master
paths:
include:
- sdk/identity/
pr:
branches:
include:
- master
paths:
include:
- sdk/identity/
jobs:
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: identity

Просмотреть файл

@ -9,9 +9,9 @@ pr:
- master
paths:
include:
- sdk/identity/identity/
- sdk/identity/
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/identity"
ServiceDirectory: identity

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/identity",
"sdk-type": "client",
"version": "0.1.0",
"description": "Provides credential implementations for Azure SDK libraries that can authenticate with Azure Active Directory",
"main": "dist/index.js",

Просмотреть файл

@ -20,4 +20,4 @@ pr:
jobs:
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/keyvault-secrets"
ServiceDirectory: keyvault

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/keyvault-certificates",
"sdk-type": "client",
"author": "Microsoft Corporation",
"version": "0.0.1",
"license": "MIT",

Просмотреть файл

@ -9,9 +9,9 @@ pr:
- master
paths:
include:
- sdk/keyvault/keyvault-keys/
- sdk/keyvault/
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/keyvault-keys"
ServiceDirectory: keyvault

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/keyvault-keys",
"sdk-type": "client",
"author": "Microsoft Corporation",
"version": "0.0.1",
"license": "MIT",

Просмотреть файл

@ -9,9 +9,9 @@ pr:
- master
paths:
include:
- sdk/keyvault/keyvault-secrets/
- sdk/keyvault/
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/keyvault-secrets"
ServiceDirectory: keyvault

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/keyvault-secrets",
"sdk-type": "client",
"author": "Microsoft Corporation",
"version": "0.0.1",
"license": "MIT",

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/keyvault",
"sdk-type": "client",
"author": "Microsoft Corporation",
"version": "0.1.0",
"license": "MIT",

Просмотреть файл

@ -20,4 +20,4 @@ pr:
jobs:
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/service-bus"
ServiceDirectory: servicebus

Просмотреть файл

@ -9,9 +9,9 @@ pr:
- master
paths:
include:
- sdk/servicebus/service-bus/
- sdk/servicebus/
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/service-bus"
ServiceDirectory: servicebus

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/service-bus",
"sdk-type": "client",
"author": "Microsoft Corporation",
"version": "1.0.2",
"license": "MIT",
@ -65,7 +66,7 @@
"eslint-detailed-reporter": "^0.8.0",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-no-only-tests": "^2.3.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-promise": "^4.1.1",
"https-proxy-agent": "^2.2.1",
"karma": "^4.0.1",
"karma-chrome-launcher": "^2.2.0",

Просмотреть файл

@ -20,4 +20,4 @@ pr:
jobs:
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/storage-blob"
ServiceDirectory: storage

Просмотреть файл

@ -9,9 +9,9 @@ pr:
- master
paths:
include:
- sdk/storage/storage-blob/
- sdk/storage/
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/storage-blob"
ServiceDirectory: storage

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/storage-blob",
"sdk-type": "client",
"version": "10.3.0",
"description": "Microsoft Azure Storage SDK for JavaScript - Blob",
"main": "./dist/index.js",

Просмотреть файл

@ -9,9 +9,9 @@ pr:
- master
paths:
include:
- sdk/storage/storage-file/
- sdk/storage/
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/storage-file"
ServiceDirectory: storage

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/storage-file",
"sdk-type": "client",
"version": "10.1.0",
"description": "Microsoft Azure Storage SDK for JavaScript - File",
"main": "./dist/index.js",

Просмотреть файл

@ -9,9 +9,9 @@ pr:
- master
paths:
include:
- sdk/storage/storage-queue/
- sdk/storage/
jobs:
- template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
PackageName: "@azure/storage-queue"
ServiceDirectory: storage

Просмотреть файл

@ -1,5 +1,6 @@
{
"name": "@azure/storage-queue",
"sdk-type": "client",
"version": "10.1.0",
"description": "Microsoft Azure Storage SDK for JavaScript - Queue",
"main": "./dist/index.js",

23
sdk/template/ci.yml Normal file
Просмотреть файл

@ -0,0 +1,23 @@
# DO NOT EDIT THIS FILE
# This file is generated automatically and any changes will be lost.
trigger:
branches:
include:
- master
paths:
include:
- sdk/template/
pr:
branches:
include:
- master
paths:
include:
- sdk/template/
jobs:
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
ServiceDirectory: template