muety / wakapi

📊 A minimalist, self-hosted WakaTime-compatible backend for coding statistics
https://wakapi.dev
MIT License
2.56k stars 158 forks source link

Run mail tests in CI #658

Closed muety closed 2 months ago

muety commented 2 months ago

In https://github.com/muety/wakapi/commit/a5565b12ea11f0ef62214eb43a60b0b24c37a864 I added integration tests for SMTP mail sending using smtp4dev. Tests are run as part of the standard test suite, but are skipped silently if no smtp4dev endpoint is available. Running the tests requires to bring up a Docker container for smtp4dev, which is why currently these tests can only be run manually for simplicity. However, SMTP tests should be configured as part of the GHA workflow, too. Should be quite straightforward and similar to how we run the API tests against different DBs (running in Docker). Perhaps something for you, @YC?

YC commented 2 months ago

Hi @muety, a test seems to be consistently failing. https://github.com/muety/wakapi/actions/runs/9889197240/job/27314711747

There is possibly a race condition, in that the container may not be ready before the tests are executed. With sleep 2 locally, I get the same error as in CI. Without sleep locally:

Running tests ...
ok      github.com/muety/wakapi/services/mail   0.340s
muety commented 2 months ago

Wow, that was quick!

I noticed that the container takes a bit to reload its configuration. Perhaps adding a longer wait time after requesting a settings change (see here) would help?