Skip to content
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
10 changes: 6 additions & 4 deletions ng-dev/release/publish/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,17 @@ export abstract class ReleaseAction {
stagingBranch: string,
): Promise<boolean> {
const nextBranch = this.active.next.branchName;
const commitMessage = getReleaseNoteCherryPickCommitMessage(releaseNotes.version);
const {version} = releaseNotes;
const commitMessage = getReleaseNoteCherryPickCommitMessage(version);

// Checkout the next branch.
await this.checkoutUpstreamBranch(nextBranch);

await this.prependReleaseNotesToChangelog(releaseNotes);

const filesToCommit: string[] = [workspaceRelativeChangelogPath];
if (releaseNotes.version.patch === 0 && !releaseNotes.version.prerelease) {

if (version.patch === 0 && version.prerelease.length === 0) {
// Switch the renovate labels for `target: rc` to `target: patch`
const renovateConfigPath = await updateRenovateConfigTargetLabels(
this.projectDir,
Expand All @@ -597,12 +599,12 @@ export abstract class ReleaseAction {
}

await this.createCommit(commitMessage, filesToCommit);
Log.info(green(` ✓ Created changelog cherry-pick commit for: "${releaseNotes.version}".`));
Log.info(green(` ✓ Created changelog cherry-pick commit for: "${version}".`));

// Create a cherry-pick pull request that should be merged by the caretaker.
const pullRequest = await this.pushChangesToForkAndCreatePullRequest(
nextBranch,
`changelog-cherry-pick-${releaseNotes.version}`,
`changelog-cherry-pick-${version}`,
commitMessage,
`Cherry-picks the changelog from the "${stagingBranch}" branch to the next ` +
`branch (${nextBranch}).`,
Expand Down
81 changes: 81 additions & 0 deletions ng-dev/release/publish/test/common.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,87 @@
}),
);
});

it('should update the renovate config labels in the cherry-pick commit', async () => {
const baseReleaseTrains = new ActiveReleaseTrains({
exceptionalMinor: null,
releaseCandidate: new ReleaseTrain('10.1.x', parse('10.1.0-rc.0')),
next: new ReleaseTrain('master', parse('10.2.0-next.0')),

Check notice on line 590 in ng-dev/release/publish/test/common.spec.ts

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/master/gi
latest: new ReleaseTrain('10.0.x', parse('10.0.0')),
});
const {version, branchName} = baseReleaseTrains.latest;
const forkBranchName = `changelog-cherry-pick-${version}`;

const {repo, fork, instance, gitClient, projectDir} = setupReleaseActionForTesting(
DelegateTestAction,
baseReleaseTrains,
);

// Expect the changelog to be fetched and return a fake changelog to test that
// it is properly appended. Also expect a pull request to be created in the fork.
repo
.expectFindForkRequest(fork)
.expectPullRequestToBeCreated('master', fork, forkBranchName, 200)

Check notice on line 605 in ng-dev/release/publish/test/common.spec.ts

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/master/gi
.expectPullRequestMergeCheck(200, false)
.expectPullRequestMerge(200);

// Simulate that the fork branch name is available.
fork.expectBranchRequest(forkBranchName);

const renovateConfigPath = join(projectDir, 'renovate.json');
writeFileSync(
renovateConfigPath,
JSON.stringify({
'baseBranches': ['main', '20.1.x'],
'packageRules': [
{
'matchBaseBranches': ['main'],
'addLabels': ['target: minor'],
},
{
'matchBaseBranches': ['!main'],
'addLabels': ['target: rc'],
},
],
}),
'utf8',
);

await instance.testCherryPickWithPullRequest(version, branchName);

expect(gitClient.pushed.length).toBe(1);
expect(gitClient.pushed[0]).toEqual(
getBranchPushMatcher({
targetBranch: forkBranchName,
targetRepo: fork,
baseBranch: 'master',

Check notice on line 638 in ng-dev/release/publish/test/common.spec.ts

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

Please consider an alternative to `master`. Possibilities include: `primary`, `main`, `leader`, `active`, `writer`
Raw output
/master/gi
baseRepo: repo,
expectedCommits: [
{
message: `docs: release notes for the v${version} release`,
files: ['CHANGELOG.md', renovateConfigPath],
},
],
}),
);

// Verify renovate config contents
const {packageRules} = JSON.parse(readFileSync(renovateConfigPath, 'utf-8')) as Record<
string,
unknown
>;

expect(packageRules).toEqual([
{
'matchBaseBranches': ['main'],
'addLabels': ['target: minor'],
},
{
'matchBaseBranches': ['!main'],
'addLabels': ['target: patch'],
},
]);
});
});
});

Expand Down