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

GitHub url does not work when there are no releases #18101

Closed
styfle opened this issue Oct 10, 2018 · 23 comments
Closed

GitHub url does not work when there are no releases #18101

styfle opened this issue Oct 10, 2018 · 23 comments

Comments

@styfle
Copy link

styfle commented Oct 10, 2018

I would expect the github url to work even when there are no releases and instead, use the master branch.

For example, /gh/jsonmc/jsonmc/ has the following response:

Couldn't find the requested release version latest.

Or at the very least, could there be an option to use a branch instead of a tag such as @master?

@MartinKolarik
Copy link
Member

"latest" links only support releases. Commits (branches) change too often and couldn't be cached effectively plus there would be a high chance of breaking changes.

@styfle
Copy link
Author

styfle commented Oct 10, 2018

change too often and couldn't be cached effectively

I think you can use the same algorithm that is used for the latest release.

https://cdn.jsdelivr.net/gh/jquery/jquery/dist/jquery.min.js

I don't think "change too often" is a good argument because someone could do several releases in a matter of minutes.

there would be a high chance of breaking changes

Maybe that's true for some repos but many have CI so that breaking changes are never merged into master. The one I linked to would never have breaking changes because it only contains data. https://github.com/jsonmc/jsonmc

The following free services offer fantastic alternatives to some or all of RawGit's functionality. You may like them even more than RawGit.

Now that RawGit is going down, there are going to be users flocking to jsdelivr. If you can't meet their needs, they'll go elsewhere. https://rawgit.com/

@MartinKolarik
Copy link
Member

We will consider adding this.

@styfle
Copy link
Author

styfle commented Oct 11, 2018

Thank you for considering! 👍

I'll give you another use case to think about.

The marked.js project has a demo page that we use to verify a bug occurs in the most recent npm release.

We have considered adding a dropdown to pick a version of marked to load so we can see when a bug was introduced. That should be relatively easy to implement since jsdelivr lets you pick a verison.

What we are unable to do now is to load the master branch version of marked to see if a bug is already fixed but hasn't been released yet (we go months between releases and bugs can get reported many times but are already fixed).

Using jsdelivr to load from master branch would be superb!

@MartinKolarik
Copy link
Member

What we are unable to do now is to load the master branch version of marked to see if a bug is already fixed but hasn't been released yet

Just a note that even if we allow this, we'll most likely use 7 days cache time (like for current latest release); 24 hours would be absolute minimum. Of course you can purge the link via our API in CI build but at that point you could also do what ractive.js does - publish every single build to npm, tag it as @next and access it as a regular npm tag.

@styfle
Copy link
Author

styfle commented Oct 11, 2018

we'll most likely use 7 days cache time

I think that would be acceptable for this use case. Typically, months go by without a release as you can see from the npm version history.

Of course you can purge the link via our API in CI

That sounds really cool! Where can I find this API?

publish every single build to npm, tag it as @next and access it as a regular npm tag

That is an interesting workaround. I think typescript does something similar. This would require a little more work and giving CI ability to publish to npm which we don't currently do. I'll think about this too.

@MartinKolarik
Copy link
Member

https://github.com/jsdelivr/jsdelivr#purge-cache

@tjenkinson
Copy link
Contributor

We also publish master as npm prereleases using Travis which works quite well :)

https://github.com/video-dev/hls.js/blob/master/scripts/travis.sh

@styfle
Copy link
Author

styfle commented Oct 29, 2018

It looks like your competitor, Staticaly, already implemented this feature using a dev flag.

https://cdn.staticaly.com/gh/markedjs/marked/master/lib/marked.js?env=dev

In fact, it looks like they copied a lot of what jsdelivr does and how it looks.
Maybe JSDelivr could copy this behavior? 🤔

@MartinKolarik
Copy link
Member

In fact, it looks like they copied a lot of what jsdelivr does and how it looks.

We're aware, the last time I checked even some pages on their website were exact word-to-word copies of jsdelivr.com.

@MartinKolarik
Copy link
Member

MartinKolarik commented Oct 31, 2018

Guess what just landed on our servers 😉

https://cdn.jsdelivr.net/gh/jsonmc/jsonmc/
https://cdn.jsdelivr.net/gh/jsonmc/jsonmc@master/
https://cdn.jsdelivr.net/gh/jsonmc/jsonmc@any-other-branch/

@styfle
Copy link
Author

styfle commented Oct 31, 2018

@MartinKolarik Thank you so much!

I will continue to proclaim @jsdelivr as the greatest service ever! 😄

@heymartinadams
Copy link

Amazing, @MartinKolarik

If you wouldn’t mind adding the @branch feature to your docs and homepage, that would make this feature easier to find (only found this feature by searching through the issues). Currently, the homepage only features release versions: https://www.jsdelivr.com/?docs=gh

Thanks again 👍🏼

@heymartinadams
Copy link

@MartinKolarik, does committing and pushing changes to a branch not update the branch file? I committed and updated changes to it a good 15 minutes ago, yet changes haven’t shown up. link

@heymartinadams
Copy link

Saw this, thanks! jsdelivr/www.jsdelivr.com#179 (comment)

@MartinKolarik
Copy link
Member

@heymartinadams there's no example at https://www.jsdelivr.com/?docs=gh but the first line mentions it:

load any GitHub release, commit, or branch

I agree the readme should be updated too though.

@AlienKevin
Copy link

I discovered that jsdelivr won't fetch the master branch if there are already release versions. I tried to fetch a fork of flatdoc but the url failed to load. This is the url I trying to load:
https://cdn.jsdelivr.net/gh/Thrilleratplay/flatdoc@master/slate-theme/style.css
which is this file on github.
I would appreciate it if jsdelivr adds the support. For now, I have to resort to staticly.

@MartinKolarik
Copy link
Member

@AlienKevin there's no master branch in that repo, only gh-pages branch, and your file path is wrong as well. It's theme-slate/style.css, not slate-theme/style.css. The correct link is https://cdn.jsdelivr.net/gh/Thrilleratplay/flatdoc@gh-pages/theme-slate/style.css

@ncruces
Copy link

ncruces commented Apr 15, 2019

I just "convinced" google/code-prettify to switch from RawGit, only to realize we still have issues because we're using master directly.

@MartinKolarik, is the 7 day policy you mentioned in place? Because the change was made 7 weeks ago, and cdn.jsdelivr.net is still serving the old version (cache-control is also one year, immutable). Is purging the only answer?

I'm not trying to get you to change anything, rather I want to understand the system, so we can figure something out.

@styfle
Copy link
Author

styfle commented Apr 15, 2019

@ncruces We also had this problem with marked when reading from master and decided to fetch the latest by the commit hash.

markedjs/marked#1457

@ncruces
Copy link

ncruces commented Apr 15, 2019

Yes, that works.

The problem with google/code-prettify is that the main js file loads plugins (other js and css files). And those URLs (which now point into master) are hard coded into the source. Commit hashes can't fix this. Tagging releases (and changing the code to match) can.

@MartinKolarik
Copy link
Member

@ncruces there was a bug about 2 months ago, which caused some @Branch files to be marked as static/immutable. The affected version of our code was live for about a week and some URLs cached at that time might have longer cache-control expiration. I purged your URLs and now they have correct headers.

@AlienKevin
Copy link

@MartinKolarik Thank you! That solves my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants