Skip to content

Commit

Permalink
feat(ng-dev): support exceptional minor target labeling in the interim
Browse files Browse the repository at this point in the history
Until we have implemented the actual exceptional minor mechanism in both
the release and merge tool, we want to be able to turn `target: minor`
into `target: rc` (internally) so that minor changes can go into the
RC/FF phase that we "misuse" as the exceptional minor release train.
  • Loading branch information
devversion committed Jun 21, 2022
1 parent 5a1ba84 commit 3276c53
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ng-dev/pr/common/targeting/labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
import {assertActiveLtsBranch} from './lts-branch.js';
import {GithubClient} from '../../../utils/git/github.js';
import {Log} from '../../../utils/logging.js';
import {assertValidPullRequestConfig, PullRequestConfig} from '../../config/index.js';

/**
* Gets a list of target labels which should be considered by the merge
Expand All @@ -45,9 +46,14 @@ import {Log} from '../../../utils/logging.js';
export async function getTargetLabelsForActiveReleaseTrains(
{latest, releaseCandidate, next}: ActiveReleaseTrains,
api: GithubClient,
config: NgDevConfig<{github?: GithubConfig; release?: ReleaseConfig}>,
config: NgDevConfig<{
github: GithubConfig;
pullRequest: PullRequestConfig;
release?: ReleaseConfig;
}>,
): Promise<TargetLabel[]> {
assertValidGithubConfig(config);
assertValidPullRequestConfig(config);

const nextBranchName = getNextBranchName(config.github);
const repo: ReleaseRepoWithApi = {
Expand Down Expand Up @@ -80,7 +86,14 @@ export async function getTargetLabelsForActiveReleaseTrains(
// TODO: Consider handling this automatically by checking if the NPM version matches
// the last-minor. If not, then an exceptional minor might be in progress. See:
// https://docs.google.com/document/d/197kVillDwx-RZtSVOBtPb4BBIAw0E9RT3q3v6DZkykU/edit#heading=h.h7o5pjq6yqd0
branches: () => [nextBranchName],
branches: () => {
// TODO(devversion): Remove this when we actually support exceptional minors.
if (config.pullRequest.__specialTreatRcAsExceptionalMinor && releaseCandidate !== null) {
return [releaseCandidate.branchName];
}

return [nextBranchName];
},
},
{
name: TargetLabelName.PATCH,
Expand Down
8 changes: 8 additions & 0 deletions ng-dev/pr/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export interface PullRequestConfig {
* scopes in patch branches, no breaking changes in minor or patch changes.
*/
targetLabelExemptScopes?: string[];

/**
* Special flag that should **NOT** be used without confirming with the dev-infra team.
* This flag turns the RC/FF release-train into an exceptional minor release-train by:
*
* - changing `target: minor` to point to `target: rc` (without the RC merge restrictions)
*/
__specialTreatRcAsExceptionalMinor?: boolean;
}

/** Loads and validates the merge configuration. */
Expand Down
5 changes: 5 additions & 0 deletions ng-dev/pr/merge/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ describe('default target labels', () => {
const targetLabels = await getTargetLabelsForActiveReleaseTrains(releaseTrains, api, {
github: githubConfig,
release: releaseConfig,
pullRequest: {
commitMessageFixupLabel: 'commit message fixup',
githubApiMerge: false,
mergeReadyLabel: 'merge ready',
},
__isNgDevConfigObject: true,
});
let label: TargetLabel;
Expand Down

0 comments on commit 3276c53

Please sign in to comment.