Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Adding new versioning strategies #1744

Merged
merged 9 commits into from Nov 11, 2022

Conversation

ddixit14
Copy link
Contributor

@ddixit14 ddixit14 commented Nov 8, 2022

This PR adds two new versioning strategies:

  • always-bump-minor : This VersioningStrategy always bumps the minor version
  • always-bump-major: This VersioningStrategy always bumps the major version

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Nov 8, 2022
@ddixit14
Copy link
Contributor Author

ddixit14 commented Nov 8, 2022

Tested it locally on a google-cloud-java fork.
For always-bump-major, this is the major-bump-pr created.
For always-bump-minor, this is the minor-bump-pr created.

@ddixit14
Copy link
Contributor Author

ddixit14 commented Nov 8, 2022

@chingor13 Need some insights to write new tests/make the tests pass.

image

@suztomo
Copy link
Member

suztomo commented Nov 8, 2022

For the new strategy, follow the test cases already written for "always-bump-patch". (I hope the tests are there). Found:

~/release-please/test $ vim ./versioning-strategies/java.ts
...
  describe('with AlwaysBumpPatch', () => {
    describe('with breaking change', () => {
      it('can bump a major', async () => {
        const strategy = new JavaSnapshot(new AlwaysBumpPatch({}));
        const oldVersion = Version.parse('1.2.3-SNAPSHOT');
        const newVersion = await strategy.bump(oldVersion, breakingCommits);
        expect(newVersion.toString()).to.equal('1.2.3');
      });

      it('can bump a major on pre major for breaking change', async () => {
        const strategy = new JavaSnapshot(new AlwaysBumpPatch({}));
        const oldVersion = Version.parse('0.1.2-SNAPSHOT');
        const newVersion = await strategy.bump(oldVersion, breakingCommits);
        expect(newVersion.toString()).to.equal('0.1.2');
      });

      it('can bump a minor pre major for breaking change', async () => {
        const strategy = new JavaSnapshot(
          new AlwaysBumpPatch({bumpMinorPreMajor: true})
        );
        const oldVersion = Version.parse('0.1.2-SNAPSHOT');
        const newVersion = await strategy.bump(oldVersion, breakingCommits);
        expect(newVersion.toString()).to.equal('0.1.2');
      });
    });

test/cli.js is untouched. Flaky tests? Needs help from Jeff.

@ddixit14 ddixit14 marked this pull request as ready for review November 8, 2022 21:54
@ddixit14 ddixit14 requested a review from a team as a code owner November 8, 2022 21:54
@ddixit14 ddixit14 requested a review from a team November 8, 2022 21:54
@chingor13
Copy link
Contributor

Need some insights to write new tests/make the tests pass.

We use a snapshot of the CLI --help output to test the CLI help feature. Try running npm run test:snap which should rewrite the test snapshots.

@suztomo
Copy link
Member

suztomo commented Nov 9, 2022

@ddixit14 Do you plan to add a test case in versioning-strategies/java.ts ?

Copy link
Contributor

@chingor13 chingor13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please add unit tests for the new versioning strategies even though they seem trivial.

Otherwise, LGTM.

@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Nov 11, 2022
@chingor13 chingor13 merged commit 7526ca8 into googleapis:main Nov 11, 2022
import {AlwaysBumpMinor} from '../../src/versioning-strategies/always-bump-minor';
import {Version} from '../../src/version';

describe('MinorVersioningStrategy', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nit, this should be AlwaysBumpMinorStrategy, my bad because I copy pasted this.

chingor13 added a commit to googleapis/repo-automation-bots that referenced this pull request Nov 28, 2023
…rategies in schema (#5262)

Adding "always-bump-minor" and "always-bump-major" to the allowed values
for versioning.
Reference PR: googleapis/release-please#1744

Co-authored-by: Jeff Ching <chingor@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants