Skip to content

Conversation

@goosys
Copy link
Contributor

@goosys goosys commented Mar 7, 2025

How about recommending the use of Codespaces to make contributions easier?

With this script, we can launch a clean environment for any branch in just three minutes and discard it when it's no longer needed.

To set up the environment, run the following command:

source bin/setup-codespaces
bin/dev

What do you think?
Let me know if there are any other necessary tasks, such as updating the README.

@nickcharlton
Copy link
Member

It's funny that you add this today, as that's what I've been working on for much of this week.

We're trying to see if we can use Codespaces for certain client projects to reduce the onboarding burden, and if it works well enough it makes sense to support it here too.

I'm still deep in the middle of figuring out what the ideal setup might be like, but I'll come back to this soon.

@goosys
Copy link
Contributor Author

goosys commented Mar 7, 2025

Last year, setting up an environment to run RSpec in Codespaces was quite challenging due to the difficulty of installing a headless browser in the container image at the time, as well as compatibility issues with WebDriver. However, these problems have been resolved in the current container image, and now RSpec runs smoothly with just the execution of the newly added script.

For the past few months, I have been using this script to launch Codespaces and work on PRs, and I have found it to be quite comfortable.

Previously, I had stored the script in a Gist and had to manually copy and paste it each time to set up the environment. I created this PR because I thought it would be more convenient to have it readily available in the repository.

@nickcharlton
Copy link
Member

Ooh, that's really good to know, thanks!

I had some comments of previous problems, but no one's been clear enough with me what they actually struggled with.

@goosys
Copy link
Contributor Author

goosys commented Mar 7, 2025

One small issue remains. Currently, since only Foreman loads Dotenv, any command other than bin/dev requires manually exporting the ENV variable to access the database:

export DATABASE_URL=postgresql://postgres:@localhost

This needs to be set for each terminal session, which is a bit inconvenient, but once we get used to it, it’s not a big deal.

Do you have any ideas?

@nickcharlton
Copy link
Member

Oh, interesting. Are you configuring your own dotfiles? One option would be to use something like direnv

export DATABASE_URL=postgresql://postgres:@localhost

./bin/setup
./bin/setup
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is setup running twice by accident or on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's on purpose. The first execution always stops at this point, so a second execution is necessary.
https://github.com/thoughtbot/administrate/blob/main/bin/setup#L12

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, of course. Thank you. How about a comment to remove the confusion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comments!

@goosys goosys force-pushed the add-quickstart-script-for-codespaces branch from df295a5 to 0b2e80a Compare March 7, 2025 17:19
@goosys
Copy link
Contributor Author

goosys commented Mar 7, 2025

Are you configuring your own dotfiles?

No, not really.

The simplest way is to add the export to .bashrc.
Normally, it's not ideal to modify this file, but since this is a temporary environment, keeping it simple might be fine.

echo "" >> ~/.bashrc && echo "export DATABASE_URL=postgresql://postgres:@localhost" >> ~/.bashrc

@nickcharlton
Copy link
Member

Ah, interesting.

I've so far gone down the path of figuring out how to setup a .devcontainer (which is also going to need a docker-compose.yml) and that does at least mostly feel like a better approach, but the journey there has been generally ...unpleasant. I should have something to share soon.

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.

3 participants