Hello there,
I am trying to create a circleCI YAML file for our data-platform.
this is how the basic structure of our repo currently looks like -
data-platform/.circleci/config.yml
data-platform/database_jobs/{all the python feed files}
data-platform/database_jobs/tests/{all the python feed-test files}
feed-test files use pytest for unit-tests
and from my basic understanding of config.yml
I came up with this -
version: 2
jobs:
build:
docker:
- image: circleci/python:2.7.14-jessie
environment:
TEST_DATABASE_URL: postgresql://root@localhost/circle_test?sslmode=disable
- image: circleci/postgres:9.6.5-alpine-ram
environment:
POSTGRES_USER: root
POSTGRES_DB: circle_test
POSTGRES_PASSWORD: ""
steps:
- checkout
- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "database_jobs/requirements.txt" }}
- run:
name: Install Python dependencies in a venv
command: |
virtualenv venv
. venv/bin/activate
pip install -r database_jobs/requirements.txt
- save_cache:
key: deps1-{{ .Branch }}-{{ checksum "database_jobs/requirements.txt" }}
paths:
- venv
test:
docker:
- image: circleci/python:2.7.14-jessie
steps:
- checkout
- run:
name: Runnning tests
command: |
. venv/bin/activate
py.test -vv database_jobs/tests
workflows:
version: 2
build_and_test:
jobs:
- build
- test
Questions:
- how to use pytest for testing all the test files located in
data-platform/database_jobs/tests/
? - I have tests that rely on database connections. Do I have to create a circleCI image for testing postgres database OR I will have to create my own database instance on the server(AWS) for running tests?
Error I am getting when trying to run the tests, also it’s not letting me activate my virtual environment:
#!/bin/bash -eo pipefail
. venv/bin/activate
py.test -vv database_jobs/tests
/bin/bash: venv/bin/activate: No such file or directory
Exited with code 1