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

move validation to bootstrap #13

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
51 changes: 51 additions & 0 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37906,6 +37906,57 @@ async function validateYarnLock(kbn, yarnLock) {

`);
process.exit(1);
} // look through all the package.json files to find packages which have mismatched version ranges


const depRanges = new Map();

for (const project of kbn.getAllProjects().values()) {
for (const [dep, range] of Object.entries(project.allDependencies)) {
const existingDep = depRanges.get(dep);

if (!existingDep) {
depRanges.set(dep, [{
range,
projects: [project]
}]);
continue;
}

const existingRange = existingDep.find(existing => existing.range === range);

if (!existingRange) {
existingDep.push({
range,
projects: [project]
});
continue;
}

existingRange.projects.push(project);
}
}

const duplicateRanges = Array.from(depRanges.entries()).filter(([, ranges]) => ranges.length > 1).reduce((acc, [dep, ranges]) => [...acc, dep, ...ranges.map(({
range,
projects
}) => ` ${range} => ${projects.map(p => p.name).join(', ')}`)], []).join('\n ');

if (duplicateRanges) {
_log__WEBPACK_IMPORTED_MODULE_3__["log"].error(dedent__WEBPACK_IMPORTED_MODULE_1___default.a`

[single_version_dependencies] Multiple version ranges for the same dependency
were found declared across different package.json files. Please consolidate
those to match across all package.json files. Different versions for the
same dependency is not supported.

If you have questions about this please reach out to the operations team.

The conflicting dependencies are:

${duplicateRanges}
`);
process.exit(1);
}

_log__WEBPACK_IMPORTED_MODULE_3__["log"].success('yarn.lock analysis completed without any issues');
Expand Down
61 changes: 61 additions & 0 deletions packages/kbn-pm/src/utils/validate_yarn_lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { writeFile } from './fs';
import { Kibana } from './kibana';
import { YarnLock } from './yarn_lock';
import { log } from './log';
import { Project } from './project';

export async function validateYarnLock(kbn: Kibana, yarnLock: YarnLock) {
// look through all of the packages in the yarn.lock file to see if
Expand Down Expand Up @@ -95,5 +96,65 @@ export async function validateYarnLock(kbn: Kibana, yarnLock: YarnLock) {
process.exit(1);
}

// look through all the package.json files to find packages which have mismatched version ranges
const depRanges = new Map<string, Array<{ range: string; projects: Project[] }>>();
for (const project of kbn.getAllProjects().values()) {
for (const [dep, range] of Object.entries(project.allDependencies)) {
const existingDep = depRanges.get(dep);
if (!existingDep) {
depRanges.set(dep, [
{
range,
projects: [project],
},
]);
continue;
}

const existingRange = existingDep.find((existing) => existing.range === range);
if (!existingRange) {
existingDep.push({
range,
projects: [project],
});
continue;
}

existingRange.projects.push(project);
}
}

const duplicateRanges = Array.from(depRanges.entries())
.filter(([, ranges]) => ranges.length > 1)
.reduce(
(acc: string[], [dep, ranges]) => [
...acc,
dep,
...ranges.map(
({ range, projects }) => ` ${range} => ${projects.map((p) => p.name).join(', ')}`
),
],
[]
)
.join('\n ');

if (duplicateRanges) {
log.error(dedent`

[single_version_dependencies] Multiple version ranges for the same dependency
were found declared across different package.json files. Please consolidate
those to match across all package.json files. Different versions for the
same dependency is not supported.

If you have questions about this please reach out to the operations team.

The conflicting dependencies are:

${duplicateRanges}
`);

process.exit(1);
}

log.success('yarn.lock analysis completed without any issues');
}
21 changes: 0 additions & 21 deletions scripts/check_single_version_dependencies.js

This file was deleted.

105 changes: 0 additions & 105 deletions src/dev/run_check_single_version_dependencies.ts

This file was deleted.

7 changes: 0 additions & 7 deletions test/scripts/checks/single_version_dependencies.sh

This file was deleted.

1 change: 0 additions & 1 deletion vars/tasks.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def check() {
kibanaPipeline.scriptTask('Check File Casing', 'test/scripts/checks/file_casing.sh'),
kibanaPipeline.scriptTask('Check Lockfile Symlinks', 'test/scripts/checks/lock_file_symlinks.sh'),
kibanaPipeline.scriptTask('Check Licenses', 'test/scripts/checks/licenses.sh'),
kibanaPipeline.scriptTask('Check Single Version Dependencies', 'test/scripts/checks/single_version_dependencies.sh'),
kibanaPipeline.scriptTask('Verify Dependency Versions', 'test/scripts/checks/verify_dependency_versions.sh'),
kibanaPipeline.scriptTask('Verify NOTICE', 'test/scripts/checks/verify_notice.sh'),
kibanaPipeline.scriptTask('Test Projects', 'test/scripts/checks/test_projects.sh'),
Expand Down