2020-10-28 06:23:51 -04:00
|
|
|
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const {execSync} = require('child_process');
|
|
|
|
|
|
|
|
|
|
|
|
describe('deploy-to-firebase:', () => {
|
|
|
|
const deployToFirebaseCmd = `"${process.execPath}" "${__dirname}/deploy-to-firebase" --dry-run`;
|
2020-10-28 09:03:41 -04:00
|
|
|
const ngRemoteUrl = 'https://github.com/angular/angular.git';
|
2020-10-28 06:23:51 -04:00
|
|
|
|
|
|
|
// Helpers
|
|
|
|
const deployToFirebaseDryRun =
|
|
|
|
env => execSync(deployToFirebaseCmd, {encoding: 'utf8', env}).toString().trim();
|
|
|
|
const getLatestCommitForBranch =
|
2020-10-28 09:03:41 -04:00
|
|
|
branch => execSync(`git ls-remote ${ngRemoteUrl} ${branch}`).slice(0, 40);
|
2020-10-28 06:23:51 -04:00
|
|
|
|
|
|
|
it('master - skip deploy - not angular', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'notangular',
|
|
|
|
})).toBe('Skipping deploy because this is not angular/angular.');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('master - skip deploy - angular fork', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'notangular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
})).toBe('Skipping deploy because this is not angular/angular.');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('master - skip deploy - pull request', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'true',
|
|
|
|
})).toBe('Skipping deploy because this is a PR build.');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('master - deploy success', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: 'master',
|
|
|
|
CI_COMMIT: getLatestCommitForBranch('master'),
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
|
|
|
'Git branch : master\n' +
|
|
|
|
'Build/deploy mode : next\n' +
|
|
|
|
'Firebase project : aio-staging\n' +
|
|
|
|
'Firebase site : aio-staging\n' +
|
|
|
|
'Deployment URL : https://next.angular.io/');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('master - skip deploy - commit not HEAD', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: 'master',
|
|
|
|
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
|
|
|
})).toBe(
|
|
|
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
|
|
|
`(${getLatestCommitForBranch('master')}).`);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('stable - deploy success', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '4.3.x',
|
|
|
|
CI_STABLE_BRANCH: '4.3.x',
|
|
|
|
CI_COMMIT: getLatestCommitForBranch('4.3.x'),
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
|
|
|
'Git branch : 4.3.x\n' +
|
|
|
|
'Build/deploy mode : stable\n' +
|
|
|
|
'Firebase project : angular-io\n' +
|
|
|
|
'Firebase site : angular-io\n' +
|
|
|
|
'Deployment URL : https://angular.io/');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('stable - skip deploy - commit not HEAD', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '4.3.x',
|
|
|
|
CI_STABLE_BRANCH: '4.3.x',
|
|
|
|
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
|
|
|
})).toBe(
|
|
|
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
|
|
|
`(${getLatestCommitForBranch('4.3.x')}).`);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('archive - deploy success', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '2.4.x',
|
|
|
|
CI_STABLE_BRANCH: '4.3.x',
|
|
|
|
CI_COMMIT: getLatestCommitForBranch('2.4.x'),
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
|
|
|
'Git branch : 2.4.x\n' +
|
|
|
|
'Build/deploy mode : archive\n' +
|
|
|
|
'Firebase project : v2-angular-io\n' +
|
|
|
|
'Firebase site : v2-angular-io\n' +
|
|
|
|
'Deployment URL : https://v2.angular.io/');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('archive - v9-angular-io multisite special case - deploy success', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '9.1.x',
|
|
|
|
CI_STABLE_BRANCH: '10.0.x',
|
|
|
|
CI_COMMIT: getLatestCommitForBranch('9.1.x'),
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
|
|
|
'Git branch : 9.1.x\n' +
|
|
|
|
'Build/deploy mode : archive\n' +
|
|
|
|
'Firebase project : aio-staging\n' +
|
|
|
|
'Firebase site : v9-angular-io\n' +
|
|
|
|
'Deployment URL : https://v9.angular.io/');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('archive - skip deploy - commit not HEAD', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '2.4.x',
|
|
|
|
CI_STABLE_BRANCH: '4.3.x',
|
|
|
|
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
|
|
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
|
|
|
`(${getLatestCommitForBranch('2.4.x')}).`);
|
|
|
|
});
|
|
|
|
|
2020-10-28 06:23:57 -04:00
|
|
|
it('archive - skip deploy - major same as stable, minor less than stable', () => {
|
2020-10-28 06:23:51 -04:00
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '2.1.x',
|
|
|
|
CI_STABLE_BRANCH: '2.2.x',
|
|
|
|
CI_COMMIT: getLatestCommitForBranch('2.1.x'),
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
|
|
|
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
|
2020-10-28 06:23:57 -04:00
|
|
|
'There is a more recent branch with the same major version: "2.4.x"');
|
2020-10-28 06:23:51 -04:00
|
|
|
});
|
|
|
|
|
2020-10-28 06:23:57 -04:00
|
|
|
it('archive - skip deploy - major lower than stable, minor not latest', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '2.1.x',
|
|
|
|
CI_STABLE_BRANCH: '4.3.x',
|
|
|
|
CI_COMMIT: getLatestCommitForBranch('2.1.x'),
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
|
|
|
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
|
|
|
|
'There is a more recent branch with the same major version: "2.4.x"');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rc - deploy success - major higher than stable', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '4.4.x',
|
|
|
|
CI_STABLE_BRANCH: '2.2.x',
|
|
|
|
CI_COMMIT: getLatestCommitForBranch('4.4.x'),
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
|
|
|
'Git branch : 4.4.x\n' +
|
|
|
|
'Build/deploy mode : rc\n' +
|
|
|
|
'Firebase project : angular-io\n' +
|
|
|
|
'Firebase site : rc-angular-io-site\n' +
|
|
|
|
'Deployment URL : https://rc.angular.io/');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rc - deploy success - major same as stable, minor higher', () => {
|
2020-10-28 06:23:51 -04:00
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '2.4.x',
|
|
|
|
CI_STABLE_BRANCH: '2.2.x',
|
|
|
|
CI_COMMIT: getLatestCommitForBranch('2.4.x'),
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
2020-10-28 06:23:57 -04:00
|
|
|
'Git branch : 2.4.x\n' +
|
|
|
|
'Build/deploy mode : rc\n' +
|
|
|
|
'Firebase project : angular-io\n' +
|
|
|
|
'Firebase site : rc-angular-io-site\n' +
|
|
|
|
'Deployment URL : https://rc.angular.io/');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rc - skip deploy - commit not HEAD', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '2.4.x',
|
|
|
|
CI_STABLE_BRANCH: '2.2.x',
|
|
|
|
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
|
|
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
|
|
|
`(${getLatestCommitForBranch('2.4.x')}).`);
|
2020-10-28 06:23:51 -04:00
|
|
|
});
|
|
|
|
|
2020-10-28 06:23:57 -04:00
|
|
|
it('rc - skip deploy - major same as stable, minor not latest', () => {
|
2020-10-28 06:23:51 -04:00
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '2.1.x',
|
2020-10-28 06:23:57 -04:00
|
|
|
CI_STABLE_BRANCH: '2.0.x',
|
2020-10-28 06:23:51 -04:00
|
|
|
CI_COMMIT: getLatestCommitForBranch('2.1.x'),
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
|
|
|
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
|
|
|
|
'There is a more recent branch with the same major version: "2.4.x"');
|
|
|
|
});
|
2020-10-28 06:23:57 -04:00
|
|
|
|
|
|
|
it('rc - skip deploy - major higher than stable, minor not latest', () => {
|
|
|
|
expect(deployToFirebaseDryRun({
|
|
|
|
CI_REPO_OWNER: 'angular',
|
|
|
|
CI_REPO_NAME: 'angular',
|
|
|
|
CI_PULL_REQUEST: 'false',
|
|
|
|
CI_BRANCH: '4.3.x',
|
|
|
|
CI_STABLE_BRANCH: '2.4.x',
|
|
|
|
CI_COMMIT: getLatestCommitForBranch('4.3.x'),
|
|
|
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
|
|
|
})).toBe(
|
|
|
|
'Skipping deploy of branch "4.3.x" to Firebase.\n' +
|
|
|
|
'There is a more recent branch with the same major version: "4.4.x"');
|
|
|
|
});
|
2020-10-28 06:23:51 -04:00
|
|
|
});
|