intuit / intuit/auto

Release comment and `released` label are added to the PR even when --dry-run flag is passed

Open
#2,516 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2.5k
Forks
221
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

When running the `auto shipit` command with the `-d` (alias for `--dry-run`), I noticed that the `released` label and the released comment are still being added PRs.

The root cause seems to be how the independent lerna versioning is handled in the `makeRelease` auto hook when the `--dry-run` flag is passed.

Here is the breakdown of what's going on:
1. In case of a fixed lerna version (for example,  `"version": "11.2.1"`) the `makeRelease` hook implicitly [returns](https://github.com/intuit/auto/blob/e135ec962b4b6911e53d4f25a407626ce17a86a6/plugins/npm/src/index.ts#L1614) `undefined`.
2. In case of an [independent lerna version](https://github.com/intuit/auto/blob/e135ec962b4b6911e53d4f25a407626ce17a86a6/plugins/npm/src/index.ts#L1523) (`"version": "independent"`) and when the [--dry-run flag](https://github.com/intuit/auto/blob/e135ec962b4b6911e53d4f25a407626ce17a86a6/plugins/npm/src/index.ts#L1535) is passed, the hook [returns an empty array](https://github.com/intuit/auto/blob/e135ec962b4b6911e53d4f25a407626ce17a86a6/plugins/npm/src/index.ts#L1554).
3. [Release information](https://github.com/intuit/auto/blob/c214a53c4a1f93860863bfc8404d4fed787fdbc9/packages/core/src/auto.ts#L2071) is retrieved.
4. In case of a fixed lerna version, the `release` variable is `undefined` [resulting](https://github.com/intuit/auto/blob/c214a53c4a1f93860863bfc8404d4fed787fdbc9/packages/core/src/auto.ts#L2082) in not invoking the `afterRelease` hook, hence no issue in this case.
5. In case of an independent lerna version and when the `--dry-run` flag is passed, the `release` variable is an empty array. This results in invoking the `afterRelease` hook.
1. The [afterRelease hook](https://github.com/intuit/auto/blob/a00c3d9f8ca1c0fc54e5f5bed20c7d5bfbcf7c29/plugins/released/src/index.ts#L83) is then processed in the `released`  plugin.
2. Through the `addReleased -> addCommentAndLabel` call chain originating from `afterRelease` hook we end up with a [comment](https://github.com/intuit/auto/blob/a00c3d9f8ca1c0fc54e5f5bed20c7d5bfbcf7c29/plugins/released/src/index.ts#L229) on the PR and the `released` [label](https://github.com/intuit/auto/blob/a00c3d9f8ca1c0fc54e5f5bed20c7d5bfbcf7c29/plugins/released/src/index.ts#L239) added to the PR, which is exactly what we observe.

**To Reproduce**

Run `npx auto shipit -d` in a repository with independent lerna versioning.

**Expected behavior**

The released PR comment and label are not added to the PR.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.