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

fix(homebrew): handle new github archive url format #29138

Merged
merged 9 commits into from
May 20, 2024

Conversation

nikaro
Copy link
Contributor

@nikaro nikaro commented May 17, 2024

Changes

This change fix the GitHub archive tag URL path parsing for Hombrew manager.

Context

Old archive urls were in form: https://github.com/<owner>/<repo>/archive/<tag>.tar.gz
New ones are in form: https://github.com/<owner>/<repo>/archive/refs/tags/<tag>.tar.gz

So with the current parsing currentValue ends up being filled with the refs string instead of the tag value.

Also, brew style command complains about the old url format, cf.: https://github.com/nikaro/homebrew-tap/actions/runs/9131845923/job/25111949942#step:7:15

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@nikaro nikaro force-pushed the fix/homebrew-url-path-parsing branch from 052904f to 2874c02 Compare May 17, 2024 20:47
@rarkins rarkins enabled auto-merge May 17, 2024 20:53
auto-merge was automatically disabled May 17, 2024 22:10

Head branch was pushed to by a user without write access

@nikaro nikaro force-pushed the fix/homebrew-url-path-parsing branch from 2874c02 to 7dcbb4a Compare May 17, 2024 22:10
@nikaro
Copy link
Contributor Author

nikaro commented May 17, 2024

@rarkins i modified some forgotten urls in tests and force pushed.

@nikaro nikaro force-pushed the fix/homebrew-url-path-parsing branch from 7dcbb4a to e1e65af Compare May 17, 2024 22:12
rarkins
rarkins previously approved these changes May 18, 2024
@rarkins rarkins enabled auto-merge May 18, 2024 04:37
@nikaro
Copy link
Contributor Author

nikaro commented May 18, 2024

Ah my bad, i didn't saw about these snapshots things.

Old archive urls were in form: https://github.com/<owner/<repo>/archive/<tag>.tar.gz
New ones are in form: https://github.com/<owner/<repo>/archive/refs/tags/<tag>.tar.gz

So with the current parsing `currentValue` ends up being filled with
the `refs` string instead of the tag value.

This change handles both forms by checking the length of the url paths
slice.
auto-merge was automatically disabled May 18, 2024 07:22

Head branch was pushed to by a user without write access

@nikaro nikaro force-pushed the fix/homebrew-url-path-parsing branch from e1e65af to f4e53df Compare May 18, 2024 07:22
@nikaro
Copy link
Contributor Author

nikaro commented May 18, 2024

This time it should be good, i ran the manager/homebrew tests locally:

➤ pnpm jest manager/homebrew

> renovate@0.0.0-semantic-release jest /Users/nicolas/Developer/github.com/renovatebot/renovate
> GIT_ALLOW_PROTOCOL=file LOG_LEVEL=fatal node --experimental-vm-modules node_modules/jest/bin/jest.js --logHeapUsage "manager/homebrew"

Host stats:
    Cpus:      8
    Memory:    8.00 GB
    HeapLimit: 2.05 GB
 PASS  lib/modules/manager/homebrew/util.spec.ts (61 MB heap size)
 PASS  lib/modules/manager/homebrew/extract.spec.ts (88 MB heap size)
 PASS  lib/modules/manager/homebrew/update.spec.ts (84 MB heap size)

=============================== Coverage summary ===============================
Statements   : 2.45% ( 1021/41618 )
Branches     : 0.94% ( 125/13171 )
Functions    : 0.9% ( 47/5203 )
Lines        : 2.44% ( 1005/41032 )
================================================================================

Test Suites: 3 passed, 3 total
Tests:       25 passed, 25 total
Snapshots:   14 passed, 14 total
Time:        5.981 s
Ran all test suites matching /manager\/homebrew/i.

Sorry for the inconvenience.

rarkins
rarkins previously approved these changes May 18, 2024
@rarkins rarkins enabled auto-merge May 18, 2024 15:28
@nikaro
Copy link
Contributor Author

nikaro commented May 19, 2024

I may need some help here, or someone taking over the PR. As i don't really know what to do to fix the coverage decrease. Is it just a matter of adding a case in the extract.spec.ts file? I'm not really familiar with TypeScript and even less with the tooling around (Jest or whatever).

Or maybe to keep things simple i can remove the handling of old URLs format, what do you think?

auto-merge was automatically disabled May 19, 2024 14:03

Head branch was pushed to by a user without write access

@rarkins
Copy link
Collaborator

rarkins commented May 19, 2024

I'd prefer to keep it, unless we know that no GitHub instance (including self hosted) that anyone uses ever generates the old style any more.

Most likely it's 1-2 additional test cases. Maybe one which was changed can be reverted to the old format.

@nikaro
Copy link
Contributor Author

nikaro commented May 19, 2024

I added a test case, "handles old "archive" github url format", i hope that's enough.

@rarkins
Copy link
Collaborator

rarkins commented May 19, 2024

There is update coverage missed: https://app.codecov.io/gh/renovatebot/renovate/pull/29138/blob/lib/modules/manager/homebrew/update.ts#L195

image

If this is not new code then it implies that it used to be reachable via a test, so again my advice would be to locate that test and duplicate it instead of replace it fully

@nikaro nikaro requested a review from rarkins May 19, 2024 15:43
@nikaro
Copy link
Contributor Author

nikaro commented May 20, 2024

I've simplified the way how i check for the new URL format, i guess the "issue" had to do with the null return for unhandled "archive" URLs. This should pass now. The tests and code coverage are good locally.

@rarkins rarkins added this pull request to the merge queue May 20, 2024
const res = extractPackageFile(content);
expect(res).not.toBeNull();
expect(res?.deps[0].skipReason).toBeUndefined();
expect(res).toMatchSnapshot();
Copy link
Member

Choose a reason for hiding this comment

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

no new snapshots 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is the GitHub diff that is a bit messed up.

The "handles old "archive" github url format" has the same content than the old "handles no space before class header" one (with the old URL format). So there is a "new" snapshot.

Merged via the queue into renovatebot:main with commit e035f05 May 20, 2024
37 checks passed
@nikaro nikaro deleted the fix/homebrew-url-path-parsing branch May 20, 2024 08:43
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 37.368.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

4 participants