【问题标题】:pytest not found when running from a conda environment in GitHub Actions从 GitHub Actions 中的 conda 环境运行时找不到 pytest
【发布时间】:2020-12-14 23:39:06
【问题描述】:

我正在尝试使用 GitHub Actions 测试我的包,该包在 conda 环境中运行。在本地一切正常。但是在 GitHub Actions 上,它显示 pytest: command not foundthis 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

在运行pytest 之前,我尝试从conda 环境和instead running pip install pytest 中删除pytest,但这给出了不同的错误:error: invalid command 'bdist_wheel'

【问题讨论】:

    标签: python pytest conda github-actions


    【解决方案1】:

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

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

    【讨论】:

    • 像魅力一样工作,但也需要在安装步骤中出现,对我来说不是这样。谢谢!
    猜你喜欢
    • 2020-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-18
    • 2020-03-03
    • 1970-01-01
    • 1970-01-01
    • 2020-07-21
    相关资源
    最近更新 更多