allure-framework / allure-python

Allure integrations for Python test frameworks
https://allurereport.org/
Apache License 2.0
713 stars 233 forks source link

Fix cache issue with the build workflow #810

Closed delatrie closed 2 months ago

delatrie commented 2 months ago

Context

Starting from version 69.3.0, Setuptools canonicalizes filenames of a source distribution according to PEP 625. Notably, all hyphens (-) are replaced with underscores (_) in the distribution name.

That leads to the following error when installing previously built common packages during a testing job of the build workflow:

Run pip install dist/allure-python-commons*.tar.gz \
WARNING: Requirement 'dist/allure-python-commons*.tar.gz' looks like a filename, but the file does not exist
Processing ./dist/allure-python-commons*.tar.gz
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/home/runner/work/allure-python/allure-python/dist/allure-python-commons*.tar.gz'

If we run ls dist before pip install, we see the following content:

allure_python_commons-0.1.dev1+g2070930-py3-none-any.whl
allure_python_commons-0.1.dev1+g2070930.tar.gz
allure_python_commons_test-0.1.dev1+g2070930-py3-none-any.whl
allure_python_commons_test-0.1.dev1+g2070930.tar.gz

Although a simple fix of the pip install command would be enough, I've decided to eliminate caching altogether and replace it with direct installation from the corresponding directory. The caching doesn't save us anything:

PS > python -m venv env && ./env/bin/Activate.ps1 &&  measure-command { pip install ./dist/allure_python_commons-2.13.6.dev1+gf185ccc.tar.gz }

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 11
Milliseconds      : 705
Ticks             : 117050592
TotalDays         : 0.000135475222222222
TotalHours        : 0.00325140533333333
TotalMinutes      : 0.19508432
TotalSeconds      : 11.7050592
TotalMilliseconds : 11705.0592

PS > rm -rf env && python -m venv env && ./env/bin/Activate.ps1 && measure-command { pip install ./allure-python-commons }

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 10
Milliseconds      : 378
Ticks             : 103782877
TotalDays         : 0.000120119070601852
TotalHours        : 0.00288285769444444
TotalMinutes      : 0.172971461666667
TotalSeconds      : 10.3782877
TotalMilliseconds : 10378.2877

In fact, it only makes the build longer and more complicated.