rails/sprockets-rails

Precompile asset esbuild failure does not trigger CI build exit

Mycobee opened this issue · 1 comments

When rails assets:precompile fails in a github actions CI pipeline, the build continues without raising a build error. This caused some broken code to sneak in to our prod instance this morning.

Does anyone have any ideas how to trigger an error where it will stop the CI build? The output below is printed out, but the CI build continues

Example:

doppler run -- bundle exec rails assets:precompile --trace
  shell: /usr/bin/bash -e {0}
  env:
    CI: true
    RAILS_ENV: test
    DOPPLER_TOKEN: dp.st.test_ci.t1B[4](https://github.com/**/**/runs/5294624544?check_suite_focus=true#step:17:4)eRvzwX0erbADmC6aasdfg[5](https://github.com/**/**/runs/5294624544?check_suite_focus=true#step:17:5)IjeVkehjiKHJETg
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke css:build (first_time)
** Execute css:build
yarn install v1.22.17
[1/4] Resolving packages...
success Already up-to-date.
$ [ ! -d ".git" ] && exit 0; husky install
husky - Git hooks installed
Done in 0.78s.
yarn run v1.22.17
$ yarn run build:tailwind & yarn run build:sass
$ tailwindcss -i ./app/assets/stylesheets/v2.css -o ./app/assets/builds/v2.css
$ sass ./app/assets/stylesheets/v1.sass.scss ./app/assets/builds/v1.css --load-path=node_modules --embed-sources
Done in 2.05s.
** Invoke javascript:build (first_time)
** Execute javascript:build
yarn install v1.22.17
[1/4] Resolving packages...
Done in 1715ms.
success Already up-to-date.
$ [ ! -d ".git" ] && exit 0; husky install
husky - Git hooks installed
Done in 1.10s.
yarn run v1.22.17
$ esbuild app/frontend/*.* --bundle --sourcemap --outdir=app/assets/builds --loader:.svg=text
 > app/frontend/app/hooks/index.js:[6](https://github.com/**/**/runs/5294624544?check_suite_focus=true#step:17:6):[9](https://github.com/**/**/runs/5294624544?check_suite_focus=true#step:17:9): error: Expected ";" but found "here"
    6 │ putatypo here!!
      ╵          ~~~~
1 error
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
** Execute assets:precompile
tgaff commented

Is it possible this is fixed now, or was an issue with the build script?
I just tried to reproduce this and could not. The assets:precompile task had an exit code of 1 for "bad" JS.