Skip to content

Add 'ldc-nightly' install target#282

Merged
wilzbach merged 5 commits intodlang:masterfrom
JohanEngelen:ldcnightly
Dec 20, 2018
Merged

Add 'ldc-nightly' install target#282
wilzbach merged 5 commits intodlang:masterfrom
JohanEngelen:ldcnightly

Conversation

@JohanEngelen
Copy link
Copy Markdown
Contributor

This PR installs ldc-nightly in e.g. "ldc-8c0abd52-20171222"
(DMD installs nightlies in e.g. "dmd-master-2017-12-27")

LDC does not have a LATEST_NIGHTLY file online, so I opted for just downloading the nightlies release page and grepping for what the binary package name should look like.

Tested on OSX.

@dlang-bot
Copy link
Copy Markdown
Contributor

dlang-bot commented Dec 27, 2017

Thanks for your pull request and interest in making D better, @JohanEngelen! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Copy link
Copy Markdown
Contributor

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

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

LGTM. I will add it to run.dlang.io once this is merged and deployed to dlang.org

Comment thread script/install.sh Outdated
ldc-nightly)
local CIurl=https://github.com/ldc-developers/ldc/releases/tag/CI
logV "Finding latest ldc-nightly binary package (at $CIurl)."
local package="$(curl -s $CIurl | grep -o "ldc2-[0-9a-f]*-$OS-$ARCH-[0-9]*.tar.xz" | head -n 1)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shellcheck error:

In script/install.sh line 427:
            local package="$(curl -s $CIurl | grep -o "ldc2-[0-9a-f]*-$OS-$ARCH-[0-9]*.tar.xz" | head -n 1)"
                  ^-- SC2155: Declare and assign separately to avoid masking return values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How do you want me to fix this?
local -r silences the warning; i don't particularly care about error codes, because we handle the error elsewhere. Still, it might be nice for the user to see the raw error.. ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think both local -r and using a separate line for the definition work though the latter seems to be the more prevalent style in this script, so I would opt for that one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@wilzbach
Copy link
Copy Markdown
Contributor

Tested on OSX.

And now Linux ;-)
Too increase coverage, you might want to add ldc-nightly to the travis.sh test script.

@wilzbach
Copy link
Copy Markdown
Contributor

Thanks. As @MartinNowak is the author and "owner" of this install script, I would wait for his feedback/approval before merging. I can't deploy it anyways :/

Copy link
Copy Markdown
Member

@PetarKirov PetarKirov left a comment

Choose a reason for hiding this comment

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

Thanks for the nice work @JohanEngelen, LGTM!

Comment thread script/install.sh Outdated
local CIurl=https://github.com/ldc-developers/ldc/releases/tag/CI
logV "Finding latest ldc-nightly binary package (at $CIurl)."
local package
package="$(curl -s $CIurl | grep -o "ldc2-[0-9a-f]*-$OS-$ARCH-[0-9]*.tar.xz" | head -n 1)"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hopefully we can replace this with a more robust way of getting the latest CI build, but we can live with it for now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The uploads are not sorted and old ones aren't deleted, so that results in a random artifact, not the latest one.
Who's updating the sha of the CI tag btw?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(nice, you spotted the problem too)

@PetarKirov
Copy link
Copy Markdown
Member

PetarKirov commented Dec 28, 2017

Nit: can you squash the "Fix [..] warning" commit into the first one? (Once it passes the CI tests.)

Comment thread script/install.sh Outdated
local CIurl=https://github.com/ldc-developers/ldc/releases/tag/CI
logV "Finding latest ldc-nightly binary package (at $CIurl)."
local package
package="$(curl -s $CIurl | grep -o "ldc2-[0-9a-f]*-$OS-$ARCH-[0-9]*.tar.xz" | head -n 1)"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use fetch instead of curl so there is some retry logic.

Comment thread script/install.sh Outdated
COMPILER="ldc-$(fetch $url)"
;;
ldc-nightly)
local CIurl=https://github.com/ldc-developers/ldc/releases/tag/CI
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Weird variable name, how about url or ci_url instead?

Comment thread script/install.sh Outdated
logV "Determining latest ldc-beta version ($url)."
COMPILER="ldc-$(fetch $url)"
;;
ldc-nightly)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd say we should at least also resolve ldc-2017222 so it's possible to install a compiler from a specific date, quite useful for bisecting an issue.
I'm not sure whether you actually plan to archive your nightly builds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I also don't know whether we'll archive the nightlies.
This is a new feature though, so please just merge this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(they aren't "nightlies" btw, it's a new build after each git commit)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps we should name it ldc-latest-ci-build?

Copy link
Copy Markdown
Contributor

@kinke kinke Nov 28, 2018

Choose a reason for hiding this comment

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

I don't like the term 'nightly' either. I guess for DMD they are indeed proper nightlies with no difference compared to regular builds. For us, they are the latest successful CI builds, which means a revision may not be available for all platforms (sporadic failures, timeouts...), not available at the same time (Windows x64/multilib and OSX packages taking quite a bit longer than the Linux x64 one), and particularly, they feature enabled LLVM+LDC assertions (well, currently not for Windows, due to AppVeyor slowness), increasing compile times over a normal release package.

@JohanEngelen
Copy link
Copy Markdown
Contributor Author

JohanEngelen commented Dec 29, 2017

Wait with merging, this does the wrong thing.

Edit: I thought we only keep the latest nightly on that "CI" release page, but apparently new builds are appended. So we cannot just do a grep for the package name, because that would just get the package with the alphabetically first githash. So this PR needs a big rework.

@JohanEngelen JohanEngelen changed the title Add 'ldc-nightly' install target [WIP] Add 'ldc-nightly' install target Dec 29, 2017
@dlang-bot dlang-bot added the WIP label Dec 29, 2017
@PetarKirov
Copy link
Copy Markdown
Member

@JohanEngelen as mentioned in ldc-developers/ldc#1883 (comment), I think the best solution would be to make your CircleCI job push commits to https://github.com/ldc-developers/ldc-developers.github.io, updating a file like LATEST_CI.

@MartinNowak
Copy link
Copy Markdown
Member

Looking at this you might want to add ldc-lts before anything else ;).
Shouldn't the other one always be the latest commit on master?
How about ldc-edge resolving to ldc-$(git describe) (e.g. ldc-1.7.0-beta1-18-gf86e33f1).
Indeed it would be cleaner if you could push LATEST_EDGE/CI to that page or to the CI release page.

@MartinNowak
Copy link
Copy Markdown
Member

At best you keep the uploads for a week, so found issues can be reproduced.
Maybe directly using CircleCI's artifacts would be cleaner? Though they don't seem to provide any delete option.

@wilzbach
Copy link
Copy Markdown
Contributor

@JohanEngelen did you manage to write such a LATEST_CI file?

@JohanEngelen
Copy link
Copy Markdown
Contributor Author

@wilzbach Haven't looked further into this. It's on the backburner...

Comment thread script/install.sh Outdated
local ci_url=https://github.com/ldc-developers/ldc/releases/tag/CI
logV "Finding latest ldc-nightly binary package (at $ci_url)."
local package
package="$(fetch $ci_url | grep -o "ldc2-[0-9a-f]*-$OS-$ARCH-[0-9]*.tar.xz" | head -n 1)"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Surely querying the GitHub API is not going to be any worse than scraping HTML...

@CyberShadow
Copy link
Copy Markdown
Member

Wait with merging, this does the wrong thing.

Check if it's possible to formulate a GitHub API query for this. Even if parsing the result with just bash is infeasible, having a dependency on jq seems reasonable.

@wilzbach
Copy link
Copy Markdown
Contributor

The GitHub API is heavily rate-limited. Using it will lead to failures on heavily used CIs like Travis.

@CyberShadow
Copy link
Copy Markdown
Member

Oh, because it will share limits with the IPs of CI services?

That makes sense, but scraping HTML is still fragile. CI services generally allow adding secrets to the account, so an API authentication token can be used there. (Or, just move the logic elsewhere...)

@JohanEngelen
Copy link
Copy Markdown
Contributor Author

I have completely stopped working on this btw. Feel free to take over.

@CyberShadow
Copy link
Copy Markdown
Member

I really don't know that much about LDC development.

I could write a tiny web service that returns the needed information from the GitHub API, if it helps. But, I can only guarantee that its availability will be as good as e.g. forum.dlang.org, which is probably around only 99%.

@wilzbach
Copy link
Copy Markdown
Contributor

This would help a lot for this issue.

@CyberShadow
Copy link
Copy Markdown
Member

Cool. Will you do the other part if I do that?

@JohanEngelen
Copy link
Copy Markdown
Contributor Author

JohanEngelen commented Dec 4, 2018

@wilzbach @CyberShadow The date has been removed from the filename. See: https://github.com/ldc-developers/ldc/releases/tag/CI

Edit: wait... how does Vlads script determine which is the newest....??? I sense I did something dumb here...

@kinke
Copy link
Copy Markdown
Contributor

kinke commented Dec 5, 2018

Indeed it would be cleaner if you could push LATEST_EDGE/CI to that page or to the CI release page

The main difficulty is that we are talking about 6 artifacts, published by 5 independent jobs, from 3 different CI services. So it's a timing issue and a question of reliability, as some jobs time out not too seldomly or randomly fail, unfortunately.

I guess there's no real way around querying the GitHub API and checking the timestamps of the files. Having a proxy do that (and cache it for some minutes or so) to bypass the rate limit would be nice, of course.

