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

Use github access token when running docker locally #10056

Merged
merged 4 commits into from
Jul 31, 2024

Conversation

riknoll
Copy link
Member

@riknoll riknoll commented Jul 30, 2024

One annoying thing about using our CLI to build locally w/ docker images is that yotta is constantly getting throttled by GitHub. We even have a GITHUB_ACCESS_TOKEN environment variable that we advertise as something you can configure, but it only gets used by PXT and not yotta which is a bummer.

Well, not anymore! This PR passes that GITHUB_ACCESS_TOKEN variable to the docker container and runs a script to setup the local ~/.yotta/config.json and ~/.netrc files to prevent throttling. This token doesn't actually need to have any permissions at all, GitHub just wants to use it for authentication.

Also, this PR fixes the --local flag which I had accidentally disabled in my last pr.

Completely unrelated to this, I also converted a function in cli.ts to use async await because it was bothering me.

@riknoll riknoll requested a review from a team July 30, 2024 21:34
@@ -387,14 +387,29 @@ function runDockerAsync(args: string[]) {
if (process.platform == "darwin")
mountArg += ":delegated"

let fullArgs = ["--rm", "-v", mountArg, "-w", "/src"].concat(dargs).concat([cs.dockerImage]).concat(args);
Copy link
Contributor

Choose a reason for hiding this comment

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

All of these concats look a little funky to me. Can we use spread syntax here instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure

cli/buildengine.ts Outdated Show resolved Hide resolved
updateEngineAsync: () => runDockerAsync(["yotta", "update"]),
buildAsync: () => runDockerAsync(["yotta", "build"]),
updateEngineAsync: () => runDockerYottaAsync(["yotta", "update"]),
buildAsync: () => runDockerYottaAsync(["yotta", "build"]),
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are special casing Yotta, do we need to include "yotta" in the args?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's easier to understand with yotta there since that's the command you would be running if you were doing all this manually.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense!

@riknoll riknoll merged commit 5c12a8a into master Jul 31, 2024
6 checks passed
@riknoll riknoll deleted the dev/riknoll/local-github-token branch July 31, 2024 16:23
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.

2 participants