-
Notifications
You must be signed in to change notification settings - Fork 581
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
Consume new ghtutorial route when loading tutorials from github #10217
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
updated with the changes I made to the API route. this now also works with tutorials in the docs folder of targets, uses etags, and proxies requests through the CDN. here's an upload target you can use to test (micro:bit): https://makecode.microbit.org/app/de79fa186a7b3225ed5aeb161ea70ec7796af70e-ac898cc414 and here's a URL that includes a docs tutorial that has a GitHub dependency: the |
@microsoft/makecode-engineers this is now ready for review! here is an updated upload target: https://makecode.microbit.org/app/36c4b10f729c193f650f763ba2e37a23adefdd90-bcbbdbd05c |
@@ -252,6 +252,14 @@ class FileGithubDb implements pxt.github.IGithubDb { | |||
loadPackageAsync(repopath: string, tag: string): Promise<pxt.github.CachedPackage> { | |||
return this.loadAsync(repopath, tag, "pkg", (r, t) => this.db.loadPackageAsync(r, t)); | |||
} | |||
|
|||
loadTutorialMarkdown(repopath: string, tag?: string): Promise<pxt.github.CachedPackage> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious why we need a function like this defined in so many places? I see that the one defined in the github namespace is getting used along with db.loadTutorialMarkdown, but what do each of these allow for us to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question for the cacheReposAsync
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's defined on the githubdb interface so all of the classes that implement that interface need to have it as well! i just propagated it to all of the existing ones we have, i don't actually know what this one in the CLI is used for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question for my own understanding. Looks good!
This consumes the newly proposed /api/ghtutorial/ endpoint. Opening as a draft PR because this endpoint isn't actually released yet.
When loading a tutorial from github, this takes the response from /api/ghtutorial/ and uses it to populate all of the caches that we maintain in indexeddb. The rest of the markdown loading pipeline is unchanged, the requests it makes simply hit the cache instead of actually making requests to the backend.
This PR also makes it so that we now cache the latest versions of github repos inside indexeddb just like we do everything else. Unlike the other things we cache, the entries for latest versions expire after an hour. I might end up increasing this period, though, since that isn't very much time at all.
I also added a
skipgithubcache=1
query parameter that bypasses all of our local github repo caches to make it easier for content creators to verify their changes.also tacked on an unrelated change making it so that the
saveblocks
query param is now case insensitive and acceptssaveasblocks
since I always accidentally try that first.