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

Ensure Docker versions are valid Dependabot::Versions #7984

Merged
merged 5 commits into from
Sep 8, 2023

Conversation

Nishnha
Copy link
Member

@Nishnha Nishnha commented Sep 7, 2023

Fixes #7938

WIP

Dependabot::Docker::Version#new would normally return an instance of a Gem::Version with an actual value, but Docker::Version#initialize failed to call #super and so it returned Gem::Version.new(nil) instead.

This PR fixes that issue in the Dependabot::Docker::Version class by actually calling #super and it also removes the overloaded #self.correct?(version) method that was present since the base method should now work correctly.

Finally, in Updater::GroupUpdateCreation we make sure to cast the version returned by the latest version finder to an actual Dependabot::Version so we can use the Dependabot::Version#segments method.

@Nishnha Nishnha requested a review from a team as a code owner September 7, 2023 18:48
@github-actions github-actions bot added the L: docker Docker containers label Sep 7, 2023
Copy link
Contributor

@yeikel yeikel left a comment

Choose a reason for hiding this comment

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

Can we add a spec that reproduces this (and proves the fix?)

@Nishnha
Copy link
Member Author

Nishnha commented Sep 8, 2023

I added a couple of tests in f0a27a1 and fcbb08a.

  • The test in f0a27a1 takes a few string versions and converts them to a Docker::Version and then checks whether they are correct (i.e. whether they are a valid Gem::Version).

  • The test in fcbb08a does the same thing but it uses version strings from a DependencySnapshot in the GroupUpdateAllVersions spec. The DependencySnapshot is for a Docker dependency with a version in the form "v2.0.20230509134123". This is the I could get to recreating the GroupUpdateCreation issue without adding a whole new test fixture.

If the test in fcbb08a isn't thorough enough I could add a new test fixture - I was able to recreated the issue in a public test repo.

I know this patch works though because I can now run the previously erroring update locally:

2023/09/08 01:55:27 INFO Raven 3.1.2 configured not to capture errors: DSN not set
2023/09/08 01:55:42 INFO Starting job processing
2023/09/08 01:55:42 INFO Starting grouped update job for dark-dependabot/docker-semver-groups
2023/09/08 01:55:42 INFO Found 1 group(s).
2023/09/08 01:55:42 INFO Starting update group for 'docker-semver-group'
2023/09/08 01:55:42 INFO Checking if kustomize/kustomize v4.5.5 needs updating
2023/09/08 01:55:43 INFO Latest version is v5.0.1
2023/09/08 01:55:43 INFO Requirements to unlock own
2023/09/08 01:55:43 INFO Requirements update strategy
2023/09/08 01:55:43 INFO Updating kustomize/kustomize from v4.5.5 to v5.0.1
2023/09/08 01:55:43 INFO Checking if alpine/helm 3.11.1 needs updating
2023/09/08 01:55:45 INFO Latest version is 3.12.3
2023/09/08 01:55:45 INFO Requirements to unlock own
2023/09/08 01:55:45 INFO Requirements update strategy
2023/09/08 01:55:45 INFO Updating alpine/helm from 3.11.1 to 3.12.3
2023/09/08 01:55:45 INFO Checking if golang 1.21.0-bullseye needs updating
2023/09/08 01:55:47 INFO Latest version is 1.21.1-bullseye
2023/09/08 01:55:47 INFO Requirements to unlock own
2023/09/08 01:55:47 INFO Requirements update strategy
2023/09/08 01:55:47 INFO Updating golang from 1.21.0-bullseye to 1.21.1-bullseye
2023/09/08 01:55:47 INFO Creating a pull request for 'docker-semver-group'
2023/09/08 01:55:48 INFO Finished job processing
2023/09/08 01:55:48 INFO Results:
+------------------------------------------------------------------------------------------------------------------------------------+
|                                                Changes to Dependabot Pull Requests                                                 |
+---------+--------------------------------------------------------------------------------------------------------------------------+
| created | kustomize/kustomize ( from v4.5.5 to v5.0.1 ), alpine/helm ( from 3.11.1 to 3.12.3 ), golang ( from 1.21.0-bullseye t... |
+---------+--------------------------------------------------------------------------------------------------------------------------+

Copy link
Member

@jurre jurre left a comment

Choose a reason for hiding this comment

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

This looks good to me 👍

@Nishnha Nishnha merged commit 85ddd74 into main Sep 8, 2023
79 checks passed
@Nishnha Nishnha deleted the nishnha/fix-docker-semver branch September 8, 2023 16:46
@yeikel
Copy link
Contributor

yeikel commented Sep 8, 2023

Thank you for adding the tests, and sorry for the delayed response

@Nishnha
Copy link
Member Author

Nishnha commented Sep 8, 2023

All good thanks for the initial review

brettfo pushed a commit to brettfo/dependabot-core that referenced this pull request Oct 11, 2023
…-semver

Ensure Docker versions are valid Dependabot::Versions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: docker Docker containers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dependabot group update doesn't work on dockerfile
3 participants