Auto: Label creation adds unwanted default labels

Created on 22 Apr 2021  ·  15Comments  ·  Source: intuit/auto

Describe the bug
When I run npx auto create-labels and have a given label configuration defined in my package.json, I would expect that only those labels get created, NOT the additional default labels defined by auto. This used to be the case but somewhere along the line stopped working correctly.

To Reproduce

Using the following configuration:

"auto": {
    "baseBranch": "master",
    "prereleaseBranches": [
      "next"
    ],
    "plugins": [
      [
        "npm",
        {
          "legacyAuth": true,
          "setRcToken": false
        }
      ],
      "released",
      "microsoft-teams"
    ],
    "shipit": {
      "noChangelog": true
    },
    "labels": [
      {
        "name": "breaking",
        "changelogTitle": "🚨  Breaking Changes",
        "description": "Backwards incompatible enhancement or feature.",
        "releaseType": "major",
        "color": "#c5000b"
      },
      {
        "name": "feature",
        "changelogTitle": "🚀  Features",
        "description": "A new feature.",
        "releaseType": "minor",
        "color": "#00ff00"
      },
      {
        "name": "build",
        "changelogTitle": "📦  Build Process",
        "description": "Changes to the build process.",
        "releaseType": "patch",
        "color": "#4a4a4a"
      },
      {
        "name": "chore",
        "changelogTitle": "🏗  Miscellaneous",
        "description": "Additional, uncategorized changes.",
        "releaseType": "patch",
        "color": "#ff00ff",
        "default": true
      },
      {
        "name": "ci",
        "changelogTitle": "🔖  Continuous Integration",
        "description": "Changes to CI configuration files and scripts.",
        "releaseType": "patch",
        "color": "#f1a60e"
      },
      {
        "name": "docs",
        "changelogTitle": "📖  Documentation",
        "description": "Documentation updates and changes.",
        "releaseType": "patch",
        "color": "#870048"
      },
      {
        "name": "fix",
        "changelogTitle": "🐛  Bug Fixes",
        "description": "A bug fix.",
        "releaseType": "patch",
        "color": "#6000ff"
      },
      {
        "name": "perf",
        "changelogTitle": "⚡️  Performance",
        "description": "A code change that improves performance.",
        "releaseType": "patch",
        "color": "#00e4ff"
      },
      {
        "name": "refactor",
        "changelogTitle": "♻️  Refactoring",
        "description": "A code change that neither fixes a bug nor adds a feature.",
        "releaseType": "patch",
        "color": "#00b58d"
      },
      {
        "name": "revert",
        "changelogTitle": "🚧  Reverting",
        "description": "Reverts a previous commit.",
        "releaseType": "patch",
        "color": "#ff9000"
      },
      {
        "name": "style",
        "changelogTitle": "🎨  Style",
        "description": "Code style (white-space, formatting, missing semi-colons, etc).",
        "releaseType": "patch",
        "color": "#0051d8"
      },
      {
        "name": "test",
        "changelogTitle": "✅  Testing",
        "description": "Adding missing tests or correcting existing tests.",
        "releaseType": "patch",
        "color": "#127f00"
      },
      {
        "name": "upgrade",
        "changelogTitle": "⚙️  Dependencies",
        "description": "Dependency upgrades.",
        "releaseType": "minor",
        "color": "#00787f"
      }
    ]
  }

This is the output:

Created labels: breaking, feature, build, chore, ci, docs, fix, perf, refactor, revert, style, test, upgrade, major, minor, patch, skip-release, internal, documentation, tests, dependencies, performance, released, prerelease

Expected behavior

Only the labels outlined in the above config would be created. Anything after the upgrade label in the above output list is unwanted and should not be created.

Screenshots

Environment information:

Environment Information:

"auto" version: v10.25.1
"git"  version: v2.29.2
"node" version: v12.13.0

✔ Labels configured on GitHub project

Additional context

bug released

Most helpful comment

@reintroducing I like that option a lot! Default can be only create specified labels. New flag to include the others and use the overwrite logic. This would be a breaking change to behavior though. What about the opposite --no-include-defaults?

All 15 comments

I was just about to file the same issue. The docs are unclear about overriding default labels. Is there a way to say that I want only those labels defined in the config and no default ones?

There is an overwrite option on the label configuration that will override the matching default label. IDK if it will work for the zon-semver labels. could you give that a try? If the docs aren't clear enough around this more than willing to accept a PR

@hipstersmoothie when looking at https://intuit.github.io/auto/docs/generated/create-labels I don't see anything of that nature. Where is the docs pertaining to this option?

@hipstersmoothie So looking at those docs, I guess I'm unclear about the functionality of that option. I would assume that if I add that to every one of my labels in my config, it would just overwrite the major, minor, and patch labels with mine, but would not clear out the others that are being created in addition to those. I think a nice addition would be to add an option to the create labels command that says include-defaults and set to true/false (true by default if you want to keep backwards compatibility). Thoughts?

