Skip to content
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

Build by service directory (part 2) #3647

Merged
merged 33 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
201734d
Take multiple targets.
mitchdenny Jun 10, 2019
5669707
Starting to build out package selection script.
mitchdenny Jun 10, 2019
7764bc7
Added select packages step.
mitchdenny Jun 11, 2019
ca5c01e
Changed to variable syntax for generated package targets.
mitchdenny Jun 11, 2019
f2d04bd
Quick hack to get a clean build.
mitchdenny Jun 11, 2019
18e65a4
Setting up select-packages tool.
mitchdenny Jun 11, 2019
ee69cf2
Fixed template.
mitchdenny Jun 11, 2019
5c3fd0e
Fixed path issue in template.
mitchdenny Jun 11, 2019
211794b
Debugging build failures.
mitchdenny Jun 11, 2019
dff14de
Actually emit targets instead of hardcoding!
mitchdenny Jun 11, 2019
003d509
Exclude everything under eng/tools/select-packages.
mitchdenny Jun 11, 2019
ac990f7
Flipping to bash.
mitchdenny Jun 11, 2019
4ff1f07
I hate path differences :)
mitchdenny Jun 11, 2019
db8f609
Trying to come up with cleanest path approach.
mitchdenny Jun 11, 2019
281055c
Just make it work :)
mitchdenny Jun 11, 2019
293d94c
Incorrect YAML statement.
mitchdenny Jun 11, 2019
5f198aa
Trying different approach to get variables.
mitchdenny Jun 11, 2019
1dda33c
Revert variables usage.
mitchdenny Jun 11, 2019
8030253
Hoisting variables across jobs.
mitchdenny Jun 11, 2019
25ee308
Tweaks to improve logging and debugging.
mitchdenny Jun 11, 2019
1f6e434
Moving to lock file for select-packages.
mitchdenny Jun 11, 2019
ac17b11
Using CI instead of instal.
mitchdenny Jun 11, 2019
7eac9ca
Moved/updated ci.yml files and setup data-plane packages.
mitchdenny Jun 11, 2019
7230ac7
Adds globbing support on the CLI.
mitchdenny Jun 11, 2019
808f83c
Fixed up glob.
mitchdenny Jun 12, 2019
9a9b678
Refined glob.
mitchdenny Jun 12, 2019
352ff9e
Added a prepare step to make the test jobs be able to start quicker.
mitchdenny Jun 12, 2019
dbdbb24
Fixing up mislabeled output variables.
mitchdenny Jun 12, 2019
24c02f2
Explicitly specifying pool on prepare.
mitchdenny Jun 12, 2019
6459720
Changes to existing ci.yml files to make sure we don't break when mer…
mitchdenny Jun 12, 2019
94c2cf1
Swap to sdk-type from isDataPlane.
mitchdenny Jun 12, 2019
bacb20e
Updated logging.
mitchdenny Jun 12, 2019
c3bbc43
Made it so that service directory excludes sdk/
mitchdenny Jun 12, 2019
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
3 changes: 2 additions & 1 deletion .docsettings.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
omitted_paths:
- documentation/ServicePrincipal/*
- eng/tools/select-packages/**
- "sdk/*/arm-*"
- "sdk/cognitiveservices/*"
language: js
Expand Down Expand Up @@ -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"]
Expand Down
109 changes: 58 additions & 51 deletions eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
jobs:
- job: Prepare
mitchdenny marked this conversation as resolved.
Show resolved Hide resolved
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"
Expand All @@ -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:
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -96,6 +111,9 @@ jobs:

- job: "Test"

dependsOn:
- Prepare

strategy:
matrix:
Linux_Node8:
Expand Down Expand Up @@ -138,6 +156,9 @@ jobs:
pool:
vmImage: "$(OSVmImage)"

variables:
GeneratedPackageTargets: $[dependencies.Prepare.outputs['SelectPackages.GeneratedPackageTargets']]
mitchdenny marked this conversation as resolved.
Show resolved Hide resolved

steps:
- task: NodeTool@0
inputs:
Expand All @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions eng/pipelines/templates/steps/select-packages.yml
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"
78 changes: 78 additions & 0 deletions eng/tools/select-packages/index.js
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") {
mitchdenny marked this conversation as resolved.
Show resolved Hide resolved
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 changes: 96 additions & 0 deletions eng/tools/select-packages/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions eng/tools/select-packages/package.json
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"
}
}
1 change: 1 addition & 0 deletions sdk/core/abort-controller/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/amqp-common/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading