首页 > 解决方案 > 从 GitHub Actions 中的 conda 环境运行时找不到 pytest

问题描述

我正在尝试使用 GitHub Actions 测试我的包,该包在conda环境中运行。在本地一切正常。但是在 GitHub Actions 上,它pytest: command not found这个工作流文件说:

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

我尝试pytestconda环境中删除,而是在运行 pip install pytest之前运行pytest,但这给出了不同的错误:error: invalid command 'bdist_wheel'.

标签: pythonpytestcondagithub-actions

解决方案


您需要指定shell,如Build步骤中所示:

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

推荐阅读