-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat: GitHub Codespaces support in LocalNet command group #456
Conversation
@aorumbayev This is an epic feature; I've been trying to implement an offline container-agnostic approach since, as you stated, using Docker can be problematic. My approach is similar to yours in that we need a local network engine. Thank you for not destroying the local network design. I'm adding this to my workboard, but this might be a better stopgap. |
@aorumbayev I could not get the pull to work without docker installed... I'm guessing its in the localnet group of the cli erroring out. |
@ShoGinn Nice find, you're spot on. The presence of docker is checked when the localnet command group is loaded. At the moment this PR is a quick spike to see what is possible, so a bit rough around the edges. |
3692d77
to
e5c7a4f
Compare
@ShoGinn this is still a preview mvp, but i patched the issue you had with docker, feel free to retry again |
I actually tried it when I saw you made some commits. It works great, and I'm excited to see how it progresses. This solution is much cleaner than local docker/podman and enables a solid dev environment. I think the CLI is going to be the biggest work. My recommendation is that rather than having dappflow or other commands check for the engine, have it check for the URL: port, but that's just a recommendation. |
47396d1
to
d94d8c6
Compare
@neilcampbell @robdmoore @Loedn , ill still keep pr description as adr up until this pr is closed/merged/resolved. Proposed changes
(cc @ShoGinn , feel free to check it out comment too, first hand user feedback is always welcome! :-) ) |
@aorumbayev I did some tests with the latest code; the codespace will start without start (I'm not sure if that is intended). Also, because the cli is always looking for docker, it won't work for I would recommend that localnet include codespace or docker for commands, dig deeper for things like logs, etc., and make the explore and console less restrictive, just naturally failing or checking ports rather than files. |
@ShoGinn hey thank you for checking it out! RE: starting without start RE: explore RE: 'I would recommend that localnet include codespace or docker for commands' For extra reference while this pr is open you can access the new docs covering this command from here https://github.com/algorandfoundation/algokit-cli/blob/feat/codespaces-localnet/docs/features/localnet.md#github-codespaces-based-localnet |
Makes sense!
Can't wait!
Sorry this was a fragmented thought! I just meant in the cli make commands specific to the docker portion a sub-command in the cli.
All of these commands should be under that way when implemented you know what features are what.
|
@ShoGinn i see, i do agree that it does make the command group semantics a bit cleaner (given that this pr is now introducing an alternative mechanism to accessing the localnet).
|
It's definitely an option. I do quite like that we are somewhat decoupled from Docker with the command semantics, as I guess it's still possible LocalNet could be an entirely native setup.
A potential issue with this approach is discoverability. It's probably not the first place someone will look to run a hosted LocalNet. What would the command be in this case I think there are pros and cons of the approaches. Let's chat to work them out and make a decision. |
@@ -120,3 +122,24 @@ AlgoKit Utils provides methods to help you do this: | |||
- Python - [`ensure_funded`](https://algorandfoundation.github.io/algokit-utils-py/html/apidocs/algokit_utils/algokit_utils.html#algokit_utils.ensure_funded) and [`get_dispenser_account`](https://algorandfoundation.github.io/algokit-utils-py/html/apidocs/algokit_utils/algokit_utils.html#algokit_utils.get_dispenser_account) | |||
|
|||
For more details about the `AlgoKit localnet` command, please refer to the [AlgoKit CLI reference documentation](../cli/index.md#localnet). | |||
|
|||
## GitHub Codespaces-based LocalNet |
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.
I think we should put some info to justify why we run an interactive session. This should be a nice segue into some brief content a the free and linking to the GH docs to show the current free limits.
I think it would also be good to link to the docs for setting up spending limits, to ensure users have the info needed to ensure they don't get unexpected bills. I believe by default the spending limits are $0, however I think this is still good to include. https://docs.github.com/en/billing/managing-billing-for-github-codespaces/about-billing-for-github-codespaces#setting-a-spending-limit
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.
What was the outcome with regards to inactivity timeouts? Does port forwarding prevent the inactivity timeout from ever triggering.
I would keep the localnet functionality outside of the |
c89a980
to
9f2af80
Compare
@neilcampbell @robdmoore podman is rather tricky to install on github actions, ubuntu registry has an outdated version and running on m1 macs require a lot of extra setup that will slow down the build. Should we address the ci bit for it separately? Otherwise ready for re-review:
|
Co-authored-by: Neil Campbell <[email protected]>
Co-authored-by: Neil Campbell <[email protected]>
on: | ||
pull_request: | ||
schedule: | ||
- cron: "0 8 * * 1" # Each monday 8 AM UTC |
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.
Fyi @robdmoore @neilcampbell this for now is manually set on the repo but I mentioned to @Loedn that if there will be a github app available on foundation's org account we can use that later on to securely auth requests to trigger these checks from a single pipeline that we can place on the https://github.com/algorandfoundation/algokit repo (without the need to deal with PATs, but obv this would not be the only advantage, can simplify cross repo communication by a great extent, we can also properly use branch protection rules that way). @Loedn for the time being though this will be set as a manual cron only covering the cli repo, as soon as the bot is available for use to auth just let me know
@neilcampbell switched to webi installer on windows too and the official installer recommends restarting the terminal session so ive matched the cli behaviour with that, if gh is not installed it will exit upon auto installation and user will need to re run the codespace command upon restart of the terminal (will update the docs on this tomorrow). |
proc_mock.should_fail_on( | ||
["gh", "--version"], | ||
) | ||
proc_mock.set_output(["powershell", "--version"], ["PowerShell 7.2.1"]) |
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.
I don't believe that powershell --version
is available.
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.
I also get the following error when the webi installer runs. It still installs though. I'm running PowerShell 7.3.6.
Set-ExecutionPolicy : The 'Set-ExecutionPolicy' command was found in the module 'Microsoft.PowerShell.Security', but the module could not be loaded. For more information, run 'Import-Module
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.
@neilcampbell should be resolved now, powershell is checked via different command that is more versatile.
The Set-ExecutionPolicy on the other hand is a bit tricky to replicate, whats the output of Get-ExecutionPolicy -List
on your side when you run it in powershell on windows (preferably same environment as the one where the error occurred during install).
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.
@aorumbayev Output is this:
Scope ExecutionPolicy
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
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.
@aorumbayev Forgot to mention I was running algokit -v localnet codespace
.
When running without -v it works fine without any error being printed, so we can ignore this.
@ShoGinn codespaces support is out and available under this release version https://github.com/algorandfoundation/algokit-cli/releases/tag/v2.1.0 |
Spike following the https://github.com/orgs/algorandfoundation/projects/1/views/1?filterQuery=aorum&pane=issue&itemId=56476748
Proposed Changes
This document serves as an informal Architecture Decision Record (ADR). Proceedings from the PR discussion will be converted to an ADR markdown file later.
Motivation
A significant number of users attending bootcamps encountered scenarios where their devices had hardware incompatibilities with Docker (primarily certain Windows 10 variations). The proposal aims to provide a convenient built-in experience that leverages GitHub CLI capabilities to provision a dummy Codespace instance (using the Algokit base template as a target) to port forward localnet ports to the user's machine.
Proposal
The idea is to provide a new command under
localnet
group to cover this scenario for users experiencing issues with docker. We can rely on GitHub CLI to leverage codespaces and their port-forwarding capabilities, allowing the Algokit CLI to lazily load the dependency if not present. The current proof of concept assumes winget for Windows and uses a 'webi' executable on Unix devices.On the first login, the user is redirected to GitHub CLI's interactive authentication flow. Afterward, any existing Codespaces with the 'sandbox' prefix are automatically deleted. Finally, a fresh Codespace is created, and after a 60-second sleep (a holistic estimate for base machine quota, roughly half for container boot, and the remaining quarters for
pipx algokit install
and starting the localnet), the indexer, algod, and kmd ports from the Codespace are redirected to the user's machine. The user can then open a new tab and interact with the localnet as if it were running locally (similar to the Docker-based experience).Pros
localnet
command group that provides a free quota-based temporary on-demand instance can offer a flexible alternative solution for any edge case where Docker is unavailable for local development.Cons and Minor Notes
Next steps
How to play around with the poc ?
pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/codespaces-localnet --force
thenalgokit localnet codespace start