test: pin Angular snapshot versions

Next step is to set up Renovate to send PRs against this package.json file
This commit is contained in:
Alex Eagle 2019-03-13 22:18:23 -07:00 committed by Alex Eagle
parent 7f879dc60b
commit b344ba4b38
4 changed files with 41 additions and 21 deletions

View File

@ -206,15 +206,9 @@ workflows:
- e2e-cli-ng-snapshots:
requires:
- build
filters:
branches:
only: master
- e2e-cli-ivy-snapshots:
requires:
- build
filters:
branches:
only: master
- snapshot_publish:
requires:
- test

View File

@ -0,0 +1,16 @@
{
"description": "snapshot versions of Angular for e2e testing",
"private": true,
"dependencies": {
"@angular/core": "github:angular/core-builds#1bc5b9bba8227986648e0acacf1c0fe003325050",
"@angular/common": "github:angular/common-builds#8e5855a592e822c8c01ed8c76ddcb613adec8c28",
"@angular/platform-browser": "github:angular/platform-browser-builds#a680285668388f1ea495b4418e258dd3a7dfddbf",
"@angular/compiler": "github:angular/compiler-builds#5010a0df7672579c111122e703ae2a31e533bfe9",
"@angular/compiler-cli": "github:angular/compiler-cli-builds#b2f95784933f67e50916d5491046672452c4470a",
"@angular/animations": "github:angular/animations-builds#2ae4075eba3acd11c871ea9ce9acec0ca5679bb1",
"@angular/forms": "github:angular/forms-builds#5030b6e9a7174b525ee8e6ee60a3a3a91ef95a3c",
"@angular/platform-browser-dynamic": "github:angular/platform-browser-dynamic-builds#4fac5c151609dcf3d4b5bc23f7fa391c6ba393e4",
"@angular/router": "github:angular/router-builds#05ee97ccb532b2f8f18cc072034d5d3e51492a3c",
"@angular/language-service": "github:angular/language-service-builds#f0414cf6ca0825aa977639cf41d1935dd5791a6d"
}
}

View File

@ -191,30 +191,40 @@ export function useSha() {
// 7.0.0-beta.4+dd2a650
// 6.1.6+4a8d56a
const label = argv['ng-tag'] ? argv['ng-tag'] : '';
const ngSnapshotVersions = require('../ng-snapshot/package.json');
return updateJsonFile('package.json', json => {
// Install over the project with snapshot builds.
Object.keys(json['dependencies'] || {})
function replaceDependencies(key: string) {
const missingSnapshots = [];
Object.keys(json[key] || {})
.filter(name => name.match(/^@angular\//))
.forEach(name => {
const pkgName = name.split(/\//)[1];
if (pkgName == 'cli') {
return;
}
json['dependencies'][`@angular/${pkgName}`]
= `github:angular/${pkgName}-builds${label}`;
});
Object.keys(json['devDependencies'] || {})
.filter(name => name.match(/^@angular\//))
.forEach(name => {
const pkgName = name.split(/\//)[1];
if (pkgName == 'cli') {
return;
if (label) {
json[key][`@angular/${pkgName}`]
= `github:angular/${pkgName}-builds${label}`;
} else {
const replacement = ngSnapshotVersions.dependencies[`@angular/${pkgName}`];
if (!replacement) {
missingSnapshots.push(`missing @angular/${pkgName}`);
}
json[key][`@angular/${pkgName}`] = replacement;
}
json['devDependencies'][`@angular/${pkgName}`]
= `github:angular/${pkgName}-builds${label}`;
});
if (missingSnapshots.length > 0) {
throw new Error('e2e test with --ng-snapshots requires all angular packages be ' +
'listed in tests/legacy-cli/e2e/ng-snapshot/package.json.\nErrors:\n' + missingSnapshots.join('\n '));
}
}
try {
replaceDependencies('dependencies');
replaceDependencies('devDependencies');
} catch (e) {
return Promise.reject(e);
}
json['devDependencies']['typescript'] = '~3.1.1';
});
} else {

View File

@ -27,7 +27,7 @@ Error.stackTraceLimit = Infinity;
* --noglobal Skip linking your local @angular/cli directory. Can save a few seconds.
* --nosilent Never silence ng commands.
* --ng-tag=TAG Use a specific tag for build snapshots. Similar to ng-snapshots but point to a
* tag of using the latest master.
* tag instead of using the latest master.
* --ng-snapshots Install angular snapshot builds in the test project.
* --ivy Use the Ivy compiler.
* --glob Run tests matching this glob pattern (relative to tests/e2e/).