Weeknotes 13
26th September, 2021
“1.3GB of node_modules/ and stress testing CI”
-
Retro-fitting tests is so much more difficult than writing them at the time of the implementation. Writing them afterwards often forces you to change the implementation in order to even test anything, and you (I, dear reader) usually end up with a highly coupled test too, making future changes more difficult. I would ideally like to an integration test to cover the subject under test whilst changing it, but that’s not always possible, as was the case this time, so making the changes feels perilous. I did my best.
-
Debugging failed tests on CI is never fun. It works on my machine has never been more painful. It sucks the life out of me. The slow feedback cycle is a killer having to push small changes and see if they pass. This particular CI was running on GitHub Actions and thankfully I found this neat action called action-tmate on the GitHub Actions Marketplace. It essentially provides you with a shell on the GitHub Actions machine your tests are running on. Much easier to debug. With this in-place I could run tests directly and use a debugger to work out what was going wrong.
-
We got into a position where we couldn’t deploy to our application hosted on Heroku this week 🤦♂️ Our Slug size had gradually been growing but a recent merge of some major JavaScript changes massively increased our bundle sizes and left us in a position where we couldn’t actually deploy any more!
Investigating on Heroku using
heroku run bash
I came across ournode_modules/
directory.$ du -sh .[^.]* * | sort -hr 1.3G node_modules 532M vendor 268M tmp 118M .heroku 95M public 12M app 1.9M spec
Oh, Node.
I did some Googling and found what seemed like a reasonable, easy to implement, approach. We augment the
assets:clean
Rake task that Heroku already call during the deployment process to remove thenode_modules/
directory before the Slug is compressed. This change make the Slug size 264MB smaller than before - an over 50% saving.The deployment should also be faster from now on as the Slug Compiler shouldn’t have to compress 1.3GB of files anymore.
-
Short work week for me this week. We went away to Cornwall for a few days. It’s been ages since I’ve been away properly what with one thing and another. A combination of uncomfortable AirBnB and poor weather meant that we decided to come home early.