Appveyor:如何在Windows映像上运行2个作业,而在Linux映像上仅运行1个作业?

时间:2018-10-11 16:01:54

标签: python appveyor

我想在Windows和Ubuntu上测试我的python项目。幸运的是,Appveyor几个月以来都支持这两种系统。

在Windows上,我曾经使用

对32位和64位python配置环境矩阵进行测试
    - PYTHON: "C:\\Python36"
    - PYTHON: "C:\\Python36-x64"

现在,如果我想为Ubuntu运行作业,因为此PYTHON变量使作业数量增加了一倍,我使Ubuntu作业运行两次而不是仅运行一次(此外,从不使用此PYTHON变量,在Ubuntu上没有用)。 appveyor.yml的摘要可解决:

version: build{build}

branches:
  only:
  - master
  - pre-release
  - dev

image:
  - Visual Studio 2015
  - Ubuntu1804

max_jobs: 1

environment:
  matrix:
    # For Python versions available on Appveyor, see
    # https://www.appveyor.com/docs/windows-images-software/#python
    # https://www.appveyor.com/docs/linux-images-software#python
    - PYTHON: "C:\\Python36"
    - PYTHON: "C:\\Python36-x64"

install:
  # We need wheel installed to build wheels
  - cmd: "%PYTHON%\\python.exe -m pip install wheel pytest"
  - sh: "pip install wheel pytest"

build: off

test_script:
  # Note that you must use the environment variable %PYTHON% to refer to
  # the interpreter you're using - Appveyor does not do anything special
  # to put the Python version you want to use on PATH.
  - cmd: "%PYTHON%\\python.exe setup.py test"
  - sh: "python setup.py test"

我已经在文档中看到了多种可能性,可以使用for:exclude之类的关键字来排除某些部分的运行,但无法弄清楚如何正确使用它们。

那么,有没有办法仍然运行两个Windows作业和一个Ubuntu工作?

(作为一种解决方法,我可以删除32位python测试,但这并不是一个很令人满意的技巧)。

1 个答案:

答案 0 :(得分:1)

确定它是可行的,请检查文档的this部分。在您的情况下,您可以摆脱image部分,并像这样设置矩阵:

environment:
  matrix:
    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
      PYTHON: "C:\\Python36"
    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
      PYTHON: "C:\\Python36-x64"
    - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu1804