Management specific pipeline should only only management packages (#20979)

* Management specific pipeline should only management packages
This commit is contained in:
praveenkuttappan 2022-03-28 08:32:40 -04:00 коммит произвёл GitHub
Родитель 51245a67de
Коммит fe4bd930c5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 58 добавлений и 20 удалений

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

@ -62,12 +62,16 @@ steps:
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
- template: /eng/pipelines/templates/steps/set-artifact-packages.yml
parameters:
Artifacts: ${{ parameters.Artifacts }}
- pwsh: |
node eng/tools/rush-runner.js check-format "${{parameters.ServiceDirectory}}" --verbose
node eng/tools/rush-runner.js check-format "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose
displayName: "Check Format in Libraries"
- script: |
node eng/tools/rush-runner.js audit "${{parameters.ServiceDirectory}}"
node eng/tools/rush-runner.js audit "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)"
condition: and(succeeded(), eq(variables['RunNpmAudit'], 'true'))
displayName: "Audit libraries"

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

@ -45,13 +45,17 @@ steps:
condition: and(succeeded(),ne(variables['SetDevVersion'],'true'))
displayName: "Install dependencies"
- template: /eng/pipelines/templates/steps/set-artifact-packages.yml
parameters:
Artifacts: ${{ parameters.Artifacts }}
# 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: |
node eng/tools/rush-runner.js build "${{parameters.ServiceDirectory}}" --verbose -p max
node eng/tools/rush-runner.js build "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max
displayName: "Build libraries"
- script: |
node eng/tools/rush-runner.js build:samples "${{parameters.ServiceDirectory}}" --verbose
node eng/tools/rush-runner.js build:samples "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose
displayName: "Build samples"
- pwsh: |
@ -59,7 +63,7 @@ steps:
displayName: "Check api extractor output changes"
- script: |
node eng/tools/rush-runner.js pack "${{parameters.ServiceDirectory}}" --verbose
node eng/tools/rush-runner.js pack "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose
displayName: "Pack libraries"
# Unlink node_modules folders to significantly improve performance of subsequent tasks

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

@ -0,0 +1,12 @@
parameters:
Artifacts: []
steps:
- pwsh: |
$artifacts = '${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json
$packages = ""
foreach ($artifact in $artifacts)
{
$packages += "$($artifact.name),"
}
echo "##vso[task.setvariable variable=ArtifactPackageNames]$packages"
displayName: "Find Packages to build"

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

@ -12,16 +12,20 @@ steps:
node common/scripts/install-run-rush.js install
displayName: "Install dependencies"
- template: /eng/pipelines/templates/steps/set-artifact-packages.yml
parameters:
Artifacts: ${{ parameters.Artifacts }}
# 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: |
node eng/tools/rush-runner.js build "${{parameters.ServiceDirectory}}" --verbose -p max
node eng/tools/rush-runner.js build "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max
displayName: "Build libraries"
# 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: |
node eng/tools/rush-runner.js build:test "${{parameters.ServiceDirectory}}" --verbose -p max
node eng/tools/rush-runner.js build:test "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max
displayName: "Build test assets"
- template: ../steps/use-node-test-version.yml
@ -32,14 +36,14 @@ steps:
# 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: |
node eng/tools/rush-runner.js unit-test:node "${{parameters.ServiceDirectory}}" --verbose -p max
node eng/tools/rush-runner.js unit-test:node "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max
displayName: "Test libraries"
condition: and(succeeded(),eq(variables['TestType'], 'node'))
# 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: |
node eng/tools/rush-runner.js unit-test:browser "${{parameters.ServiceDirectory}}" --verbose -p max
node eng/tools/rush-runner.js unit-test:browser "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max
displayName: "Test libraries"
condition: and(succeeded(),eq(variables['TestType'], 'browser'))

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

@ -56,26 +56,37 @@ const parseArgs = () => {
}
let inFlags = false;
let isPackageFilter = false;
let artifactNames = "";
const services = [],
flags = [];
const [scriptPath, action, ...givenArgs] = process.argv.slice(1);
const baseDir = path.resolve(`${path.dirname(scriptPath)}/../..`);
for (const arg of givenArgs) {
if (!inFlags && arg.startsWith("-")) {
if (arg === "-packages") {
isPackageFilter = true;
continue;
}
else if (!inFlags && arg.startsWith("-")) {
inFlags = true;
}
if (inFlags) {
flags.push(arg);
} else {
}
else if (isPackageFilter) {
artifactNames = arg;
isPackageFilter = false;
}
else {
if (arg && arg !== "*") {
// exclude empty value and special value "*" meaning all libraries
services.push(arg);
}
}
}
return [baseDir, action, services, flags];
return [baseDir, action, services, flags, artifactNames];
};
const getPackageJsons = (searchDir) => {
@ -97,22 +108,25 @@ const getPackageJsons = (searchDir) => {
return sdkDirectories.concat(perfTestDirectories).filter((f) => fs.existsSync(f)); // only keep paths for files that actually exist
};
const getServicePackages = (baseDir, serviceDirs) => {
const getServicePackages = (baseDir, serviceDirs, artifactNames) => {
const packageNames = [];
const packageDirs = [];
const validSdkTypes = ["client", "mgmt", "perf-test", "utility"]; // valid "sdk-type"s that we are looking for, to be able to apply rush-runner jobs on
let validSdkTypes = ["client", "mgmt", "perf-test", "utility"]; // valid "sdk-type"s that we are looking for, to be able to apply rush-runner jobs on
console.log(`Packages to build: ${artifactNames}`);
const artifacts = artifactNames.split(",");
for (const serviceDir of serviceDirs) {
const searchDir = path.resolve(path.join(baseDir, "sdk", serviceDir));
const packageJsons = getPackageJsons(searchDir);
for (const filePath of packageJsons) {
const contents = JSON.parse(fs.readFileSync(filePath, "utf8"));
if (validSdkTypes.includes(contents["sdk-type"])) {
const artifactName = contents.name.replace("@", "").replace("/", "-");
if (validSdkTypes.includes(contents["sdk-type"]) && artifacts.includes(artifactName)) {
packageNames.push(contents.name);
packageDirs.push(path.dirname(filePath));
}
}
}
console.log(`Packages eligible to run rush task: ${packageNames}`);
return [packageNames, packageDirs];
};
@ -134,9 +148,9 @@ const flatMap = (arr, f) => {
return [].concat(...result);
};
const [baseDir, action, serviceDirs, rushParams] = parseArgs();
const [baseDir, action, serviceDirs, rushParams, artifactNames] = parseArgs();
const [packageNames, packageDirs] = getServicePackages(baseDir, serviceDirs);
const [packageNames, packageDirs] = getServicePackages(baseDir, serviceDirs, artifactNames);
/**
* Helper function to provide the rush logic that is used frequently below

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

@ -30,4 +30,4 @@ extends:
ServiceDirectory: advisor
Artifacts:
- name: azure-arm-advisor
safeName: azurearmadvisor
safeName: azurearmadvisor

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

@ -32,4 +32,4 @@ extends:
ServiceDirectory: appconfiguration
Artifacts:
- name: azure-app-configuration
safeName: azureappconfiguration
safeName: azureappconfiguration