I agree with @reintroducing. I knew about overwrite option, but it is only about adjusting default labels if I understand it correctly. We want an option to create _only_ the labels we configured.

@reintroducing I like that option a lot! Default can be only create specified labels. New flag to include the others and use the overwrite logic. This would be a breaking change to behavior though. What about the opposite --no-include-defaults?

@hipstersmoothie yes, sorry my explanation wasn't clear, i was suggesting the same thing you are but in reverse and it would be true by default, lol, to avoid a breaking change. yours is actually cleaner and aligns better with how all other options are done. I'm all for it!

I might not have to to get to this until the weekend. If you submit a PR I'll review and merge prompts

I made an attempt to fix it: https://github.com/intuit/auto/pull/1966, but in a bit different way. See the explanation there.


:rocket: Issue was released in v10.26.0 :rocket:

@laughedelic @hipstersmoothie @adierkens I just tried the upgrade to this and am seeing the following issue in CI where we create canaries automatically on a new PR:

Screen Shot 2021-04-29 at 2 32 48 PM

It's worth noting that the actual config is in a packages/auto/config.json file and is extended at the root of our repo using the following:

"auto": {
    "extends": "./packages/auto/config.json"
  },

This was, however, working perfectly fine prior to updating to the latest version.

Here is the full config.json file:

{
  "baseBranch": "master",
  "noDefaultLabels": true,
  "prereleaseBranches": ["next"],
  "plugins": [
    [
      "npm",
      {
        "legacyAuth": true,
        "setRcToken": false
      }
    ],
    "released",
    "microsoft-teams"
  ],
  "shipit": {
    "noChangelog": true
  },
  "labels": [
    {
      "name": "breaking",
      "changelogTitle": "🚨  Breaking Changes",
      "description": "Backwards incompatible enhancement or feature.",
      "releaseType": "major",
      "color": "#c5000b"
    },
    {
      "name": "feature",
      "changelogTitle": "🚀  Features",
      "description": "A new feature.",
      "releaseType": "minor",
      "color": "#00ff00"
    },
    {
      "name": "build",
      "changelogTitle": "📦  Build Process",
      "description": "Changes to the build process.",
      "releaseType": "patch",
      "color": "#4a4a4a"
    },
    {
      "name": "chore",
      "changelogTitle": "🏗  Miscellaneous",
      "description": "Additional, uncategorized changes.",
      "releaseType": "patch",
      "color": "#ff00ff",
      "default": true
    },
    {
      "name": "ci",
      "changelogTitle": "🔖  Continuous Integration",
      "description": "Changes to CI configuration files and scripts.",
      "releaseType": "patch",
      "color": "#f1a60e"
    },
    {
      "name": "docs",
      "changelogTitle": "📖  Documentation",
      "description": "Documentation updates and changes.",
      "releaseType": "patch",
      "color": "#870048"
    },
    {
      "name": "fix",
      "changelogTitle": "🐛  Bug Fixes",
      "description": "A bug fix.",
      "releaseType": "patch",
      "color": "#6000ff"
    },
    {
      "name": "perf",
      "changelogTitle": "⚡️  Performance",
      "description": "A code change that improves performance.",
      "releaseType": "patch",
      "color": "#00e4ff"
    },
    {
      "name": "refactor",
      "changelogTitle": "♻️  Refactoring",
      "description": "A code change that neither fixes a bug nor adds a feature.",
      "releaseType": "patch",
      "color": "#00b58d"
    },
    {
      "name": "revert",
      "changelogTitle": "🚧  Reverting",
      "description": "Reverts a previous commit.",
      "releaseType": "patch",
      "color": "#ff9000"
    },
    {
      "name": "style",
      "changelogTitle": "🎨  Style",
      "description": "Code style (white-space, formatting, missing semi-colons, etc).",
      "releaseType": "patch",
      "color": "#0051d8"
    },
    {
      "name": "test",
      "changelogTitle": "✅  Testing",
      "description": "Adding missing tests or correcting existing tests.",
      "releaseType": "patch",
      "color": "#127f00"
    },
    {
      "name": "upgrade",
      "changelogTitle": "⚙️  Dependencies",
      "description": "Dependency upgrades.",
      "releaseType": "minor",
      "color": "#00787f"
    }
  ]
}

Is it possible that the new option needs to be added to the validator and its as simple as that? https://github.com/intuit/auto/blob/main/packages/core/src/types.ts#L54

Is it possible that the new option needs to be added to the validator and its as simple as that? https://github.com/intuit/auto/blob/main/packages/core/src/types.ts#L54

This makes sense! I didn't know about it.

@reintroducing I added it here: https://github.com/intuit/auto/pull/1971. But I don't know if it should be added anywhere else.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brunobertoldi picture brunobertoldi  ·  8Comments

jdalrymple picture jdalrymple  ·  6Comments

zephraph picture zephraph  ·  10Comments

tunnckoCore picture tunnckoCore  ·  4Comments

hipstersmoothie picture hipstersmoothie  ·  13Comments