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

Add npm source #296

Merged
merged 3 commits into from
Aug 6, 2018
Merged

Add npm source #296

merged 3 commits into from
Aug 6, 2018

Conversation

bollwyvl
Copy link
Contributor

Fixes #291.

This adds a simple, yet not very widely applicable, source to, if the feedstock url is from registry.npmjs.org, make a call to registry.npmjs.org and return the dist-tag which is latest (the default). Like the PyPI source, it also will not return pre-release-y values in the name of the tag, as that also happens as the dist-tags feature is fairly buried.

Not doing prereleases might be introducing an unwelcome opinion... thoughts? Both of the major upstream tools that use the namespace, npm and yarn, ignore them, so it seems reasonable enough.

@codecov-io
Copy link

codecov-io commented Jul 27, 2018

Codecov Report

Merging #296 into master will increase coverage by 12.35%.
The diff coverage is 81.25%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #296       +/-   ##
===========================================
+ Coverage   15.92%   28.28%   +12.35%     
===========================================
  Files           6        6               
  Lines         427      442       +15     
===========================================
+ Hits           68      125       +57     
+ Misses        359      317       -42
Impacted Files Coverage Δ
conda_forge_tick/update_upstream_versions.py 27.94% <81.25%> (+27.94%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f949aca...1005b08. Read the comment docs.

name = "npm"

def get_url(self, meta_yaml):
if "registry.npmjs.org" in meta_yaml["url"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be not in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack! good catch!


def get_version(self, url):
r = requests.get(url)
latest = r.json()["dist-tags"].get("latest", "").strip()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please check r.ok before trying to get the json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

@justcalamari
Copy link
Contributor

Thanks for putting this in, @bollwyvl!

@isuruf
Copy link
Member

isuruf commented Jul 27, 2018

Instead of checking the url to have registry.npmjs.org you can check whether the meta.yaml file has - nodejs in it. meta_yaml['raw_meta_yaml'] gives the raw file

@bollwyvl
Copy link
Contributor Author

Instead of checking the url to have registry.npmjs.org you can check whether the meta.yaml file has - nodejs in it. meta_yaml['raw_meta_yaml'] gives the raw file

Hmmm... I guess the namespace thing is what trips me up from taking that approach. A separate PR could look to doing something about the github release filtering as well, but i have no data outside of a bit of looking as to which projects are aggressively using that particular ui feature... i guess if they ever used a pre-release, then you'd only want the stable releases.

@scopatz
Copy link
Contributor

scopatz commented Jul 27, 2018

Thanks for putting this in @bollwyvl! Generally LGTM

@scopatz
Copy link
Contributor

scopatz commented Jul 27, 2018

It would be nice to have tests for this, but we don't have any other tests for related classes, so I don't feel comfortable putting that burden on this PR. But it would make a nice addition 😉

@bollwyvl
Copy link
Contributor Author

bollwyvl commented Jul 27, 2018 via email

@CJ-Wright
Copy link
Member

I'm 👍 on these changes. Tests would be spectacular!

@bollwyvl
Copy link
Contributor Author

Added a simple test with requests-mock.

I kinda phoned it in on the attrs, which probably need to be fixed.


@pytest.mark.parametrize("inp, ver, source, urls", latest_url_test_list)
def test_latest_version(inp, ver, source, urls, requests_mock):
pmy = parse_meta_yaml(inp)["source"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the right way to transform the package into the thing that get_latest_version is expecting?

Copy link
Member

Choose a reason for hiding this comment

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

You could use get_attrs https://github.com/regro/cf-scripts/blob/master/conda_forge_tick/make_graph.py#L24 (although this currently pulls the meta.yaml itself from github. I guess at some point we should separate the request from the rest of it for these kinds of things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, guess I can mock that, too...

@scopatz
Copy link
Contributor

scopatz commented Aug 6, 2018

Pinging this issue. @CJ-Wright @justcalamari - should this go in as is?

@CJ-Wright
Copy link
Member

@bollwyvl thank you very much!

@CJ-Wright CJ-Wright merged commit 9b26ddd into regro:master Aug 6, 2018
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

6 participants