I’m new to CircleCI. I have a flask app running locally. The tests run succesfully with the following code:
docker-compose up -d docker-compose run flask bash -c "export FLASK_APP=app; flask test"
Now, I would like to run the same code using CircleCI. Here’s my
version: 2 jobs: build: docker: - image: circleci/python:3.6.8 steps: - checkout - run: name: Setup Docker Compose command: | curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose chmod +x ~/docker-compose sudo mv ~/docker-compose /usr/local/bin/docker-compose - setup_remote_docker - run: name: Run Tests command: | set -x docker-compose up -d docker-compose run flask bash -c "export FLASK_APP=app; flask test"
This is giving me the error:
No such command "test".
This means that within the Circle CI Docker container, my flask app with the test function implemented is not found. This seems very strange to me, as what’s inside the Docker container should be the same for both my local environment and the Circle CI environment (that’s the whole point of Docker!).
Am I missing something in
config.yml? Am I doing something wrong here?
test function is defined in
__init__.py of the app as follows:
@app.cli.command() @click.argument('test_file', required=False) def test(test_file=None): """ Runs the unit tests without generating a coverage report. Enter 'docker-compose run --rm flask python manage.py test' to run all the tests in the 'tests' directory, with no coverage report. :return int: 0 if all tests pass, 1 if not """ if test_file: pattern = test_file + '.py' else: pattern = 'test*.py' tests = unittest.TestLoader().discover('checks_api/tests/unit', pattern=pattern) result = unittest.TextTestRunner(verbosity=2).run(tests) if result.wasSuccessful(): return 0 else: return 1