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

Intersection for latest Date for multiple components #9

Open
jparris opened this issue Aug 7, 2019 · 5 comments
Open

Intersection for latest Date for multiple components #9

jparris opened this issue Aug 7, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@jparris
Copy link

jparris commented Aug 7, 2019

It would be super helpful if there was a was to query when the latest build was available for multiple component e.g clippy & rustfmt. E.g.,
curl https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/clippy+rustfmt
2019-08-01

@mexus mexus added the enhancement New feature or request label Aug 8, 2019
@mexus
Copy link
Contributor

mexus commented Aug 8, 2019

I knew the day would come when somebody suggests to implement a multiple-component lookup :)

Right now it doesn't seem to be possible since the website is generated as static HTML pages and JSON files and hosted on github pages...

While it must be not that hard to use javascript to load and analyze those JSONs in a browser, I don't see how we can make curl to work without implementing the logic on the server-side.

So while it is a really useful and even somehow required feature (esp. for use in CIs), for now I can only suggest to implement it as python (bash/...) script.

Could it be that you have better ideas?

@jparris
Copy link
Author

jparris commented Aug 9, 2019

Okay so last night I wiped up a python3 script that gets the job done; the filtering isn't the cleanest and it could use some error handling but it works for me and i hope it will be useful to others.

Example run

$ ./rustup_component_intersection.py x86_64-unknown-linux-gnu rustfmt clippy rls
The following nightly builds are supported:  2019-08-09, 2019-08-08

Script

#!/usr/bin/env python
import json
import sys
from urllib.request import urlopen

def usage():
    print(""" rustup_component_intersection.py <target> <component> [<component> ...]
    WHAT
        Determines  which rust nightly builds support all the rustup components you rely upon
    ARGUMENTS
        target    e.g., x86_64-unknown-linux-gnu
        component e.g., clippy, rls, or rustfmt
    NOTE
       * Checkout https://rust-lang.github.io/rustup-components-history/ for valid targets and components
       * The rustup components history only provides the past 7 days; Therefor I can only tell you
       about intersections in these 7 days.
       * Error handling is non existent if you pass in an invalid target & component ¯\_(ツ)_/¯.
    """)
    sys.exit(1)

def component_dates(target, component):
    data = {}
    url = 'https://rust-lang.github.io/rustup-components-history/{}/{}.json'.format(target,component)
    with urlopen(url) as raw:
        data = json.load(raw)
    return data

if __name__ == "__main__":
    if len(sys.argv) <= 3 or sys.argv[1] == "-h" or sys.argv[1] == "-h":
        usage()

    target = sys.argv[1]
    components = sys.argv[2:]
    dates = {}
    for component in components:
        for date,supported in component_dates(target, component).items():
            if date == "last_available":
                continue
            if supported:
                if date in dates:
                    dates[date].append(component)
                else:
                    dates[date] = [component]
    supported = {k: v for k, v in dates.items() if len(v) == len(components)}
    print ("The following nightly builds are supported: ", ", ".join(supported.keys()))

@mexus
Copy link
Contributor

mexus commented Aug 9, 2019 via email

@mexus
Copy link
Contributor

mexus commented Aug 15, 2019

@jparris ping (:

@kjvalencik
Copy link

Thanks for sharing this! I think one of the limitations of this idea is that the JSON only provides a week of data (just like the HTML). It would be helpful if the JSON included the full range that was peeked (3 weeks).

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

No branches or pull requests

3 participants