Github provides since august 2019 a new way to orchestrate any workflow, based on any event : Github Actions. A lot of developers migrates to this for their CI, because it’s (almost) free and fully integrated with github (no need to register to a new service for CI !).
You can find an example of a working CI configuration here (this example use some caching, rubocop and brakeman).
One day, my CI stopped working : I had some js features tests which failed ( but not on my computer ). I was like “ Damn, remote debugging headless chrome tests seems to be pretty hard 😬”.
And yes, it was not an easy process 🙄… that’s why I wrote this post today.
Finding a tool to reproduce the fail scenario
In my computer, failing tests are green, so I have to find a way to reproduce it.
I find a tool named act, which seems
to be a great fit for my needs : it uses Docker (like Github Actions) and read
Github Actions configuration files in
.github/workflows to reproduce the exact
behaviour of github actions.
However, I had multiple issues with it 😕
- First, I does not resolve tag well, and failed on my second step.
- Second, I had an issue on a env variable which was not set
- And the last one which led me to seek to an another solution :
The (painful) error:
To eliminate this warning, please install libyaml and reinstall your ruby.
My reaction 👇
I gave up and tried something else, which I knew will be more tricky : remote debugging 👾
I found a github action that can create a tmate session on the host system : action-tmate
All you have to do it’s to put the step just before the rspec step, push on github, and connect to a ssh session.
When you open the action, you’ll see the information to connect to this session:
FYI, It will loop until you (or Github) decide to stop the container.
In my case, I had to see what’s going on my headless browser. Thanks to apparition, it’s possible to takes screenshots, so I put this line just before one of my failing assertion:
All I need to do is to connect to the remote session, run the failing test
and get the screenshot (thanks to transfer.sh,
rsync does not work on tmate.io)
Here is my remote screenshot 👇
On this test, one of my
perform_some_actions is to toggle the content by
clicking on the element (example below, same screenshot but on my computer)
Clearly the action of toggling the content does not work on the CI.
My clicking action from my capybara test:
And my actual DOM:
I suspect that
Capybara tries to click on the div, but not on the 2 last divs which triggers
the actual toggle (divs with
I tried to harden my clicking action by targetting the exact div like this:
I pushed on my debugging branch to trigger the build with my tmate action enabled (in order to run this test exactly) and guess what : it worked 🙌🎉
- act seems promising, I’ll definitely watch the evolution (be able to debug actions in local is definitely a nice to have!)
- Take screenshots and upload them in order to inspect exactly what’s happen on your remote session, transfer.sh is a great tool for this
Have a pleasant day 🙃