我试图在托管构建代理中运行以下azure-管线. run文件。
- task: UsePythonVersion@0
inputs:
versionSpec: $(pythonVersion)
displayName: 'Use Python 3.10.8'
- script: |
export POETRY_VERSION=$(poetryVersion)
curl -sSL https://install.python-poetry.org | python -
echo "##vso[task.setvariable variable=PATH]${PATH}:$HOME/.local/bin"
displayName: 'Install poetry'
- ${{ if eq(parameters.usePoetryCache, true) }}:
- task: Cache@2
inputs:
key: 'poetry | "$(Agent.OS)" | poetry.lock'
# restoreKeys: |
# poetry | "$(Agent.OS)"
# poetry
path: $(venv)
cacheHitVar: POETRY_CAHCE_RESTORED
- script: |
poetry config virtualenvs.in-project true
poetry config virtualenvs.path $(venv)
displayName: Configure Poetry
- script: |
poetry install
displayName: Install dependencies
condition: eq(variables.POETRY_CAHCE_RESTORED, 'false')
- script: |
poetry show coverage
displayName: Check coverage installation
- script: |
poetry run coverage run -m pytest && poetry run coverage xml -o ${{ parameters.workingDirectory }}/${{ parameters.testResultsDir }}/coverage.xml
displayName: Run tests & code coverage # THIS FAILS
我不明白为什么缓存步骤成功,但是poetry run
失败了。只有在使用缓存时才会发生这种情况。如果每次跳过缓存和安装依赖项,它就能工作。
记录每一步的日志:
缓存@2
Resolving key:
- poetry [string]
- "Linux" [string]
- poetry.lock [file] --> 7AFBEE979DA4396BFE2D0AEF57A0A6A210629F38EFE50786DF26B396ECD935E0
Resolved to: poetry|"Linux"|VHTXv4eVo2iEXIULm/6DKwpSuYJEqaI86WbrPgZ3/T4=
Using default max parallelism.
Max dedup parallelism: 192
Getting a pipeline cache artifact with one of the following fingerprints:
Fingerprint: `poetry|"Linux"|VHTXv4eVo2iEXIULm/6DKwpSuYJEqaI86WbrPgZ3/T4=`
There is a cache hit: `poetry|"Linux"|VHTXv4eVo2iEXIULm/6DKwpSuYJEqaI86WbrPgZ3/T4=`
Used scope: 3012;5b97d788-43ec-45d8-836e-eaa18049b8fb;refs/heads/feature/pipeline-work;ff191ef6-ebfd-4d63-9d61-e7d1f8ceaf65
Entry found at fingerprint: `poetry|"Linux"|VHTXv4eVo2iEXIULm/6DKwpSuYJEqaI86WbrPgZ3/T4=`
Expected size to be downloaded: 121.7 MB
Downloaded 0.0 MB out of 121.7 MB (0%).
Downloaded 121.7 MB out of 121.7 MB (100%).
Download statistics:
Total Content: 121.7 MB
Physical Content Downloaded: 48.8 MB
Compression Saved: 72.9 MB
Local Caching Saved: 0.0 MB
Chunks Downloaded: 1,483
Nodes Downloaded: 3
显示覆盖安装
name : coverage
version : 6.5.0
description : Code coverage measurement for Python
dependencies
- tomli *
覆盖范围
poetry run coverage run -m pytest && poetry run coverage xml -o /agent/_work/22/s/TestResults/coverage.xml
========================== Starting Command Output ===========================
/bin/bash --noprofile --norc /agent/_work/_temp/XXXXXXXXXXXXXXXXXX.sh
Command not found: coverage
##[error]Bash exited with code '1'.
Finishing: Run tests & code coverage
发布于 2022-11-24 08:25:17
请检查$(venv)
在缓存任务中的路径值,我在下面的示例yaml中使用了/home/vsts/.virtualenvs
。它在我这边起作用。
trigger: none
parameters:
- name: usePoetryCache
type: string
default: true
pool:
vmImage: ubuntu-latest
strategy:
matrix:
Python36:
python.version: '3.10'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
- script: |
curl -sSL https://install.python-poetry.org | python -
echo "##vso[task.setvariable variable=PATH]${PATH}:$HOME/.local/bin"
displayName: 'Install poetry'
- ${{ if eq(parameters.usePoetryCache, true) }}:
- task: Cache@2
inputs:
key: 'poetry | "$(Agent.OS)"'
# restoreKeys: |
# poetry | "$(Agent.OS)"
# poetry
path: $(venv)
cacheHitVar: POETRY_CAHCE_RESTORED
- script: |
poetry config virtualenvs.in-project true
poetry config virtualenvs.path $(venv)
poetry lock
displayName: Configure Poetry
- script: |
poetry install
displayName: Install dependencies
condition: eq(variables.POETRY_CAHCE_RESTORED, 'false')
- script: |
poetry show coverage
displayName: Check coverage installation
- script: |
poetry run coverage run -m pytest
displayName: Run tests & code coverage
https://stackoverflow.com/questions/74555593
复制相似问题