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

Resolves #3829 Improve codespaces debugging #4482

Merged
merged 11 commits into from
Aug 4, 2024

Conversation

jimmyli97
Copy link
Contributor

@jimmyli97 jimmyli97 commented Jun 27, 2024

Fix #3829

Description

  • Adds desktop environment to codespaces so tests can be viewed in browser
  • Fix setup issues with nvm and rbenv
  • Rewrite dockerfile to use apt-get and noninteractive
  • Adds debug gem to gemfile to allow attaching to live server using Shopify
  • Adds additional documentation on debugging using VSCode Shopify extension

Motivation

I think it's safe to close #3829 with these fixes because I've been doing all my development in codespaces with this setup recently and it's working great.

  • bin/start didn't work out of the box due to failed javascript runtime and rbenv, fixed to install node and rbenv init (I don't know when this stopped working because it did work before)
  • Much easier to write tests when you can view them running in browser
  • apt-get and noninteractive are best practice for dockerfiles
  • I like using Shopify's debugger because I find setting breakpoints much easier with a GUI

Dependencies

gem "debug", ">= 1.0.0"

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update
  • Documentation update

How Has This Been Tested?

  • Full rebuild of codespace, bin/start works out of the box
  • NOT_HEADLESS=true bundle exec rspec spec/system/partner_system_spec.rb running in Codespaces is visible over noVNC on localhost:6080
  • Ran Shopify Ruby LSP debugger and attached to the server as per documentation in VSCode and in Codespaces.

Screenshots

@cielf cielf requested a review from awwaiid June 27, 2024 16:09
CONTRIBUTING.md Outdated
3. Run `bin/start` and visit the URL that pops in VSCode up to see the human essentials page
4. Login as a sample user with the default [credentials](#credentials).
3. Run `bin/start`.
4. Right click on port 3000, set the port visibility to Public, and visit the URL that pops in VSCode up to see the human essentials page.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interestingly, I've never had to do this step and was able to visit the URL without issue. Is this an optional step maybe?

Copy link
Contributor Author

@jimmyli97 jimmyli97 Jun 27, 2024

Choose a reason for hiding this comment

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

I tried again today and now the private port is working after a workaround so I think it is a bug in the VSCode Codespaces extension. Yesterday I tried to view the app at 127.0.0.1:3000 after port forwarding with visibility set to private and couldn't figure out why it wasn't working, I just got "ERR_EMPTY_RESPONSE". The server was up and running and I could curl to it just fine in the Codespace terminal, so I really couldn't figure out what was wrong. There was another contributor in Slack who ran into this issue also.

I removed the doc about public ports in commit 377cf8e

@jimmyli97 jimmyli97 force-pushed the improve-codespaces-debugging branch 2 times, most recently from f4d30bd to 84cf1e8 Compare June 27, 2024 18:31
@jimmyli97 jimmyli97 force-pushed the improve-codespaces-debugging branch from 84cf1e8 to 377cf8e Compare July 3, 2024 23:20
* apt-get is best practice for scripts, see this [link](https://askubuntu.com/a/990838/1817536)
* DEBIAN_FRONTEND noninteractive is best practice for Docker setup, see this [link](https://askubuntu.com/a/1430072/1817536)
* Can now run Chrome in NOT_HEADLESS=true and view tests in browser
  on Codespaces
@jimmyli97 jimmyli97 marked this pull request as draft July 7, 2024 02:48
@jimmyli97 jimmyli97 force-pushed the improve-codespaces-debugging branch from 879be46 to 1d4a0df Compare July 7, 2024 03:24
@jimmyli97 jimmyli97 force-pushed the improve-codespaces-debugging branch from 1d4a0df to 92217c8 Compare July 7, 2024 03:44
@jimmyli97 jimmyli97 changed the title Improve codespaces debugging Resolves #3829 Improve codespaces debugging Jul 9, 2024
@jimmyli97 jimmyli97 marked this pull request as ready for review July 10, 2024 23:10
@jimmyli97 jimmyli97 force-pushed the improve-codespaces-debugging branch 2 times, most recently from 1116a39 to 3dfb6ea Compare July 11, 2024 03:49
@cielf cielf requested a review from awwaiid July 11, 2024 20:11
Copy link
Collaborator

@awwaiid awwaiid left a comment

Choose a reason for hiding this comment

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

This works. Still takes a long time to start, and I didn't verify the VNC-browser bit. I think I liked it a bit more when the ports popped up instead of me needing to go click them, but I'll merge this in for the other improvements and we'll wait for general feedback. Thank you!

@awwaiid awwaiid merged commit 3c05471 into rubyforgood:main Aug 4, 2024
20 checks passed
@jimmyli97
Copy link
Contributor Author

jimmyli97 commented Aug 4, 2024

@awwaiid

Looks like speeding up the container build is possible with a Github action prebuilding and pushing to ghcr.io, which is free storage for public repos, following this guide (https://containers.dev/guide/prebuild), I might be able to look into it when I have a chance

(previous comment before edit)
probably the best way to speed it up is with [codespace prebuilds] (https://docs.github.com/en/codespaces/prebuilding-your-codespaces/configuring-prebuilds#configuring-prebuilds), which takes up billable storage in the organization repo, and has to be done by someone with admin access, and moving the post-create.sh to updateContentCommand so the prebuild builds it. I can open an issue for that if you want, not sure if that's something you have the storage or the time for.

@jimmyli97 jimmyli97 deleted the improve-codespaces-debugging branch August 5, 2024 00:25
Copy link
Contributor

@jimmyli97: Your PR Resolves #3829 Improve codespaces debugging is part of today's Human Essentials production release: 2024.08.11.
Thank you very much for your contribution!

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.

Experiment with Code Spaces and related tooling
2 participants