ietf-ribose / bibxml-service

Django-based Web service implementing IETF BibXML APIs
BSD 3-Clause "New" or "Revised" License
6 stars 4 forks source link

Running tests locally requires online connection #14

Closed strogonoff closed 2 years ago

strogonoff commented 2 years ago

Describe the issue

It seems like accessing Codecov is required for tests to work.

We don’t want two different commands for running tests locally vs. CI, but we also don’t want to require a connection if a developer runs tests locally. Perhaps there’s an easy way to make tests run locally without talking to Codecov?

Code of Conduct

stefanomunarini commented 2 years ago

Locally, if the containers are up and running, we can use the following command to run the tests:

docker-compose exec web python manage.py test

Is this enough @strogonoff ?

Otherwise we could have a separate docker-compose file for local testing, which would be a copy of the current docker-compose.test.yml, but with a slightly different command, e.g.:

command: sh -c "/wait && python manage.py test"

In this case, we could introduce a base docker-compose.base.test.yml file.

strogonoff commented 2 years ago

We should update the docs and list the command: https://bib.ietf.org/static/docs/howto/run-tests.html

Maybe we can override the test CMD via CLI flag without creating a separate Compose file🤔

stefanomunarini commented 2 years ago

I haven't found anything about overriding the test CMD via CLI flag. @strogonoff


However, I found out that, when specifying multiple docker-compose files (using the -f flag), "Compose combines them into a single configuration"[1] and we can "override and add to their predecessors"[1].

An option, here, is to have an additional docker-compose.test-local.yml file that overrides the command of the docker-compose.test.yml file.

The new docker-compose.test-local.yml will look like:

version: "3.9"

  test:
    command: sh -c "/wait && python manage.py test"

Tests can then be run with the following commands:

docker compose -f docker-compose.test.yml up --exit-code-from test
docker compose -f docker-compose.test.yml -f docker-compose.test-local.yml up --exit-code-from test

[1] https://docs.docker.com/compose/reference/#specifying-multiple-compose-files