Max Ghenis
Max Ghenis

Reputation: 15803

pytest not found when running from a conda environment in GitHub Actions

I'm trying to test my package with GitHub Actions, where the package runs in a conda environment. It all works fine locally. But on GitHub Actions, it says pytest: command not found with this workflow file:

name: Build and Test [Python 3.6, 3.7]

on: push

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.6, 3.7]

    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          persist-credentials: false

      - name: Setup Miniconda using Python ${{ matrix.python-version }}
        uses: goanpeca/setup-miniconda@v1
        with:
          activate-environment: microdf
          environment-file: environment.yml
          python-version: ${{ matrix.python-version }}
          auto-activate-base: false

      - name: Build
        shell: bash -l {0}
        run: |
          pip install -e .
      - name: Run tests
        run: |
          pytest

I tried removing pytest from the conda environment and instead running pip install pytest before running pytest, but that gave a different error: error: invalid command 'bdist_wheel'.

Upvotes: 5

Views: 1653

Answers (1)

Max Ghenis
Max Ghenis

Reputation: 15803

You need to specify the shell, as in the Build step:

- name: Run tests
  shell: bash -l {0}
  run: pytest

Upvotes: 5

Related Questions