I'm trying to install requirements in a build step and run tests on circleci. I run into a permission denied problem when running the pip install because it tries to install the requirements globally. I could install the requirements on a user level, but using virtualenv also works:
version: 2
defaults: &defaults
docker:
- image: circleci/python:3.6
jobs:
build_dataloader:
<<: *defaults
working_directory: ~/app/dataloader
steps:
- checkout:
path: ~/app
- run:
name: Install requirements
command: |
virtualenv env
source env/bin/activate
pip install -r requirements.txt
dataloader_tests:
<<: *defaults
parallelism: 2
steps:
- checkout:
path: ~/app
- run:
name: Running dataloader tests
command: |
cd ~/app/dataloader
python3 -m unittest discover tests/unit/
- store_artifacts:
path: test-reports/
destination: app_tests
workflows:
version: 2
run_tests:
jobs:
- build_dataloader
- dataloader_tests:
requires:
- build_dataloader
Is there any way to put the virtualenv in a separate step? This does not work when I put the virtualenv part in a separate step:
version: 2
defaults: &defaults
docker:
- image: circleci/python:3.6
jobs:
build_dataloader:
<<: *defaults
working_directory: ~/app/dataloader
steps:
- checkout:
path: ~/app
- run:
name: Setup virtualenv
command: |
virtualenv env
source env/bin/activate
- run:
name: Install requirements
command: |
pip install -r requirements.txt
dataloader_tests:
<<: *defaults
parallelism: 2
steps:
- checkout:
path: ~/app
- run:
name: Running dataloader tests
command: |
cd ~/app/dataloader
python3 -m unittest discover tests/unit/
- store_artifacts:
path: test-reports/
destination: app_tests
workflows:
version: 2
run_tests:
jobs:
- build_dataloader
- dataloader_tests:
requires:
- build_dataloader
Why does this fail? Shouldn't it create the virtual env if I put it in a separate step?