YML 如何指定python 3.10

问题描述 投票:0回答:1

我想开始对我的代码进行矩阵测试。我尝试使用下面的 yml 在 Azure Devops 管道上运行单元测试。

当我运行它时,它会将“3.10”缩短为“3.1”。我该如何避免这种情况? enter image description here

parameters:
  - name: imageList
    type: object
    default: ["windows-latest", "ubuntu-latest", "windows-2019", "ubuntu-20.04"]
  - name: pythonList
    type: object
    default:
      - "3.11"
      - "3.10" # WHAT TO DO HERE
      - "3.9"

stages:
  - stage: test_on_microsoft_hosted_agents
    jobs:
      - ${{ each image in parameters.imageList }}:
        - job: ${{ replace(replace(image, '-', '_'), '.', '_') }}
          pool:
            vmImage: ${{ image }}
          strategy:
            maxParallel: 1
            matrix:
              ${{ each python in parameters.pythonList }}:
                Python${{ replace(python, '.', '') }}:
                  python.version: "${{ python }}"
                  platform.name: "${{ image }}"
          steps:
            - task: UsePythonVersion@0
              inputs:
                versionSpec: "$(python.version)"
              displayName: "Use Python $(python.version)"
azure-devops yaml azure-pipelines
1个回答
0
投票

尝试使用格式函数指定以确保版本字符串保持完整

parameters:
  - name: imageList
    type: object
    default: ["windows-latest", "ubuntu-latest", "windows-2019", "ubuntu-20.04"]
  - name: pythonList
    type: object
    default:
      - "3.11"
      - "3.10"
      - "3.9"

stages:
  - stage: test_on_microsoft_hosted_agents
    jobs:
      - ${{ each image in parameters.imageList }}:
        - job: ${{ replace(replace(image, '-', '_'), '.', '_') }}
          pool:
            vmImage: ${{ image }}
          strategy:
            maxParallel: 1
            matrix:
              ${{ each python in parameters.pythonList }}:
                Python${{ format('{0:.2f}', python) | replace('.', '') }}:
                  python.version: "${{ python }}"
                  platform.name: "${{ image }}"
          steps:
            - task: UsePythonVersion@0
              inputs:
                versionSpec: "$(python.version)"
              displayName: "Use Python $(python.version)"
© www.soinside.com 2019 - 2024. All rights reserved.