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

dry-run: generate ignored versions from "update-types" #3513

Merged
merged 16 commits into from
Apr 22, 2021

Conversation

thepwagner
Copy link
Contributor

@thepwagner thepwagner commented Apr 19, 2021

Continuing #3512 and #3525 , this migrates Dependabot::Config::UpdateConfig::IgnoreCondition to Dependabot::Config::IgnoreCondition, and amends the #ignored_versions() function to support dynamically ignored version ranges, as specified by #2219 (comment) .

This iteration supports the functionality via the dry-run.rb script, 🎉 . Dependabot doesn't yet recognize the syntax, but it will parse a .github/dependabot.yaml configuration file:

updates:
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "monthly"
    ignore:
      - dependency-name: "lodash"
        update-types: ["version-update:semver-major"]

Related

@thepwagner thepwagner self-assigned this Apr 19, 2021
Base automatically changed from dry-run-config-file to main April 20, 2021 14:37
@thepwagner thepwagner changed the base branch from main to update-config-poro April 20, 2021 19:08
Base automatically changed from update-config-poro to main April 21, 2021 13:13
@feelepxyz
Copy link
Contributor

feelepxyz commented Apr 21, 2021 via email

@thepwagner thepwagner changed the title experiment: generate ignored versions from "update-type" experiment: generate ignored versions from "update-types" Apr 21, 2021
@thepwagner thepwagner marked this pull request as ready for review April 21, 2021 18:10
@thepwagner thepwagner requested a review from a team as a code owner April 21, 2021 18:10
Copy link
Contributor Author

@thepwagner thepwagner left a comment

Choose a reason for hiding this comment

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

I marked RFR as this is code complete and roughly what I was going for.

As noted, the way conditions are aggregated needs some attention:

  • What if there are multiple matches with identical update-types:?
  • What if there are multiple matches with different update-types:?
  • What if there are update-types: and versions:?

This definitely isn't shippable, but is a worthy iteration.

common/lib/dependabot/config/ignore_condition.rb Outdated Show resolved Hide resolved
select { |ic| ic.dependency_name == dep.name }. # FIXME: wildcard support
map(&:versions).
select { |ic| ic.dependency_name == dependency.name }. # FIXME: wildcard support
map { |ic| ic.ignored_versions(dependency) }.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Concern: as I as alluding to in https://github.com/dependabot/dependabot-core/pull/3536/files#r617772124 , this isn't going to behave when multiple conditions match the target dependency...

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I follow, do we have a test case for this that will fail currently?

I was looking at moving the dependency name checking into the IgnoreCondition class but would mean returning an empty ignored_versions if the dependency name doesn't match the ic.dependency_name which seems confusing to me but unsure if I'm missing something else?

Copy link
Contributor

Choose a reason for hiding this comment

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

this isn't going to behave when multiple conditions match the target dependency

Is this case tested here?: https://github.com/dependabot/dependabot-core/pull/3513/files#diff-1bee1e376554d0d150b3a22f7b1ca87ac8d9de442cebf942c2f0e3f7fcc50c04R56

ignored = reqs.any? { |req| req.satisfied_by?(version) }
expect(ignored).to eq(true), "Expected #{v} to be ignored, but was allowed"
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice test helpers 👍

Copy link
Contributor

@feelepxyz feelepxyz left a comment

Choose a reason for hiding this comment

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

This is looking good! Tests are real clear and easy to follow 💯

I've been testing this on dry-runs and it's working well 🎉 Should we ship this and start incorporating in updater? Not sure if it's worth refactoring the wildcard matching as I see it possibly being more confusing having the dependency name filtering done in the individual IgnoreCondition but might have missed some edge-case that's not working.

@feelepxyz
Copy link
Contributor

  • What if there are multiple matches with identical update-types:?
  • What if there are multiple matches with different update-types:?
  • What if there are update-types: and versions:?

Tried to add some tests around this. Added a uniq on the generated version requirements but seems to work? 🤔

Copy link
Contributor

@feelepxyz feelepxyz left a comment

Choose a reason for hiding this comment

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

I've been testing a bunch of dry-runs with different ignore setups and looking good so far! 🚢

thepwagner and others added 2 commits April 22, 2021 13:06
This was a thing before the refactor - it was replaced with `try { Integer(x) } catch (ArgumentError e) {}`, to handle this case.

Co-authored-by: Philip Harrison <philip@mailharrison.com>
@thepwagner thepwagner changed the title experiment: generate ignored versions from "update-types" generate ignored versions from "update-types" Apr 22, 2021
@thepwagner thepwagner changed the title generate ignored versions from "update-types" dry-run: generate ignored versions from "update-types" Apr 22, 2021
@thepwagner thepwagner merged commit c575aee into main Apr 22, 2021
@thepwagner thepwagner deleted the relative-ignore-update-type branch April 22, 2021 18:38
This was referenced Apr 22, 2021
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 this pull request may close these issues.

None yet

3 participants