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

I'm having an issue where the action still merges a major release even if the target is set to minor. #166

Closed
simoneb opened this issue Apr 1, 2022 · 7 comments · Fixed by #167

Comments

@simoneb
Copy link
Collaborator

simoneb commented Apr 1, 2022

I'm having an issue where the action still merges a major release even if the target is set to minor.

For example, React v17.0.2 to v18.0.0 still gets merged.

    automerge:
        needs: analyze
        runs-on: ubuntu-latest
        permissions:
            pull-requests: write
            contents: write
        if: ${{ github.event_name == 'pull_request' }}
        steps:
            -   uses: fastify/github-action-merge-dependabot@v3
                with:
                    github-token: ${{ secrets.GITHUB_TOKEN }}
                    target: minor

Example PR: https://github.com/austins/smoothnanners-web/pull/17

Originally posted by @austins in #124 (comment)

@climba03003
Copy link
Member

It's always true if the title do not match regexp.

const match = expression.exec(prTitle)
if (!match) {
return true
}

@simoneb
Copy link
Collaborator Author

simoneb commented Apr 1, 2022

Ah I can see that that dependabot PR is doing something we're not expecting here! It's bumping both react and react-dom. I've never seen this case before, I guess dependabot is getting smarter. We need a different strategy here, all of the assumptions we made in the action rely on a single package being bumped

@simoneb
Copy link
Collaborator Author

simoneb commented Apr 1, 2022

@wilkmaia is looking into this

@wilkmaia
Copy link
Contributor

wilkmaia commented Apr 1, 2022

@simoneb based on what I've seen, this is kind of an expected behavior in the code right now, even if not desired.

Specifically, looking at this test we can see it was actually expected that if the PR title didn't match the target match expression (/from ([^\s]+) to ([^\s]+)/) the target option would be ignored.

Moving forward we might want to improve that specific segment. Instead of simply checking the PR title we might want to check what's actually going on in the package.json file. Maybe matching the package name(s) in the PR title with the versions in package.json.

I'll work on that change for now but if you don't think that's not a good approach we can re-think the strategy.


Edit: only now I've seen the comments above lol.

@wilkmaia
Copy link
Contributor

wilkmaia commented Apr 1, 2022

If this issue is ever implemented we might want to drop checking the PR title altogether, given the PR template they implement might involve setting the title as well.

@austins
Copy link

austins commented Apr 2, 2022

I believe there was also a case where it still approved a merge to a major release with a valid semver format, although the config was set to target minor (example PR). However, this was with fastify/[email protected].

For this case with React, yes, the title has two dependencies and dependabot isn't including the version numbers in the title. We could parse the PR message for Updates react from 17.0.2 to 18.0.0 and Updates react-dom from 17.0.2 to 18.0.0, however that may not be reliable if dependabot ever changes their template again. I would say that checking the diff in package.json would be the most consistent and reliable option.

Thanks Fastify team for looking into this!

@simoneb
Copy link
Collaborator Author

simoneb commented Apr 2, 2022

I agree that looking at the diff is probably the only reliable way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants