From a3258229c75b45fbeae870e7aa82386c0dafedc4 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Fri, 13 Sep 2024 10:48:24 -0600 Subject: [PATCH] feat(ng-dev): allow for labels to be applied to only a subset of managed repositories Allow for specific labels to be applied to a subset of managed repositories instead of all --- .github/local-actions/branch-manager/main.js | 112 +++++++++++------ .github/local-actions/labels-sync/main.js | 117 ++++++++++++------ .github/local-actions/labels-sync/src/main.ts | 7 +- github-actions/branch-manager/main.js | 112 +++++++++++------ .../commit-message-based-labels/lib/main.ts | 7 +- .../commit-message-based-labels/main.js | 117 ++++++++++++------ github-actions/unified-status-check/main.js | 112 +++++++++++------ ng-dev/pr/common/labels/action.ts | 4 +- ng-dev/pr/common/labels/base.ts | 42 +++++-- ng-dev/pr/common/labels/feature.ts | 4 +- ng-dev/pr/common/labels/index.ts | 4 +- ng-dev/pr/common/labels/managed.ts | 40 +++--- ng-dev/pr/common/labels/merge.ts | 4 +- ng-dev/pr/common/labels/misc.ts | 4 +- ng-dev/pr/common/labels/needs.ts | 4 +- ng-dev/pr/common/labels/priority.ts | 4 +- ng-dev/pr/common/labels/requires.ts | 4 +- ng-dev/pr/common/labels/target.ts | 26 ++-- 18 files changed, 483 insertions(+), 241 deletions(-) diff --git a/.github/local-actions/branch-manager/main.js b/.github/local-actions/branch-manager/main.js index e168f7ff5..5c4c904b8 100644 --- a/.github/local-actions/branch-manager/main.js +++ b/.github/local-actions/branch-manager/main.js @@ -57887,14 +57887,35 @@ async function assertActiveLtsBranch(repo2, releaseConfig, branchName) { } // -var createTypedObject = () => (v) => v; +var createTypedObject = (LabelConstructor) => { + return (val) => { + for (const key in val) { + val[key] = new LabelConstructor(val[key]); + } + return val; + }; +}; var Label = class { - constructor({ name, description, color }) { - this.name = name; - this.description = description; - this.color = color; + constructor(params4) { + this.params = params4; + this.repositories = this.params.repositories || [ + ManagedRepositories.ANGULAR, + ManagedRepositories.ANGULAR_CLI, + ManagedRepositories.COMPONENTS, + ManagedRepositories.DEV_INFRA + ]; + this.name = this.params.name; + this.description = this.params.description; + this.color = this.params.color; } }; +var ManagedRepositories; +(function(ManagedRepositories2) { + ManagedRepositories2["COMPONENTS"] = "components"; + ManagedRepositories2["ANGULAR"] = "angular"; + ManagedRepositories2["ANGULAR_CLI"] = "angular-cli"; + ManagedRepositories2["DEV_INFRA"] = "dev-infra"; +})(ManagedRepositories || (ManagedRepositories = {})); // var TargetLabel = class extends Label { @@ -57903,31 +57924,31 @@ var TargetLabel = class extends Label { this.__hasTargetLabelMarker__ = true; } }; -var targetLabels = createTypedObject()({ - TARGET_FEATURE: new TargetLabel({ +var targetLabels = createTypedObject(TargetLabel)({ + TARGET_FEATURE: { description: "This PR is targeted for a feature branch (outside of main and semver branches)", name: "target: feature" - }), - TARGET_LTS: new TargetLabel({ + }, + TARGET_LTS: { description: "This PR is targeting a version currently in long-term support", name: "target: lts" - }), - TARGET_MAJOR: new TargetLabel({ + }, + TARGET_MAJOR: { description: "This PR is targeted for the next major release", name: "target: major" - }), - TARGET_MINOR: new TargetLabel({ + }, + TARGET_MINOR: { description: "This PR is targeted for the next minor release", name: "target: minor" - }), - TARGET_PATCH: new TargetLabel({ + }, + TARGET_PATCH: { description: "This PR is targeted for the next patch release", name: "target: patch" - }), - TARGET_RC: new TargetLabel({ + }, + TARGET_RC: { description: "This PR is targeted for the next release-candidate", name: "target: rc" - }) + } }); // @@ -59067,7 +59088,13 @@ function parseInternal(fullText) { } // -var managedLabels = createTypedObject()({ +var ManagedLabel = class extends Label { + constructor() { + super(...arguments); + this.commitCheck = this.params.commitCheck; + } +}; +var managedLabels = createTypedObject(ManagedLabel)({ DETECTED_BREAKING_CHANGE: { description: "PR contains a commit with a breaking change", name: "detected: breaking change", @@ -59088,16 +59115,6 @@ var managedLabels = createTypedObject()({ name: "area: docs", commitCheck: (c) => c.type === "docs" }, - DETECTED_COMPILER_CHANGE: { - description: "Issues related to `ngc`, Angular's template compiler", - name: "area: compiler", - commitCheck: (c) => c.type === "compiler" || c.type === "compiler-cli" - }, - DETECTED_PLATFORM_BROWSER_CHANGE: { - description: "Issues related to the framework runtime", - name: "area: core", - commitCheck: (c) => c.type === "platform-browser" || c.type === "core" - }, DETECTED_INFRA_CHANGE: { description: "Related the build and CI infrastructure of the project", name: "area: build & ci", @@ -59109,14 +59126,29 @@ var managedLabels = createTypedObject()({ commitCheck: (c) => c.type === "perf" }, DETECTED_HTTP_CHANGE: { - description: "", + description: "Issues related to HTTP and HTTP Client", name: "area: common/http", - commitCheck: (c) => c.type === "common/http" || c.type === "http" + commitCheck: (c) => c.type === "common/http" || c.type === "http", + repositories: [ManagedRepositories.ANGULAR] + }, + DETECTED_COMPILER_CHANGE: { + description: "Issues related to `ngc`, Angular's template compiler", + name: "area: compiler", + commitCheck: (c) => c.type === "compiler" || c.type === "compiler-cli", + repositories: [ManagedRepositories.ANGULAR] + }, + DETECTED_PLATFORM_BROWSER_CHANGE: { + description: "Issues related to the framework runtime", + name: "area: core", + commitCheck: (c) => c.type === "platform-browser" || c.type === "core", + repositories: [ManagedRepositories.ANGULAR] } }); // -var actionLabels = createTypedObject()({ +var ActionLabel = class extends Label { +}; +var actionLabels = createTypedObject(ActionLabel)({ ACTION_MERGE: { description: "The PR is ready for merge by the caretaker", name: "action: merge" @@ -59140,7 +59172,9 @@ var actionLabels = createTypedObject()({ }); // -var mergeLabels = createTypedObject()({ +var MergeLabel = class extends Label { +}; +var mergeLabels = createTypedObject(MergeLabel)({ MERGE_PRESERVE_COMMITS: { description: "When the PR is merged, a rebase and merge should be performed", name: "merge: preserve commits" @@ -59160,7 +59194,9 @@ var mergeLabels = createTypedObject()({ }); // -var priorityLabels = createTypedObject()({ +var PriorityLabel = class extends Label { +}; +var priorityLabels = createTypedObject(PriorityLabel)({ P0: { name: "P0", description: "Issue that causes an outage, breakage, or major function to be unusable, with no known workarounds" @@ -59188,7 +59224,9 @@ var priorityLabels = createTypedObject()({ }); // -var featureLabels = createTypedObject()({ +var FeatureLabel = class extends Label { +}; +var featureLabels = createTypedObject(FeatureLabel)({ FEATURE_IN_BACKLOG: { name: "feature: in backlog", description: "Feature request for which voting has completed and is now in the backlog" @@ -59208,7 +59246,9 @@ var featureLabels = createTypedObject()({ }); // -var requiresLabels = createTypedObject()({ +var RequiresLabel = class extends Label { +}; +var requiresLabels = createTypedObject(RequiresLabel)({ REQUIRES_TGP: { name: "requires: TGP", description: "This PR requires a passing TGP before merging is allowed" diff --git a/.github/local-actions/labels-sync/main.js b/.github/local-actions/labels-sync/main.js index 8f575f155..920f65c00 100644 --- a/.github/local-actions/labels-sync/main.js +++ b/.github/local-actions/labels-sync/main.js @@ -42911,17 +42911,44 @@ var Octokit2 = Octokit.plugin(requestLog, legacyRestEndpointMethods, paginateRes ); // -var createTypedObject = () => (v) => v; +var createTypedObject = (LabelConstructor) => { + return (val) => { + for (const key in val) { + val[key] = new LabelConstructor(val[key]); + } + return val; + }; +}; var Label = class { - constructor({ name, description, color }) { - this.name = name; - this.description = description; - this.color = color; + constructor(params) { + this.params = params; + this.repositories = this.params.repositories || [ + ManagedRepositories.ANGULAR, + ManagedRepositories.ANGULAR_CLI, + ManagedRepositories.COMPONENTS, + ManagedRepositories.DEV_INFRA + ]; + this.name = this.params.name; + this.description = this.params.description; + this.color = this.params.color; } }; +var ManagedRepositories; +(function(ManagedRepositories2) { + ManagedRepositories2["COMPONENTS"] = "components"; + ManagedRepositories2["ANGULAR"] = "angular"; + ManagedRepositories2["ANGULAR_CLI"] = "angular-cli"; + ManagedRepositories2["DEV_INFRA"] = "dev-infra"; +})(ManagedRepositories || (ManagedRepositories = {})); // -var managedLabels = createTypedObject()({ +var ManagedLabel = class extends Label { + constructor() { + super(...arguments); + this.commitCheck = this.params.commitCheck; + } +}; +var managedLabels = createTypedObject(ManagedLabel)({ DETECTED_BREAKING_CHANGE: { description: "PR contains a commit with a breaking change", name: "detected: breaking change", @@ -42942,16 +42969,6 @@ var managedLabels = createTypedObject()({ name: "area: docs", commitCheck: (c) => c.type === "docs" }, - DETECTED_COMPILER_CHANGE: { - description: "Issues related to `ngc`, Angular's template compiler", - name: "area: compiler", - commitCheck: (c) => c.type === "compiler" || c.type === "compiler-cli" - }, - DETECTED_PLATFORM_BROWSER_CHANGE: { - description: "Issues related to the framework runtime", - name: "area: core", - commitCheck: (c) => c.type === "platform-browser" || c.type === "core" - }, DETECTED_INFRA_CHANGE: { description: "Related the build and CI infrastructure of the project", name: "area: build & ci", @@ -42963,14 +42980,29 @@ var managedLabels = createTypedObject()({ commitCheck: (c) => c.type === "perf" }, DETECTED_HTTP_CHANGE: { - description: "", + description: "Issues related to HTTP and HTTP Client", name: "area: common/http", - commitCheck: (c) => c.type === "common/http" || c.type === "http" + commitCheck: (c) => c.type === "common/http" || c.type === "http", + repositories: [ManagedRepositories.ANGULAR] + }, + DETECTED_COMPILER_CHANGE: { + description: "Issues related to `ngc`, Angular's template compiler", + name: "area: compiler", + commitCheck: (c) => c.type === "compiler" || c.type === "compiler-cli", + repositories: [ManagedRepositories.ANGULAR] + }, + DETECTED_PLATFORM_BROWSER_CHANGE: { + description: "Issues related to the framework runtime", + name: "area: core", + commitCheck: (c) => c.type === "platform-browser" || c.type === "core", + repositories: [ManagedRepositories.ANGULAR] } }); // -var actionLabels = createTypedObject()({ +var ActionLabel = class extends Label { +}; +var actionLabels = createTypedObject(ActionLabel)({ ACTION_MERGE: { description: "The PR is ready for merge by the caretaker", name: "action: merge" @@ -42994,7 +43026,9 @@ var actionLabels = createTypedObject()({ }); // -var mergeLabels = createTypedObject()({ +var MergeLabel = class extends Label { +}; +var mergeLabels = createTypedObject(MergeLabel)({ MERGE_PRESERVE_COMMITS: { description: "When the PR is merged, a rebase and merge should be performed", name: "merge: preserve commits" @@ -43020,35 +43054,37 @@ var TargetLabel = class extends Label { this.__hasTargetLabelMarker__ = true; } }; -var targetLabels = createTypedObject()({ - TARGET_FEATURE: new TargetLabel({ +var targetLabels = createTypedObject(TargetLabel)({ + TARGET_FEATURE: { description: "This PR is targeted for a feature branch (outside of main and semver branches)", name: "target: feature" - }), - TARGET_LTS: new TargetLabel({ + }, + TARGET_LTS: { description: "This PR is targeting a version currently in long-term support", name: "target: lts" - }), - TARGET_MAJOR: new TargetLabel({ + }, + TARGET_MAJOR: { description: "This PR is targeted for the next major release", name: "target: major" - }), - TARGET_MINOR: new TargetLabel({ + }, + TARGET_MINOR: { description: "This PR is targeted for the next minor release", name: "target: minor" - }), - TARGET_PATCH: new TargetLabel({ + }, + TARGET_PATCH: { description: "This PR is targeted for the next patch release", name: "target: patch" - }), - TARGET_RC: new TargetLabel({ + }, + TARGET_RC: { description: "This PR is targeted for the next release-candidate", name: "target: rc" - }) + } }); // -var priorityLabels = createTypedObject()({ +var PriorityLabel = class extends Label { +}; +var priorityLabels = createTypedObject(PriorityLabel)({ P0: { name: "P0", description: "Issue that causes an outage, breakage, or major function to be unusable, with no known workarounds" @@ -43076,7 +43112,9 @@ var priorityLabels = createTypedObject()({ }); // -var featureLabels = createTypedObject()({ +var FeatureLabel = class extends Label { +}; +var featureLabels = createTypedObject(FeatureLabel)({ FEATURE_IN_BACKLOG: { name: "feature: in backlog", description: "Feature request for which voting has completed and is now in the backlog" @@ -43096,7 +43134,9 @@ var featureLabels = createTypedObject()({ }); // -var requiresLabels = createTypedObject()({ +var RequiresLabel = class extends Label { +}; +var requiresLabels = createTypedObject(RequiresLabel)({ REQUIRES_TGP: { name: "requires: TGP", description: "This PR requires a passing TGP before merging is allowed" @@ -45414,7 +45454,10 @@ async function syncLabelsInRepo(github, repoName, managedLabels2) { core.debug(`Requesting labels`); const repoLabels = await github.paginate(github.issues.listLabelsForRepo, repo); core.debug(`Retrieved ${repoLabels.length} from Github`); - for (const { description, name, color } of managedLabels2) { + for (const { description, name, color, repositories } of managedLabels2) { + if (!repositories.includes(repoName)) { + continue; + } const matchedLabel = repoLabels.find((label) => label.name === name); if (matchedLabel === void 0) { core.info(`${name}: Adding label to repository`); diff --git a/.github/local-actions/labels-sync/src/main.ts b/.github/local-actions/labels-sync/src/main.ts index 7acc2b23c..df0799310 100644 --- a/.github/local-actions/labels-sync/src/main.ts +++ b/.github/local-actions/labels-sync/src/main.ts @@ -7,6 +7,7 @@ import { ANGULAR_ROBOT, revokeActiveInstallationToken, } from '../../../../github-actions/utils.js'; +import {ManagedRepositories} from '../../../../ng-dev/pr/common/labels/base.js'; /** The type for a Github label returned from the Github API. */ type GithubLabel = @@ -26,7 +27,11 @@ async function syncLabelsInRepo(github: Octokit, repoName: string, managedLabels // For each label in the list of managed labels, ensure that it exists and is in sync. // NOTE: Not all labels in repositories are managed. Labels which are not included or managed in // our tooling definitions and configurations are ignored entirely by tooling. - for (const {description, name, color} of managedLabels) { + for (const {description, name, color, repositories} of managedLabels) { + // Only apply the logic for the repositories the Label is registered for. + if (!repositories.includes(repoName as ManagedRepositories)) { + continue; + } /** The label from Github if a match is found. */ const matchedLabel = repoLabels.find((label: GithubLabel) => label.name === name); diff --git a/github-actions/branch-manager/main.js b/github-actions/branch-manager/main.js index 9cc64fe72..abdceca3a 100644 --- a/github-actions/branch-manager/main.js +++ b/github-actions/branch-manager/main.js @@ -42911,17 +42911,44 @@ var Octokit2 = Octokit.plugin(requestLog, legacyRestEndpointMethods, paginateRes ); // -var createTypedObject = () => (v) => v; +var createTypedObject = (LabelConstructor) => { + return (val) => { + for (const key in val) { + val[key] = new LabelConstructor(val[key]); + } + return val; + }; +}; var Label = class { - constructor({ name, description, color }) { - this.name = name; - this.description = description; - this.color = color; + constructor(params) { + this.params = params; + this.repositories = this.params.repositories || [ + ManagedRepositories.ANGULAR, + ManagedRepositories.ANGULAR_CLI, + ManagedRepositories.COMPONENTS, + ManagedRepositories.DEV_INFRA + ]; + this.name = this.params.name; + this.description = this.params.description; + this.color = this.params.color; } }; +var ManagedRepositories; +(function(ManagedRepositories2) { + ManagedRepositories2["COMPONENTS"] = "components"; + ManagedRepositories2["ANGULAR"] = "angular"; + ManagedRepositories2["ANGULAR_CLI"] = "angular-cli"; + ManagedRepositories2["DEV_INFRA"] = "dev-infra"; +})(ManagedRepositories || (ManagedRepositories = {})); // -var managedLabels = createTypedObject()({ +var ManagedLabel = class extends Label { + constructor() { + super(...arguments); + this.commitCheck = this.params.commitCheck; + } +}; +var managedLabels = createTypedObject(ManagedLabel)({ DETECTED_BREAKING_CHANGE: { description: "PR contains a commit with a breaking change", name: "detected: breaking change", @@ -42942,16 +42969,6 @@ var managedLabels = createTypedObject()({ name: "area: docs", commitCheck: (c) => c.type === "docs" }, - DETECTED_COMPILER_CHANGE: { - description: "Issues related to `ngc`, Angular's template compiler", - name: "area: compiler", - commitCheck: (c) => c.type === "compiler" || c.type === "compiler-cli" - }, - DETECTED_PLATFORM_BROWSER_CHANGE: { - description: "Issues related to the framework runtime", - name: "area: core", - commitCheck: (c) => c.type === "platform-browser" || c.type === "core" - }, DETECTED_INFRA_CHANGE: { description: "Related the build and CI infrastructure of the project", name: "area: build & ci", @@ -42963,14 +42980,29 @@ var managedLabels = createTypedObject()({ commitCheck: (c) => c.type === "perf" }, DETECTED_HTTP_CHANGE: { - description: "", + description: "Issues related to HTTP and HTTP Client", name: "area: common/http", - commitCheck: (c) => c.type === "common/http" || c.type === "http" + commitCheck: (c) => c.type === "common/http" || c.type === "http", + repositories: [ManagedRepositories.ANGULAR] + }, + DETECTED_COMPILER_CHANGE: { + description: "Issues related to `ngc`, Angular's template compiler", + name: "area: compiler", + commitCheck: (c) => c.type === "compiler" || c.type === "compiler-cli", + repositories: [ManagedRepositories.ANGULAR] + }, + DETECTED_PLATFORM_BROWSER_CHANGE: { + description: "Issues related to the framework runtime", + name: "area: core", + commitCheck: (c) => c.type === "platform-browser" || c.type === "core", + repositories: [ManagedRepositories.ANGULAR] } }); // -var actionLabels = createTypedObject()({ +var ActionLabel = class extends Label { +}; +var actionLabels = createTypedObject(ActionLabel)({ ACTION_MERGE: { description: "The PR is ready for merge by the caretaker", name: "action: merge" @@ -42994,7 +43026,9 @@ var actionLabels = createTypedObject()({ }); // -var mergeLabels = createTypedObject()({ +var MergeLabel = class extends Label { +}; +var mergeLabels = createTypedObject(MergeLabel)({ MERGE_PRESERVE_COMMITS: { description: "When the PR is merged, a rebase and merge should be performed", name: "merge: preserve commits" @@ -43020,35 +43054,37 @@ var TargetLabel = class extends Label { this.__hasTargetLabelMarker__ = true; } }; -var targetLabels = createTypedObject()({ - TARGET_FEATURE: new TargetLabel({ +var targetLabels = createTypedObject(TargetLabel)({ + TARGET_FEATURE: { description: "This PR is targeted for a feature branch (outside of main and semver branches)", name: "target: feature" - }), - TARGET_LTS: new TargetLabel({ + }, + TARGET_LTS: { description: "This PR is targeting a version currently in long-term support", name: "target: lts" - }), - TARGET_MAJOR: new TargetLabel({ + }, + TARGET_MAJOR: { description: "This PR is targeted for the next major release", name: "target: major" - }), - TARGET_MINOR: new TargetLabel({ + }, + TARGET_MINOR: { description: "This PR is targeted for the next minor release", name: "target: minor" - }), - TARGET_PATCH: new TargetLabel({ + }, + TARGET_PATCH: { description: "This PR is targeted for the next patch release", name: "target: patch" - }), - TARGET_RC: new TargetLabel({ + }, + TARGET_RC: { description: "This PR is targeted for the next release-candidate", name: "target: rc" - }) + } }); // -var priorityLabels = createTypedObject()({ +var PriorityLabel = class extends Label { +}; +var priorityLabels = createTypedObject(PriorityLabel)({ P0: { name: "P0", description: "Issue that causes an outage, breakage, or major function to be unusable, with no known workarounds" @@ -43076,7 +43112,9 @@ var priorityLabels = createTypedObject()({ }); // -var featureLabels = createTypedObject()({ +var FeatureLabel = class extends Label { +}; +var featureLabels = createTypedObject(FeatureLabel)({ FEATURE_IN_BACKLOG: { name: "feature: in backlog", description: "Feature request for which voting has completed and is now in the backlog" @@ -43096,7 +43134,9 @@ var featureLabels = createTypedObject()({ }); // -var requiresLabels = createTypedObject()({ +var RequiresLabel = class extends Label { +}; +var requiresLabels = createTypedObject(RequiresLabel)({ REQUIRES_TGP: { name: "requires: TGP", description: "This PR requires a passing TGP before merging is allowed" diff --git a/github-actions/commit-message-based-labels/lib/main.ts b/github-actions/commit-message-based-labels/lib/main.ts index dde239f04..c0acf38b4 100644 --- a/github-actions/commit-message-based-labels/lib/main.ts +++ b/github-actions/commit-message-based-labels/lib/main.ts @@ -4,6 +4,7 @@ import {Octokit} from '@octokit/rest'; import {Commit, parseCommitMessage} from '../../../ng-dev/commit-message/parse.js'; import {managedLabels} from '../../../ng-dev/pr/common/labels/index.js'; import {ANGULAR_ROBOT, getAuthTokenFor, revokeActiveInstallationToken} from '../../utils.js'; +import {ManagedRepositories} from '../../../ng-dev/pr/common/labels/base.js'; class CommitMessageBasedLabelManager { /** Run the commit message based labelling process. */ @@ -36,7 +37,11 @@ class CommitMessageBasedLabelManager { // Add or Remove label as appropriate for each of the supported label and commit messaage // combinations. - for (const {commitCheck, name} of Object.values(managedLabels)) { + for (const {commitCheck, name, repositories} of Object.values(managedLabels)) { + // Only apply the logic for the repositories the Label is registered for. + if (!repositories.includes(context.repo.repo as ManagedRepositories)) { + continue; + } const hasCommit = this.commits.some(commitCheck); const hasLabel = this.labels.has(name); core.info(`${name} | hasLabel: ${hasLabel} | hasCommit: ${hasCommit}`); diff --git a/github-actions/commit-message-based-labels/main.js b/github-actions/commit-message-based-labels/main.js index ef489ae61..a588c72d1 100644 --- a/github-actions/commit-message-based-labels/main.js +++ b/github-actions/commit-message-based-labels/main.js @@ -43376,17 +43376,44 @@ function parseInternal(fullText) { } // -var createTypedObject = () => (v) => v; +var createTypedObject = (LabelConstructor) => { + return (val) => { + for (const key in val) { + val[key] = new LabelConstructor(val[key]); + } + return val; + }; +}; var Label = class { - constructor({ name, description, color }) { - this.name = name; - this.description = description; - this.color = color; + constructor(params) { + this.params = params; + this.repositories = this.params.repositories || [ + ManagedRepositories.ANGULAR, + ManagedRepositories.ANGULAR_CLI, + ManagedRepositories.COMPONENTS, + ManagedRepositories.DEV_INFRA + ]; + this.name = this.params.name; + this.description = this.params.description; + this.color = this.params.color; } }; +var ManagedRepositories; +(function(ManagedRepositories2) { + ManagedRepositories2["COMPONENTS"] = "components"; + ManagedRepositories2["ANGULAR"] = "angular"; + ManagedRepositories2["ANGULAR_CLI"] = "angular-cli"; + ManagedRepositories2["DEV_INFRA"] = "dev-infra"; +})(ManagedRepositories || (ManagedRepositories = {})); // -var managedLabels = createTypedObject()({ +var ManagedLabel = class extends Label { + constructor() { + super(...arguments); + this.commitCheck = this.params.commitCheck; + } +}; +var managedLabels = createTypedObject(ManagedLabel)({ DETECTED_BREAKING_CHANGE: { description: "PR contains a commit with a breaking change", name: "detected: breaking change", @@ -43407,16 +43434,6 @@ var managedLabels = createTypedObject()({ name: "area: docs", commitCheck: (c) => c.type === "docs" }, - DETECTED_COMPILER_CHANGE: { - description: "Issues related to `ngc`, Angular's template compiler", - name: "area: compiler", - commitCheck: (c) => c.type === "compiler" || c.type === "compiler-cli" - }, - DETECTED_PLATFORM_BROWSER_CHANGE: { - description: "Issues related to the framework runtime", - name: "area: core", - commitCheck: (c) => c.type === "platform-browser" || c.type === "core" - }, DETECTED_INFRA_CHANGE: { description: "Related the build and CI infrastructure of the project", name: "area: build & ci", @@ -43428,14 +43445,29 @@ var managedLabels = createTypedObject()({ commitCheck: (c) => c.type === "perf" }, DETECTED_HTTP_CHANGE: { - description: "", + description: "Issues related to HTTP and HTTP Client", name: "area: common/http", - commitCheck: (c) => c.type === "common/http" || c.type === "http" + commitCheck: (c) => c.type === "common/http" || c.type === "http", + repositories: [ManagedRepositories.ANGULAR] + }, + DETECTED_COMPILER_CHANGE: { + description: "Issues related to `ngc`, Angular's template compiler", + name: "area: compiler", + commitCheck: (c) => c.type === "compiler" || c.type === "compiler-cli", + repositories: [ManagedRepositories.ANGULAR] + }, + DETECTED_PLATFORM_BROWSER_CHANGE: { + description: "Issues related to the framework runtime", + name: "area: core", + commitCheck: (c) => c.type === "platform-browser" || c.type === "core", + repositories: [ManagedRepositories.ANGULAR] } }); // -var actionLabels = createTypedObject()({ +var ActionLabel = class extends Label { +}; +var actionLabels = createTypedObject(ActionLabel)({ ACTION_MERGE: { description: "The PR is ready for merge by the caretaker", name: "action: merge" @@ -43459,7 +43491,9 @@ var actionLabels = createTypedObject()({ }); // -var mergeLabels = createTypedObject()({ +var MergeLabel = class extends Label { +}; +var mergeLabels = createTypedObject(MergeLabel)({ MERGE_PRESERVE_COMMITS: { description: "When the PR is merged, a rebase and merge should be performed", name: "merge: preserve commits" @@ -43485,35 +43519,37 @@ var TargetLabel = class extends Label { this.__hasTargetLabelMarker__ = true; } }; -var targetLabels = createTypedObject()({ - TARGET_FEATURE: new TargetLabel({ +var targetLabels = createTypedObject(TargetLabel)({ + TARGET_FEATURE: { description: "This PR is targeted for a feature branch (outside of main and semver branches)", name: "target: feature" - }), - TARGET_LTS: new TargetLabel({ + }, + TARGET_LTS: { description: "This PR is targeting a version currently in long-term support", name: "target: lts" - }), - TARGET_MAJOR: new TargetLabel({ + }, + TARGET_MAJOR: { description: "This PR is targeted for the next major release", name: "target: major" - }), - TARGET_MINOR: new TargetLabel({ + }, + TARGET_MINOR: { description: "This PR is targeted for the next minor release", name: "target: minor" - }), - TARGET_PATCH: new TargetLabel({ + }, + TARGET_PATCH: { description: "This PR is targeted for the next patch release", name: "target: patch" - }), - TARGET_RC: new TargetLabel({ + }, + TARGET_RC: { description: "This PR is targeted for the next release-candidate", name: "target: rc" - }) + } }); // -var priorityLabels = createTypedObject()({ +var PriorityLabel = class extends Label { +}; +var priorityLabels = createTypedObject(PriorityLabel)({ P0: { name: "P0", description: "Issue that causes an outage, breakage, or major function to be unusable, with no known workarounds" @@ -43541,7 +43577,9 @@ var priorityLabels = createTypedObject()({ }); // -var featureLabels = createTypedObject()({ +var FeatureLabel = class extends Label { +}; +var featureLabels = createTypedObject(FeatureLabel)({ FEATURE_IN_BACKLOG: { name: "feature: in backlog", description: "Feature request for which voting has completed and is now in the backlog" @@ -43561,7 +43599,9 @@ var featureLabels = createTypedObject()({ }); // -var requiresLabels = createTypedObject()({ +var RequiresLabel = class extends Label { +}; +var requiresLabels = createTypedObject(RequiresLabel)({ REQUIRES_TGP: { name: "requires: TGP", description: "This PR requires a passing TGP before merging is allowed" @@ -45884,7 +45924,10 @@ var CommitMessageBasedLabelManager = class { async run() { await this.initialize(); core.info(`PR #${import_github2.context.issue.number}`); - for (const { commitCheck, name } of Object.values(managedLabels)) { + for (const { commitCheck, name, repositories } of Object.values(managedLabels)) { + if (!repositories.includes(import_github2.context.repo.repo)) { + continue; + } const hasCommit = this.commits.some(commitCheck); const hasLabel = this.labels.has(name); core.info(`${name} | hasLabel: ${hasLabel} | hasCommit: ${hasCommit}`); diff --git a/github-actions/unified-status-check/main.js b/github-actions/unified-status-check/main.js index 68c70f5a6..d7324b469 100644 --- a/github-actions/unified-status-check/main.js +++ b/github-actions/unified-status-check/main.js @@ -45695,17 +45695,44 @@ var checkOnlyPassingStatuses = ({ statuses }) => { }; // -var createTypedObject = () => (v) => v; +var createTypedObject = (LabelConstructor) => { + return (val) => { + for (const key in val) { + val[key] = new LabelConstructor(val[key]); + } + return val; + }; +}; var Label = class { - constructor({ name, description, color }) { - this.name = name; - this.description = description; - this.color = color; + constructor(params2) { + this.params = params2; + this.repositories = this.params.repositories || [ + ManagedRepositories.ANGULAR, + ManagedRepositories.ANGULAR_CLI, + ManagedRepositories.COMPONENTS, + ManagedRepositories.DEV_INFRA + ]; + this.name = this.params.name; + this.description = this.params.description; + this.color = this.params.color; } }; +var ManagedRepositories; +(function(ManagedRepositories2) { + ManagedRepositories2["COMPONENTS"] = "components"; + ManagedRepositories2["ANGULAR"] = "angular"; + ManagedRepositories2["ANGULAR_CLI"] = "angular-cli"; + ManagedRepositories2["DEV_INFRA"] = "dev-infra"; +})(ManagedRepositories || (ManagedRepositories = {})); // -var managedLabels = createTypedObject()({ +var ManagedLabel = class extends Label { + constructor() { + super(...arguments); + this.commitCheck = this.params.commitCheck; + } +}; +var managedLabels = createTypedObject(ManagedLabel)({ DETECTED_BREAKING_CHANGE: { description: "PR contains a commit with a breaking change", name: "detected: breaking change", @@ -45726,16 +45753,6 @@ var managedLabels = createTypedObject()({ name: "area: docs", commitCheck: (c) => c.type === "docs" }, - DETECTED_COMPILER_CHANGE: { - description: "Issues related to `ngc`, Angular's template compiler", - name: "area: compiler", - commitCheck: (c) => c.type === "compiler" || c.type === "compiler-cli" - }, - DETECTED_PLATFORM_BROWSER_CHANGE: { - description: "Issues related to the framework runtime", - name: "area: core", - commitCheck: (c) => c.type === "platform-browser" || c.type === "core" - }, DETECTED_INFRA_CHANGE: { description: "Related the build and CI infrastructure of the project", name: "area: build & ci", @@ -45747,14 +45764,29 @@ var managedLabels = createTypedObject()({ commitCheck: (c) => c.type === "perf" }, DETECTED_HTTP_CHANGE: { - description: "", + description: "Issues related to HTTP and HTTP Client", name: "area: common/http", - commitCheck: (c) => c.type === "common/http" || c.type === "http" + commitCheck: (c) => c.type === "common/http" || c.type === "http", + repositories: [ManagedRepositories.ANGULAR] + }, + DETECTED_COMPILER_CHANGE: { + description: "Issues related to `ngc`, Angular's template compiler", + name: "area: compiler", + commitCheck: (c) => c.type === "compiler" || c.type === "compiler-cli", + repositories: [ManagedRepositories.ANGULAR] + }, + DETECTED_PLATFORM_BROWSER_CHANGE: { + description: "Issues related to the framework runtime", + name: "area: core", + commitCheck: (c) => c.type === "platform-browser" || c.type === "core", + repositories: [ManagedRepositories.ANGULAR] } }); // -var actionLabels = createTypedObject()({ +var ActionLabel = class extends Label { +}; +var actionLabels = createTypedObject(ActionLabel)({ ACTION_MERGE: { description: "The PR is ready for merge by the caretaker", name: "action: merge" @@ -45778,7 +45810,9 @@ var actionLabels = createTypedObject()({ }); // -var mergeLabels = createTypedObject()({ +var MergeLabel = class extends Label { +}; +var mergeLabels = createTypedObject(MergeLabel)({ MERGE_PRESERVE_COMMITS: { description: "When the PR is merged, a rebase and merge should be performed", name: "merge: preserve commits" @@ -45804,35 +45838,37 @@ var TargetLabel = class extends Label { this.__hasTargetLabelMarker__ = true; } }; -var targetLabels = createTypedObject()({ - TARGET_FEATURE: new TargetLabel({ +var targetLabels = createTypedObject(TargetLabel)({ + TARGET_FEATURE: { description: "This PR is targeted for a feature branch (outside of main and semver branches)", name: "target: feature" - }), - TARGET_LTS: new TargetLabel({ + }, + TARGET_LTS: { description: "This PR is targeting a version currently in long-term support", name: "target: lts" - }), - TARGET_MAJOR: new TargetLabel({ + }, + TARGET_MAJOR: { description: "This PR is targeted for the next major release", name: "target: major" - }), - TARGET_MINOR: new TargetLabel({ + }, + TARGET_MINOR: { description: "This PR is targeted for the next minor release", name: "target: minor" - }), - TARGET_PATCH: new TargetLabel({ + }, + TARGET_PATCH: { description: "This PR is targeted for the next patch release", name: "target: patch" - }), - TARGET_RC: new TargetLabel({ + }, + TARGET_RC: { description: "This PR is targeted for the next release-candidate", name: "target: rc" - }) + } }); // -var priorityLabels = createTypedObject()({ +var PriorityLabel = class extends Label { +}; +var priorityLabels = createTypedObject(PriorityLabel)({ P0: { name: "P0", description: "Issue that causes an outage, breakage, or major function to be unusable, with no known workarounds" @@ -45860,7 +45896,9 @@ var priorityLabels = createTypedObject()({ }); // -var featureLabels = createTypedObject()({ +var FeatureLabel = class extends Label { +}; +var featureLabels = createTypedObject(FeatureLabel)({ FEATURE_IN_BACKLOG: { name: "feature: in backlog", description: "Feature request for which voting has completed and is now in the backlog" @@ -45880,7 +45918,9 @@ var featureLabels = createTypedObject()({ }); // -var requiresLabels = createTypedObject()({ +var RequiresLabel = class extends Label { +}; +var requiresLabels = createTypedObject(RequiresLabel)({ REQUIRES_TGP: { name: "requires: TGP", description: "This PR requires a passing TGP before merging is allowed" diff --git a/ng-dev/pr/common/labels/action.ts b/ng-dev/pr/common/labels/action.ts index 52a8be798..4d61a5702 100644 --- a/ng-dev/pr/common/labels/action.ts +++ b/ng-dev/pr/common/labels/action.ts @@ -1,8 +1,8 @@ import {createTypedObject, Label} from './base.js'; -interface ActionLabel extends Label {} +class ActionLabel extends Label {} -export const actionLabels = createTypedObject()({ +export const actionLabels = createTypedObject(ActionLabel)({ ACTION_MERGE: { description: 'The PR is ready for merge by the caretaker', name: 'action: merge', diff --git a/ng-dev/pr/common/labels/base.ts b/ng-dev/pr/common/labels/base.ts index 1e3bf21cb..e1cc78667 100644 --- a/ng-dev/pr/common/labels/base.ts +++ b/ng-dev/pr/common/labels/base.ts @@ -1,7 +1,11 @@ -export const createTypedObject = - () => - >(v: O) => - v; +export const createTypedObject = any>(LabelConstructor: T) => { + return (val: Record[0]>) => { + for (const key in val) { + val[key] = new LabelConstructor(val[key]); + } + return val as unknown as Record>; + }; +}; export interface LabelParams { /* The label string. */ @@ -10,19 +14,31 @@ export interface LabelParams { description: string; /* The hexadecimal color code for the label, without the leading */ color?: string; + /** The repositories the label is to be used in. */ + repositories?: ManagedRepositories[]; } -export class Label { +export class Label { + /** The repositories the label is to be used in. */ + repositories = this.params.repositories || [ + ManagedRepositories.ANGULAR, + ManagedRepositories.ANGULAR_CLI, + ManagedRepositories.COMPONENTS, + ManagedRepositories.DEV_INFRA, + ]; /* The label string. */ - name: string; + name = this.params.name; /* The label description. */ - description: string; + description = this.params.description; /* The hexadecimal color code for the label, without the leading */ - color?: string; + color = this.params.color; + + constructor(public readonly params: T) {} +} - constructor({name, description, color}: LabelParams) { - this.name = name; - this.description = description; - this.color = color; - } +export enum ManagedRepositories { + COMPONENTS = 'components', + ANGULAR = 'angular', + ANGULAR_CLI = 'angular-cli', + DEV_INFRA = 'dev-infra', } diff --git a/ng-dev/pr/common/labels/feature.ts b/ng-dev/pr/common/labels/feature.ts index 5359690b6..0059994eb 100644 --- a/ng-dev/pr/common/labels/feature.ts +++ b/ng-dev/pr/common/labels/feature.ts @@ -1,8 +1,8 @@ import {createTypedObject, Label} from './base.js'; -interface FeatureLabel extends Label {} +class FeatureLabel extends Label {} -export const featureLabels = createTypedObject()({ +export const featureLabels = createTypedObject(FeatureLabel)({ FEATURE_IN_BACKLOG: { name: 'feature: in backlog', description: 'Feature request for which voting has completed and is now in the backlog', diff --git a/ng-dev/pr/common/labels/index.ts b/ng-dev/pr/common/labels/index.ts index aee838240..d2856619d 100644 --- a/ng-dev/pr/common/labels/index.ts +++ b/ng-dev/pr/common/labels/index.ts @@ -5,7 +5,7 @@ import {targetLabels} from './target.js'; import {priorityLabels} from './priority.js'; import {featureLabels} from './feature.js'; import {requiresLabels} from './requires.js'; -import {Label} from './base.js'; +import {Label, LabelParams} from './base.js'; export const allLabels = { ...managedLabels, @@ -18,7 +18,7 @@ export const allLabels = { }; // Ensures that all labels in `allLabels` properly implement `Label`. -const _typeCheckEnforceAllLabels: Record = allLabels; +const _typeCheckEnforceAllLabels: Record> = allLabels; export {managedLabels, actionLabels, mergeLabels, targetLabels, priorityLabels, requiresLabels}; export {Label}; diff --git a/ng-dev/pr/common/labels/managed.ts b/ng-dev/pr/common/labels/managed.ts index 126b8594d..5c9f8e6ce 100644 --- a/ng-dev/pr/common/labels/managed.ts +++ b/ng-dev/pr/common/labels/managed.ts @@ -1,12 +1,17 @@ import {Commit} from '../../../commit-message/parse.js'; -import {createTypedObject, Label} from './base.js'; +import {createTypedObject, Label, LabelParams, ManagedRepositories} from './base.js'; -interface ManagedLabel extends Label { +export interface ManageLabelParams extends LabelParams { /** A matching function, if the label is automatically applied by our github action, otherwise false. */ - commitCheck: ((c: Commit) => boolean) | false; + commitCheck: (c: Commit) => boolean; } -export const managedLabels = createTypedObject()({ +class ManagedLabel extends Label { + /** A matching function, if the label is automatically applied by our github action, otherwise false. */ + commitCheck: (c: Commit) => boolean = this.params.commitCheck; +} + +export const managedLabels = createTypedObject(ManagedLabel)({ DETECTED_BREAKING_CHANGE: { description: 'PR contains a commit with a breaking change', name: 'detected: breaking change', @@ -27,16 +32,6 @@ export const managedLabels = createTypedObject()({ name: 'area: docs', commitCheck: (c: Commit) => c.type === 'docs', }, - DETECTED_COMPILER_CHANGE: { - description: "Issues related to `ngc`, Angular's template compiler", - name: 'area: compiler', - commitCheck: (c: Commit) => c.type === 'compiler' || c.type === 'compiler-cli', - }, - DETECTED_PLATFORM_BROWSER_CHANGE: { - description: 'Issues related to the framework runtime', - name: 'area: core', - commitCheck: (c: Commit) => c.type === 'platform-browser' || c.type === 'core', - }, DETECTED_INFRA_CHANGE: { description: 'Related the build and CI infrastructure of the project', name: 'area: build & ci', @@ -47,9 +42,24 @@ export const managedLabels = createTypedObject()({ name: 'area: performance', commitCheck: (c: Commit) => c.type === 'perf', }, + + // angular/angular specific labels. DETECTED_HTTP_CHANGE: { - description: '', + description: 'Issues related to HTTP and HTTP Client', name: 'area: common/http', commitCheck: (c: Commit) => c.type === 'common/http' || c.type === 'http', + repositories: [ManagedRepositories.ANGULAR], + }, + DETECTED_COMPILER_CHANGE: { + description: "Issues related to `ngc`, Angular's template compiler", + name: 'area: compiler', + commitCheck: (c: Commit) => c.type === 'compiler' || c.type === 'compiler-cli', + repositories: [ManagedRepositories.ANGULAR], + }, + DETECTED_PLATFORM_BROWSER_CHANGE: { + description: 'Issues related to the framework runtime', + name: 'area: core', + commitCheck: (c: Commit) => c.type === 'platform-browser' || c.type === 'core', + repositories: [ManagedRepositories.ANGULAR], }, }); diff --git a/ng-dev/pr/common/labels/merge.ts b/ng-dev/pr/common/labels/merge.ts index 4491e0530..ffdd5ffff 100644 --- a/ng-dev/pr/common/labels/merge.ts +++ b/ng-dev/pr/common/labels/merge.ts @@ -1,8 +1,8 @@ import {createTypedObject, Label} from './base.js'; -interface MergeLabel extends Label {} +class MergeLabel extends Label {} -export const mergeLabels = createTypedObject()({ +export const mergeLabels = createTypedObject(MergeLabel)({ MERGE_PRESERVE_COMMITS: { description: 'When the PR is merged, a rebase and merge should be performed', name: 'merge: preserve commits', diff --git a/ng-dev/pr/common/labels/misc.ts b/ng-dev/pr/common/labels/misc.ts index f7b54e5fe..98fa64f2e 100644 --- a/ng-dev/pr/common/labels/misc.ts +++ b/ng-dev/pr/common/labels/misc.ts @@ -1,8 +1,8 @@ import {createTypedObject, Label} from './base.js'; -interface MiscLabel extends Label {} +class MiscLabel extends Label {} -export const miscLabels = createTypedObject()({ +export const miscLabels = createTypedObject(MiscLabel)({ FEATURE: { name: 'feature', description: 'Label used to distinguish feature request from other issues', diff --git a/ng-dev/pr/common/labels/needs.ts b/ng-dev/pr/common/labels/needs.ts index e9805dd7a..51f15c223 100644 --- a/ng-dev/pr/common/labels/needs.ts +++ b/ng-dev/pr/common/labels/needs.ts @@ -1,8 +1,8 @@ import {createTypedObject, Label} from './base.js'; -interface NeedsLabel extends Label {} +class NeedsLabel extends Label {} -export const needsLabels = createTypedObject()({ +export const needsLabels = createTypedObject(NeedsLabel)({ NEEDS_CLARIFICATION: { name: 'needs: clarification', description: diff --git a/ng-dev/pr/common/labels/priority.ts b/ng-dev/pr/common/labels/priority.ts index 0189e32fc..9d300c2d5 100644 --- a/ng-dev/pr/common/labels/priority.ts +++ b/ng-dev/pr/common/labels/priority.ts @@ -1,8 +1,8 @@ import {createTypedObject, Label} from './base.js'; -interface PriorityLabel extends Label {} +class PriorityLabel extends Label {} -export const priorityLabels = createTypedObject()({ +export const priorityLabels = createTypedObject(PriorityLabel)({ P0: { name: 'P0', description: diff --git a/ng-dev/pr/common/labels/requires.ts b/ng-dev/pr/common/labels/requires.ts index 75ea729ed..8f062b132 100644 --- a/ng-dev/pr/common/labels/requires.ts +++ b/ng-dev/pr/common/labels/requires.ts @@ -1,8 +1,8 @@ import {createTypedObject, Label} from './base.js'; -interface RequiresLabel extends Label {} +class RequiresLabel extends Label {} -export const requiresLabels = createTypedObject()({ +export const requiresLabels = createTypedObject(RequiresLabel)({ REQUIRES_TGP: { name: 'requires: TGP', description: 'This PR requires a passing TGP before merging is allowed', diff --git a/ng-dev/pr/common/labels/target.ts b/ng-dev/pr/common/labels/target.ts index ba4450807..39f5371f6 100644 --- a/ng-dev/pr/common/labels/target.ts +++ b/ng-dev/pr/common/labels/target.ts @@ -12,29 +12,29 @@ export class TargetLabel extends Label { * More details can be found here: * https://docs.google.com/document/d/197kVillDwx-RZtSVOBtPb4BBIAw0E9RT3q3v6DZkykU#heading=h.lkuypj38h15d */ -export const targetLabels = createTypedObject()({ - TARGET_FEATURE: new TargetLabel({ +export const targetLabels = createTypedObject(TargetLabel)({ + TARGET_FEATURE: { description: 'This PR is targeted for a feature branch (outside of main and semver branches)', name: 'target: feature', - }), - TARGET_LTS: new TargetLabel({ + }, + TARGET_LTS: { description: 'This PR is targeting a version currently in long-term support', name: 'target: lts', - }), - TARGET_MAJOR: new TargetLabel({ + }, + TARGET_MAJOR: { description: 'This PR is targeted for the next major release', name: 'target: major', - }), - TARGET_MINOR: new TargetLabel({ + }, + TARGET_MINOR: { description: 'This PR is targeted for the next minor release', name: 'target: minor', - }), - TARGET_PATCH: new TargetLabel({ + }, + TARGET_PATCH: { description: 'This PR is targeted for the next patch release', name: 'target: patch', - }), - TARGET_RC: new TargetLabel({ + }, + TARGET_RC: { description: 'This PR is targeted for the next release-candidate', name: 'target: rc', - }), + }, });