dwyl / smart-home-firmware

Firmware for dwyl/smart-home-security-system
GNU General Public License v3.0
4 stars 0 forks source link

Running a background process in CI #15

Closed th0mas closed 4 years ago

th0mas commented 4 years ago

For our integration tests, we need to run a background process in our CI provider - currently Travis.

We're currently doing this through

mix phx.server&
SERVER_PID=$!

Which starts the server process and assigns an environment variable to the PID.

However, we can't view logs with this method which is tripping us up in #13.

We need to figure out a way of running a background process on a CI provider that allows us to test against our hub server.

th0mas commented 4 years ago

Circle CI seems to let you run multiple containers to test against: https://circleci.com/blog/setting-up-tricky-containers-in-circle-2-0-multi-image/

nelsonic commented 4 years ago

@th0mas yeah, just because you can use multiple Docker Containers, doesn't mean you want to. 😉 We have used Docker in the past and it can become another maintenance chore. ⏳ If we do not plan to deploy our App(s) using Docker, we should not be using it in our build phase.

As discussed on our Standup call I think we could independently deploy the Hub App to Heroku and use that in testing the firmware. Though it might incur some network latency, that may result in slower test execution. 💭 Given that Elixir executes tests in parallel, the "cost" of doing this will be the slowest test i.e. max 2 seconds. While it might sound like more work to deploy the Hub App to Heroku and then use the deployed app for testing the firmware, it will end up being less of a headache and it will cut down on the build times in both the short and long-run because there won't be any extra git clone or mix deps.get to run.

I can set-up a separate Heroku account to run the Hub app to ensure that we never run out of "free" dyno hours then "ping" the app to wake it at the start of the tests so the dyno is primed. That way we have full Application logs for the Hub and can debug anything.

This is what I've done to test https://github.com/dwyl/auth which calls out to https://dwylmail.herokuapp.com/ in CI. Some people may consider this to be "coupling" and even an "anti-pattern". I respectfully disagree with those idealists, this is how Apps work in the "real world", they call other microservices/APIs and if something fails we need to know.

LMK what you think/decide. I'm happy to do the Heroku work so you don't have to. (obvs I will share the access with you so can debug it if you need to ...)

th0mas commented 4 years ago

Closing for now as we have technically cheated and run our testing hub server on heroku, see dwyl/smart-home-auth-server#14