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

Tests can't run without yarn #50772

Open
arusa opened this issue Jan 16, 2024 · 4 comments
Open

Tests can't run without yarn #50772

arusa opened this issue Jan 16, 2024 · 4 comments

Comments

@arusa
Copy link

arusa commented Jan 16, 2024

Steps to reproduce

  1. Create a new rails app that uses yarn
  2. docker build -t testimage:1 .
  3. docker run -it testimage:1 /bin/bash
  4. bin/rails test

Expected behavior

As the image already contains all precompiled assets I would expect the tests to be able to run successfully even without precompiling first.

Actual behavior

bin/rails test now always runs test:prepare, which tries to compile the assets and therefore crashes, because the default Dockerfile doesn't keep yarn in the image.

I want an option to skip running test:prepare when running tests.

System configuration

Rails version: 7.1.2

Ruby version: 3.1.4

@rafaelfranca
Copy link
Member

I don't think we should skip test:prepare since it can run more things, but I can see us not trying to compile assets if they are present like we used to do with sprockets.

@rafaelfranca
Copy link
Member

BTW, I know the current dockerfile is supposed to be used to run tests, but I'm planning to change that. The Dockerfile used for CI will be the same one that will be used in development, and that will for sure include yarn. That is another way to solve this issue.

@waymondo
Copy link
Contributor

waymondo commented Jan 29, 2024

i ran into this today too after a Rails update where we have a docker setup where an image already has the precompiled assets (and no yarn executable). i learned though that cssbundling-rails allows you to bypass the build step with an ENV var:

https://github.com/rails/cssbundling-rails/blob/main/lib/tasks/cssbundling/build.rake#L63

@rails-bot
Copy link

rails-bot bot commented Apr 28, 2024

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 7-1-stable branch or on main, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

@rails-bot rails-bot bot added the stale label Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants