git-gurus-itu-devops / itu-minitwit

0 stars 0 forks source link

Fix non-idempotent GitHub Actions #37

Closed A-Guldborg closed 7 months ago

A-Guldborg commented 7 months ago

Fixes #30

Current status is this workflow

After database and minitwit seems to be running correctly, it fails with error message:

dependency failed to start: container minitwit is unhealthy

This PR should fix the fact that our tests sometimes fails if they run before the application is running

I have attempted pointing the health-check to localhost, 0.0.0.0 and minitwit - all with port 5000. Inspiration for healthcheck is this and this article.

Any help is very much appreciated!

duckth commented 7 months ago

Something to note on this:

If we change our tests to use native Ruby testing tools, I don't think we will actually need to run our tests using Docker Compose, but instead, we could just run it right in the action runner. This would practically eliminate this issue, since we don't have to bother with containers waiting to start.

Of course, an argument against this is that with docker-compose tests we test something that looks a bit closer to how the production app works, instead of just running unit tests.

duckth commented 7 months ago

I have added two commits: fcbd9df3c0151d99592a003ae6fee7b950c22a7b - corrects syntax in health check (array syntax) cf3d506e27d362f49f68ae3b5f07f25489445a20 - adds a flag to terminate all the containers of test runner stops (so it doesn't run infinitely) Tests are now green 👍

A-Guldborg commented 7 months ago

See above 2 commits that verifies a failing test (which calls pythons exit(1)) actually fails the workflow. Ready for review :-)