-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CI] Run tests against pre-built/installed version of setuptools
#3049
Draft
abravalheri
wants to merge
14
commits into
pypa:main
Choose a base branch
from
abravalheri:isolated-ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5b272c1
Replace in-tree test fixture with per-dir conftest
abravalheri c8e34fe
Avoid depending on the project root in tests
abravalheri c62e0a3
Make sure tests that check sys.modules don't fail
abravalheri 3c83b73
Use venv when testing pkg_resources and old-style namespaces
abravalheri 1b25980
Make tests relocatable
abravalheri 83030cd
Avoid problems with issubclass
abravalheri 4978518
Use temporary module for test_require_present
abravalheri 92d466f
Prevent specific test that relies on source code present
abravalheri 611e175
Add a CI Pipeline that uses `tox --installpkg` to test as installed
abravalheri a3edb61
Add temporary workaround for pytest-perf
abravalheri c825944
Temporarily disable CI fail fast
abravalheri f2c6eed
Skip pytest-perf on PyPy with local distutils
abravalheri e266be8
Use latest development version of pytest-perf
abravalheri 4b5baaa
Allow codecov to correctly find file paths
abravalheri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
[run] | ||
source_pkgs = | ||
setuptools | ||
pkg_resources | ||
omit = | ||
# leading `*/` for pytest-dev/pytest-cov#456 | ||
*/.tox/* | ||
*/_vendor/* | ||
*/_distutils/* | ||
*/tests/* | ||
*/test_*/* | ||
*/pip-run-*/* | ||
*/pip-build*/* | ||
*/pip-req-build*/* | ||
*/pip-standalone*/* | ||
/tmp/easy_install*/* | ||
/tmp/tmp*/setup.py | ||
|
||
[paths] | ||
setuptools = | ||
setuptools/ | ||
*/site-packages/setuptools/ | ||
*/pip-install-*/setuptools_*/setuptools/ | ||
*/tmp*/setuptools | ||
pkg_resources = | ||
pkg_resources/ | ||
*/site-packages/pkg_resources/ | ||
*/pip-install-*/setuptools_*/pkg_resources/ | ||
*/tmp*/pkg_resources | ||
|
||
[report] | ||
show_missing = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[run] | ||
source_pkgs = | ||
setuptools | ||
pkg_resources | ||
omit = | ||
# leading `*/` for pytest-dev/pytest-cov#456 | ||
*/_vendor/* | ||
*/_distutils/* | ||
*/tests/* | ||
*/test_* | ||
|
||
[paths] | ||
setuptools = | ||
src/setuptools/ | ||
*/site-packages/setuptools/ | ||
*/pip-install-*/setuptools_*/setuptools/ | ||
*/tmp*/setuptools | ||
pkg_resources = | ||
src/pkg_resources/ | ||
*/site-packages/pkg_resources/ | ||
*/pip-install-*/setuptools_*/pkg_resources/ | ||
*/tmp*/pkg_resources | ||
|
||
[report] | ||
show_missing = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,8 +3,74 @@ name: tests | |||||
on: [push, pull_request, workflow_dispatch] | ||||||
|
||||||
jobs: | ||||||
prepare: | ||||||
runs-on: ubuntu-latest | ||||||
outputs: | ||||||
python-version-for-build: ${{ steps.python-version-for-build.outputs.version }} | ||||||
wheel-distribution: ${{ steps.wheel-distribution.outputs.path }} | ||||||
sdist-distribution: ${{ steps.sdist-distribution.outputs.path }} | ||||||
|
||||||
steps: | ||||||
- name: Set Python version for build step | ||||||
id: python-version-for-build | ||||||
run: echo "::set-output name=version::3.10" # <- Python version used for build release | ||||||
- uses: actions/checkout@v2 | ||||||
- name: Setup Python | ||||||
uses: actions/setup-python@v2 | ||||||
with: | ||||||
python-version: ${{ steps.python-version-for-build.outputs.version }} | ||||||
- name: Install tox | ||||||
run: python -m pip install tox | ||||||
- name: Lint code | ||||||
run: python -m tox -e lint | ||||||
- name: Build distribution files | ||||||
run: python -m tox -e build | ||||||
- name: Record the path of wheel distribution | ||||||
id: wheel-distribution | ||||||
run: | | ||||||
echo "::set-output name=path::$(ls dist/*.whl)" | ||||||
- name: Record the path of sdist distribution | ||||||
id: sdist-distribution | ||||||
run: | | ||||||
echo "::set-output name=path::$(ls dist/*.tar.gz)" | ||||||
- name: Store the distribution files for use in other stages | ||||||
uses: actions/upload-artifact@v2 | ||||||
with: | ||||||
name: python-distribution-files | ||||||
path: | | ||||||
${{ steps.wheel-distribution.outputs.path }} | ||||||
${{ steps.sdist-distribution.outputs.path }} | ||||||
retention-days: 2 | ||||||
- name: Debug pipeline stage output | ||||||
run: | | ||||||
echo python-version-for-build = ${{ steps.python-version-for-build.outputs.version }} | ||||||
echo wheel-distribution = ${{ steps.wheel-distribution.outputs.path }} | ||||||
echo sdist-distribution = ${{ steps.sdist-distribution.outputs.path }} | ||||||
|
||||||
develop-test: | ||||||
# Make sure `setuptools` can be installed in editable mode | ||||||
# and tests also run as they would do in the developer's machine | ||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- uses: actions/checkout@v2 | ||||||
- name: Setup Python | ||||||
uses: actions/setup-python@v2 | ||||||
with: | ||||||
# Use a release that is not very new but still have a long life: | ||||||
python-version: "3.8" | ||||||
- name: Ensure setuptools can be installed in editable mode | ||||||
run: | | ||||||
python -m pip install -e . | ||||||
- name: Install tox | ||||||
run: | | ||||||
python -m pip install tox | ||||||
- name: Run tests | ||||||
run: python -m tox -- --cov-report xml --cov-report term | ||||||
|
||||||
test: | ||||||
needs: prepare | ||||||
strategy: | ||||||
fail-fast: false | ||||||
matrix: | ||||||
distutils: | ||||||
- stdlib | ||||||
|
@@ -22,6 +88,8 @@ jobs: | |||||
runs-on: ${{ matrix.platform }} | ||||||
env: | ||||||
SETUPTOOLS_USE_DISTUTILS: ${{ matrix.distutils }} | ||||||
PRE_BUILT_SETUPTOOLS_WHEEL: ${{ needs.prepare.outputs.wheel-distribution }} | ||||||
PRE_BUILT_SETUPTOOLS_SDIST: ${{ needs.prepare.outputs.sdist-distribution }} | ||||||
steps: | ||||||
- uses: actions/checkout@v2 | ||||||
- name: Setup Python | ||||||
|
@@ -31,17 +99,44 @@ jobs: | |||||
- name: Install tox | ||||||
run: | | ||||||
python -m pip install tox | ||||||
- name: Isolate tests to avoid PYTHONPATH interference | ||||||
run: | | ||||||
# Avoid problems with import paths, see #2318, #3015: | ||||||
# `mkdir` `git rm` and `git mv` are OS-independent commands | ||||||
git mv setuptools/tests test_setuptools | ||||||
git mv pkg_resources/tests test_pkg_resources | ||||||
# Prevent local directories to take precedence over installed packages: | ||||||
mkdir src | ||||||
git mv _distutils_hack src | ||||||
git mv setuptools src | ||||||
git mv pkg_resources src | ||||||
- name: Retrieve pre-built distribution files | ||||||
uses: actions/download-artifact@v2 | ||||||
with: | ||||||
name: python-distribution-files | ||||||
path: dist/ | ||||||
- name: Skip some Pytest plugins on PyPy | ||||||
if: contains(matrix.python, 'pypy') && matrix.distutils == 'local' && matrix.platform != 'windows-latest' | ||||||
# PyPy 3.7 imports `distutils` in its `sysconfig`, which would trigger | ||||||
# `_distutils_hack` and potentially mess imports for `pep517` (used by some plugins) | ||||||
# https://foss.heptapod.net/pypy/pypy/-/blob/8301595a71447bbe58bb61c5ecd83d93cfda5eb0/lib-python/3/sysconfig.py#L461-473 | ||||||
# https://foss.heptapod.net/pypy/pypy/-/blob/8301595a71447bbe58bb61c5ecd83d93cfda5eb0/lib_pypy/_sysconfigdata.py#L5 | ||||||
# https://github.com/pypa/pep517/blob/a942316305395f8f757f210e2b16f738af73f8b8/pep517/in_process/_in_process.py#L76-L86 | ||||||
run: echo 'PYTEST_ADDOPTS=-p no:perf' >> $GITHUB_ENV | ||||||
- name: Run tests | ||||||
run: tox -- --cov-report xml | ||||||
run: >- | ||||||
python -m tox | ||||||
--installpkg '${{ needs.prepare.outputs.wheel-distribution }}' | ||||||
-- --cov-report xml --cov-report term --cov-config .coveragerc.ci | ||||||
- name: Publish coverage | ||||||
if: false # disabled for #2727 | ||||||
uses: codecov/codecov-action@v1 | ||||||
with: | ||||||
flags: >- # Mark which lines are covered by which envs | ||||||
${{ runner.os }}, | ||||||
${{ matrix.python }} | ||||||
|
||||||
test_cygwin: | ||||||
needs: prepare | ||||||
strategy: | ||||||
matrix: | ||||||
distutils: | ||||||
|
@@ -50,6 +145,8 @@ jobs: | |||||
runs-on: windows-latest | ||||||
env: | ||||||
SETUPTOOLS_USE_DISTUTILS: ${{ matrix.distutils }} | ||||||
PRE_BUILT_SETUPTOOLS_WHEEL: ${{ needs.prepare.outputs.wheel-distribution }} | ||||||
PRE_BUILT_SETUPTOOLS_SDIST: ${{ needs.prepare.outputs.sdist-distribution }} | ||||||
steps: | ||||||
- uses: actions/checkout@v2 | ||||||
- name: Install Cygwin with Python | ||||||
|
@@ -66,18 +163,43 @@ jobs: | |||||
shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -leo pipefail -o igncr {0} | ||||||
run: | | ||||||
python3.8 -m pip install tox | ||||||
- name: Run tests | ||||||
- name: Isolate tests to avoid PYTHONPATH interference | ||||||
shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -leo pipefail -o igncr {0} | ||||||
run: | | ||||||
tox -- --cov-report xml | ||||||
# Avoid problems with import paths, see #2318, #3015: | ||||||
# `mkdir` `git rm` and `git mv` are OS-independent commands | ||||||
git mv setuptools/tests test_setuptools | ||||||
git mv pkg_resources/tests test_pkg_resources | ||||||
# Prevent local directories to take precedence over installed packages: | ||||||
mkdir src | ||||||
git mv _distutils_hack src | ||||||
git mv setuptools src | ||||||
git mv pkg_resources src | ||||||
- name: Retrieve pre-built distribution files | ||||||
uses: actions/download-artifact@v2 | ||||||
with: | ||||||
name: python-distribution-files | ||||||
path: dist/ | ||||||
- name: Run tests | ||||||
shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -leo pipefail -o igncr {0} | ||||||
run: >- | ||||||
python -m tox | ||||||
--installpkg '${{ needs.prepare.outputs.wheel-distribution }}' | ||||||
-- --cov-report xml --cov-report term --cov-config .coveragerc.ci | ||||||
- name: Publish coverage | ||||||
uses: codecov/codecov-action@v1 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already deprecated, v3 should be used instead. |
||||||
with: | ||||||
flags: >- # Mark which lines are covered by which envs | ||||||
cygwin | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be comma-separated
Suggested change
|
||||||
${{ matrix.python }} | ||||||
|
||||||
integration-test: | ||||||
strategy: | ||||||
matrix: | ||||||
distutils: | ||||||
- stdlib | ||||||
- local | ||||||
needs: test | ||||||
needs: [prepare, test] | ||||||
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && contains(github.ref, 'refs/tags/')) | ||||||
# To avoid long times and high resource usage, we assume that: | ||||||
# 1. The setuptools APIs used by packages don't vary too much with OS or | ||||||
|
@@ -89,6 +211,8 @@ jobs: | |||||
runs-on: ubuntu-latest | ||||||
env: | ||||||
SETUPTOOLS_USE_DISTUTILS: ${{ matrix.distutils }} | ||||||
PRE_BUILT_SETUPTOOLS_WHEEL: ${{ needs.prepare.outputs.wheel-distribution }} | ||||||
PRE_BUILT_SETUPTOOLS_SDIST: ${{ needs.prepare.outputs.sdist-distribution }} | ||||||
steps: | ||||||
- uses: actions/checkout@v2 | ||||||
- name: Install OS-level dependencies | ||||||
|
@@ -103,11 +227,31 @@ jobs: | |||||
- name: Install tox | ||||||
run: | | ||||||
python -m pip install tox | ||||||
- name: Isolate tests to avoid PYTHONPATH interference | ||||||
run: | | ||||||
# Avoid problems with import paths, see #2318, #3015: | ||||||
# `mkdir` `git rm` and `git mv` are OS-independent commands | ||||||
git mv setuptools/tests test_setuptools | ||||||
git mv pkg_resources/tests test_pkg_resources | ||||||
# Prevent local directories to take precedence over installed packages: | ||||||
mkdir src | ||||||
git mv _distutils_hack src | ||||||
git mv setuptools src | ||||||
git mv pkg_resources src | ||||||
- name: Retrieve pre-built distribution files | ||||||
uses: actions/download-artifact@v2 | ||||||
with: | ||||||
name: python-distribution-files | ||||||
path: dist/ | ||||||
- name: Run integration tests | ||||||
run: tox -e integration | ||||||
run: >- | ||||||
python -m tox -e integration | ||||||
--installpkg '${{ needs.prepare.outputs.wheel-distribution }}' | ||||||
-- -vv --durations=10 | ||||||
test_setuptools/integration | ||||||
|
||||||
release: | ||||||
needs: [test, test_cygwin, integration-test] | ||||||
needs: [prepare, test, test_cygwin, develop-test, integration-test] | ||||||
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | ||||||
runs-on: ubuntu-latest | ||||||
|
||||||
|
@@ -116,7 +260,7 @@ jobs: | |||||
- name: Setup Python | ||||||
uses: actions/setup-python@v2 | ||||||
with: | ||||||
python-version: "3.10" | ||||||
python-version: ${{ needs.prepare.outputs-python-version-for-build }} | ||||||
- name: Install tox | ||||||
run: | | ||||||
python -m pip install tox | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right solution. This setting seems to change how files on Codecov are mapped to GH.