Running tests at circleci in conda environment
I use conda, and and trying to figure out how to get things running at circleci. I have a very simple project in an environment called
calculator with two functions (one
subtraction and one test for each). I am using
pylint8 to check the formatting, and
pytest-cov for testing/coverage.
My configuration file is as follows, which seems to be working until I reach the test-running stage:
# Python CircleCI 2.0 configuration file version: 2 jobs: build: docker: - image: continuumio/miniconda3 working_directory: ~/repo steps: # Step 1: obtain repo from GitHub - checkout # Step 2: create virtual env and install dependencies - run: name: install dependencies command: | conda env create -f environment.yml # Step 3: run linter and tests - run: name: run tests command: | conda init bash conda activate calculator flake8 --statistics pytest -v --cov
Steps 1 and 2 work ok, but Step 3 gives a fail with the following message:
#!/bin/bash -eo pipefail conda init bash conda activate calculator flake8 --statistics pytest -v --cov no change /opt/conda/condabin/conda no change /opt/conda/bin/conda no change /opt/conda/bin/conda-env no change /opt/conda/bin/activate no change /opt/conda/bin/deactivate no change /opt/conda/etc/profile.d/conda.sh no change /opt/conda/etc/fish/conf.d/conda.fish no change /opt/conda/shell/condabin/Conda.psm1 no change /opt/conda/shell/condabin/conda-hook.ps1 no change /opt/conda/lib/python3.7/site-packages/xontrib/conda.xsh no change /opt/conda/etc/profile.d/conda.csh modified /root/.bashrc ==> For changes to take effect, close and re-open your current shell. <== CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. To initialize your shell, run $ conda init <SHELL_NAME> Currently supported shells are: - bash - fish - tcsh - xonsh - zsh - powershell
I am in Ubuntu 18. I previously wasn't running
conda init bash, but based on the error, I put it in there, but it is still suggesting I initialize my shell even though I already did this.
conda init bashchanges your
.bashrcwhich then would have to be reloaded.
You could try it in this order
conda init bash source ~/.bashrc conda activate calculator
or simply try the old fashioned way of
source activate calculator(without running
conda init bashat all).