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

Fixes #4425 so tests work after Docker setup #4426

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

jimmyli97
Copy link
Contributor

@jimmyli97 jimmyli97 commented Jun 4, 2024

Resolves #4425

Description

Fixes the Docker setup files so that tests pass out of the box, by installing latest version of Chrome and also setting the DOCKER environment variable.

Tests use Cuprite which relies on a headless Chrome browser. However, you can't run Chrome's browser sandboxed in Docker containers. There's an environment variable called DOCKER when registering Cuprite (see rails_helper.rb) which tells it to run browser as non-sandboxed.

Alternative solutions

  • latest version of Chromium can't run on this old-old-stable version of Debian, which means some tests fail if trying to use old-old-stable Chromium
  • You could set the DOCKER environment variable in the dockerfile, but I don't think there's a big difference between that and devcontainer.json,
  • Also, you could set cap_add: SYS_ADMIN in docker-compose.yml instead of setting this environment variable which grants the container root access to the parent machine and allows Chrome to run sandboxed, but I think that's overkill

Motivation

I wanted to try out Codespaces because I have a relatively old machine and rspec locally takes about 25 minutes, rspec on Codespaces 4-core takes 10 minutes and is much faster.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  1. Create new codespace from this branch
  2. After installation, run bundle exec rspec in terminal. All tests pass.
  3. Install Dev Container add-on in VSCode and open repo locally in Dev Container
  4. After installation, run bundle exec rspec in terminal. All tests pass.

@jimmyli97 jimmyli97 force-pushed the 4425-codespaces-tests-bugfix branch 2 times, most recently from 1b4f198 to 4fed336 Compare June 4, 2024 19:58
@jimmyli97 jimmyli97 changed the title Fixes #4425 so tests work after Docker setup Fixes #4425 so tests work after Docker setup (draft) Jun 4, 2024
@jimmyli97 jimmyli97 force-pushed the 4425-codespaces-tests-bugfix branch from 4fed336 to f5b3bf0 Compare June 4, 2024 21:59
@jimmyli97 jimmyli97 force-pushed the 4425-codespaces-tests-bugfix branch from f5b3bf0 to 44f4cd7 Compare June 4, 2024 22:01
@jimmyli97 jimmyli97 changed the title Fixes #4425 so tests work after Docker setup (draft) Fixes #4425 so tests work after Docker setup Jun 4, 2024
@cielf cielf requested a review from awwaiid June 5, 2024 17:42
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.

Delightful, thank you!

@awwaiid awwaiid merged commit c2e7f20 into rubyforgood:main Jun 6, 2024
19 checks passed
@jimmyli97 jimmyli97 deleted the 4425-codespaces-tests-bugfix branch June 10, 2024 18:59
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.

[BUG]: rspec tests fail in fresh virtual machine dev environments
2 participants