Edit: Well we could theoretically have a LATEST_CI_<platform> file for all platforms.

@CyberShadow
Copy link
Copy Markdown
Member

The date has been removed from the filename.

Updated script to show only the hash.

Edit: wait... how does Vlads script determine which is the newest....???

The release ID apparently doesn't change when new files are uploaded, so the data is always at /repos/ldc-developers/ldc/releases/8840125.

Having a proxy do that (and cache it for some minutes or so) to bypass the rate limit would be nice, of course.

GitHub does not count 301 replies against the rate limit, which means the script will always provide the latest data with no rate limit.

@kinke
Copy link
Copy Markdown
Contributor

kinke commented Dec 5, 2018

Can you show the source of the script? I only see the result and wonder how it works. It's almost certain that the Linux package is available earlier than the OSX one, so if it just returns the hash of the latest Linux package, the according OSX package may not be available yet. It needs to be per-platform (something like ?platform=linux-x86_64).

@JohanEngelen
Copy link
Copy Markdown
Contributor Author

Well we could theoretically have a LATEST_CI_ file for all platforms.

@kinke That doesn't sound all that bad and would simplify things a lot I feel.

@kinke
Copy link
Copy Markdown
Contributor

kinke commented Dec 9, 2018

Not for us, as 3 CI services need to be able to push to that repo, requiring a token to do so, which could even be abused by some malevolent PR etc.
I guess @CyberShadow's implementation just needs an additional handful of lines, taking a platform input param and filtering the artifact filenames before sorting by upload date and extracting the git hash.

@CyberShadow
Copy link
Copy Markdown
Member

I changed it to just dump all URLs, so that you can grep it as needed. Does that help?

@JohanEngelen
Copy link
Copy Markdown
Contributor Author

@CyberShadow Look at the CI release page now. The problem is getting the URL belonging to the latest packages. (getting the urls is not the problem).

@CyberShadow
Copy link
Copy Markdown
Member

CyberShadow commented Dec 10, 2018

The GitHub server is replying with a "304 Not Modified" to a request with an "If-Modified-Since" of "Tue, 04 Dec 2018 22:50:54 GMT", for a resource that very obviously has been modified within the past week. Looks like a bug in their API.

Edit: sent a support request.

@CyberShadow
Copy link
Copy Markdown
Member

Caching issue was fixed (switched to ETag-based caching at GitHub support's suggestion). What next, should I filter the assets to bin them by the hash and only show the last one per hash?

Can you show the source of the script?

Yes, sorry, here it is:
http://thecybershadow.net/d/github-ldc/index.txt

Library used is https://github.com/milo/github-api + milo/github-api#24.

@JohanEngelen
Copy link
Copy Markdown
Contributor Author

only show the last one per hash?

I'd say only show the last one per arch.

@CyberShadow
Copy link
Copy Markdown
Member

Oops, right. How's this?

@JohanEngelen
Copy link
Copy Markdown
Contributor Author

Looks good to me :)

@kinke
Copy link
Copy Markdown
Contributor

kinke commented Dec 11, 2018

Yeah, thx a lot, seems to work fine.

Tested on mac and linux. (x86_64)
@JohanEngelen
Copy link
Copy Markdown
Contributor Author

OK, I've fixed the script. It now works on my mac and on a Ubuntu server too!

@JohanEngelen
Copy link
Copy Markdown
Contributor Author

JohanEngelen commented Dec 11, 2018

rename ldc-nightly to ldc-latest-ci? Or keep the name for uniformity with DMD's?
As @kinke noted: it is a different build than a release build. So perhaps it's not so bad if it has a different name than -nightly...

@JohanEngelen
Copy link
Copy Markdown
Contributor Author

@wilzbach @kinke @CyberShadow I'm happy with it, it works well for me. Good to merge?

@kinke
Copy link
Copy Markdown
Contributor

kinke commented Dec 13, 2018

Yep, lgtm now.

Copy link
Copy Markdown
Member

@PetarKirov PetarKirov left a comment

Choose a reason for hiding this comment

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

Looks good to me, nice work everyone!

@wilzbach wilzbach removed the WIP label Dec 20, 2018
@wilzbach wilzbach merged commit 6f477a5 into dlang:master Dec 20, 2018
@wilzbach
Copy link
Copy Markdown
Contributor

The script needs manual deployment as it needs to be signed, but I just did so.
It should be available on Travis etc. now, e.g.

d: ldc-latest-ci

@wilzbach
Copy link
Copy Markdown
Contributor

Also, I forgot to say thanks to everyone involved in this effort!

@JohanEngelen @kinke you might want to open a thread in the NG, s.t. people know about this and actually enable it in their CIs.

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.

7 participants