Creates a tool for staging and publishing releases as per the new branching and versioning that has been outlined in the following document. The tool is intended to be used across the organization to ensure consistent branching/versioning and labeling: https://docs.google.com/document/d/197kVillDwx-RZtSVOBtPb4BBIAw0E9RT3q3v6DZkykU/edit#heading=h.s3qlps8f4zq7dd The tool implements the actions as outlined in the following initial plan: https://hackmd.io/2Le8leq0S6G_R5VEVTNK9A. The implementation slightly diverged in so far that it performs staging and publishing together so that releasing is a single convenient command. In case of errors for which re-running the full command is not sufficient, we want to consider adding recover functionality. e.g. when the staging completed, but the actual NPM publishing aborted unexpectedly due to build errors. PR Close #38656
80 lines
3.1 KiB
TypeScript
80 lines
3.1 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {getBranchPushMatcher} from '../../../utils/testing';
|
|
import {ReleaseTrain} from '../../versioning/release-trains';
|
|
import {ConfigureNextAsMajorAction} from '../actions/configure-next-as-major';
|
|
|
|
import {parse, setupReleaseActionForTesting} from './test-utils';
|
|
|
|
describe('configure next as major action', () => {
|
|
it('should be active if the next branch is for a minor', async () => {
|
|
expect(await ConfigureNextAsMajorAction.isActive({
|
|
releaseCandidate: null,
|
|
next: new ReleaseTrain('master', parse('10.1.0-next.3')),
|
|
latest: new ReleaseTrain('10.0.x', parse('10.0.3')),
|
|
})).toBe(true);
|
|
});
|
|
|
|
it('should be active regardless of a feature-freeze/release-candidate train', async () => {
|
|
expect(await ConfigureNextAsMajorAction.isActive({
|
|
releaseCandidate: new ReleaseTrain('10.1.x', parse('10.1.0-rc.1')),
|
|
next: new ReleaseTrain('master', parse('10.2.0-next.3')),
|
|
latest: new ReleaseTrain('10.0.x', parse('10.0.3')),
|
|
})).toBe(true);
|
|
});
|
|
|
|
it('should not be active if the next branch is for a major', async () => {
|
|
expect(await ConfigureNextAsMajorAction.isActive({
|
|
releaseCandidate: null,
|
|
next: new ReleaseTrain('master', parse('11.0.0-next.0')),
|
|
latest: new ReleaseTrain('10.0.x', parse('10.0.3')),
|
|
})).toBe(false);
|
|
});
|
|
|
|
it('should compute proper version and create staging pull request', async () => {
|
|
const action = setupReleaseActionForTesting(ConfigureNextAsMajorAction, {
|
|
releaseCandidate: null,
|
|
next: new ReleaseTrain('master', parse('10.1.0-next.3')),
|
|
latest: new ReleaseTrain('10.0.x', parse('10.0.2')),
|
|
});
|
|
|
|
const {repo, fork, gitClient} = action;
|
|
const expectedVersion = `11.0.0-next.0`;
|
|
const expectedForkBranch = `switch-next-to-major-${expectedVersion}`;
|
|
|
|
// We first mock the commit status check for the next branch, then expect two pull
|
|
// requests from a fork that are targeting next and the new feature-freeze branch.
|
|
repo.expectBranchRequest('master', 'MASTER_COMMIT_SHA')
|
|
.expectCommitStatusCheck('MASTER_COMMIT_SHA', 'success')
|
|
.expectFindForkRequest(fork)
|
|
.expectPullRequestToBeCreated('master', fork, expectedForkBranch, 200);
|
|
|
|
// In the fork, we make the staging branch appear as non-existent,
|
|
// so that the PR can be created properly without collisions.
|
|
fork.expectBranchRequest(expectedForkBranch, null);
|
|
|
|
await action.instance.perform();
|
|
|
|
expect(gitClient.pushed.length).toBe(1);
|
|
expect(gitClient.pushed[0])
|
|
.toEqual(
|
|
getBranchPushMatcher({
|
|
baseBranch: 'master',
|
|
baseRepo: repo,
|
|
targetBranch: expectedForkBranch,
|
|
targetRepo: fork,
|
|
expectedCommits: [{
|
|
message: `release: switch the next branch to v${expectedVersion}`,
|
|
files: ['package.json'],
|
|
}],
|
|
}),
|
|
'Expected the update branch to be created in fork for a pull request.');
|
|
});
|
|
});
|