I ran into problems with asset pre-compilation during deploys, so I opted to go for local pre-compilation and check in the resulting files to my source tree. I don't really have any problems with that approach, except that sometimes I forget to run the precompile task and release without precompiling assets! :(
I'm wondering if anyone has come across some sort of way to check to see if any asset changes have occurred? Ideally I'd like to run some sort of check on my CI server and fail the build if there's asset changes that haven't been committed.
I had a couple of thoughts:
Run
RAILS_ENV=production bundle exec rake assets:precompile
on the CI server and see if there's any output. (The command appears to not output anything if assets are up-to-date.) However, it seems as though the command's output is tied somehow to the environment it runs in, because after running the command locally, committing the results, and then running the command on the CI server, there is still output from the command! I'd like to know why this is tied to the environment, but I can't even find the source forrake assets:precompile
in the rails github repo. Does anyone know where the source for that is?Somehow write a command that can look through the git history and determine if any assets have changed within my
assets/
folder since the last precompilation. Not really sure how that would work...
This has bit me more than a couple times, and sometimes I don't catch it when co-workers commit asset changes - plus it really seems like this is something a computer should be able to catch for a human. I guess a somewhat reasonable third alternative would be to have the CI server simply run the command, and commit the generated files to the source tree automatically, but I don't like the idea of my CI server making commits.
Any thoughts? Thanks.