@@ -582,6 +582,87 @@ describe('common release action logic', () => {
582582 } ) ,
583583 ) ;
584584 } ) ;
585+
586+ it ( 'should update the renovate config labels in the cherry-pick commit' , async ( ) => {
587+ const baseReleaseTrains = new ActiveReleaseTrains ( {
588+ exceptionalMinor : null ,
589+ releaseCandidate : new ReleaseTrain ( '10.1.x' , parse ( '10.1.0-rc.0' ) ) ,
590+ next : new ReleaseTrain ( 'master' , parse ( '10.2.0-next.0' ) ) ,
591+ latest : new ReleaseTrain ( '10.0.x' , parse ( '10.0.0' ) ) ,
592+ } ) ;
593+ const { version, branchName} = baseReleaseTrains . latest ;
594+ const forkBranchName = `changelog-cherry-pick-${ version } ` ;
595+
596+ const { repo, fork, instance, gitClient, projectDir} = setupReleaseActionForTesting (
597+ DelegateTestAction ,
598+ baseReleaseTrains ,
599+ ) ;
600+
601+ // Expect the changelog to be fetched and return a fake changelog to test that
602+ // it is properly appended. Also expect a pull request to be created in the fork.
603+ repo
604+ . expectFindForkRequest ( fork )
605+ . expectPullRequestToBeCreated ( 'master' , fork , forkBranchName , 200 )
606+ . expectPullRequestMergeCheck ( 200 , false )
607+ . expectPullRequestMerge ( 200 ) ;
608+
609+ // Simulate that the fork branch name is available.
610+ fork . expectBranchRequest ( forkBranchName ) ;
611+
612+ const renovateConfigPath = join ( projectDir , 'renovate.json' ) ;
613+ writeFileSync (
614+ renovateConfigPath ,
615+ JSON . stringify ( {
616+ 'baseBranches' : [ 'main' , '20.1.x' ] ,
617+ 'packageRules' : [
618+ {
619+ 'matchBaseBranches' : [ 'main' ] ,
620+ 'addLabels' : [ 'target: minor' ] ,
621+ } ,
622+ {
623+ 'matchBaseBranches' : [ '!main' ] ,
624+ 'addLabels' : [ 'target: rc' ] ,
625+ } ,
626+ ] ,
627+ } ) ,
628+ 'utf8' ,
629+ ) ;
630+
631+ await instance . testCherryPickWithPullRequest ( version , branchName ) ;
632+
633+ expect ( gitClient . pushed . length ) . toBe ( 1 ) ;
634+ expect ( gitClient . pushed [ 0 ] ) . toEqual (
635+ getBranchPushMatcher ( {
636+ targetBranch : forkBranchName ,
637+ targetRepo : fork ,
638+ baseBranch : 'master' ,
639+ baseRepo : repo ,
640+ expectedCommits : [
641+ {
642+ message : `docs: release notes for the v${ version } release` ,
643+ files : [ 'CHANGELOG.md' , renovateConfigPath ] ,
644+ } ,
645+ ] ,
646+ } ) ,
647+ ) ;
648+
649+ // Verify renovate config contents
650+ const { packageRules} = JSON . parse ( readFileSync ( renovateConfigPath , 'utf-8' ) ) as Record <
651+ string ,
652+ unknown
653+ > ;
654+
655+ expect ( packageRules ) . toEqual ( [
656+ {
657+ 'matchBaseBranches' : [ 'main' ] ,
658+ 'addLabels' : [ 'target: minor' ] ,
659+ } ,
660+ {
661+ 'matchBaseBranches' : [ '!main' ] ,
662+ 'addLabels' : [ 'target: patch' ] ,
663+ } ,
664+ ] ) ;
665+ } ) ;
585666 } ) ;
586667} ) ;
587668
0 commit comments