From eb2f74c153987b4e0d03aa16931d97e8137d9257 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 29 Nov 2021 10:31:58 +0100 Subject: Fix CI tests / wheels / workflow (#2024) Signed-off-by: Giampaolo Rodola --- .github/workflows/build.yml | 66 +++++++++++++++++++++++++--- HISTORY.rst | 2 +- Makefile | 4 +- appveyor.yml | 8 ---- psutil/__init__.py | 2 +- psutil/tests/runner.py | 2 + psutil/tests/test_connections.py | 2 - psutil/tests/test_linux.py | 10 ++--- psutil/tests/test_misc.py | 6 +-- scripts/internal/download_wheels_appveyor.py | 2 +- scripts/internal/print_wheels.py | 2 +- 11 files changed, 75 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0559acd2..ca026299 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,13 +3,14 @@ # # * Linux # * macOS -# * Windows (commented) +# * Windows (disabled) # * FreeBSD # # To skip certain builds see: # https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip # # External GH actions: +# * https://github.com/pypa/cibuildwheel # * https://github.com/actions/checkout # * https://github.com/actions/setup-python # * https://github.com/actions/upload-artifact @@ -19,10 +20,11 @@ on: [push, pull_request] name: build jobs: - linux-macos-win: - name: ${{ matrix.os }} + # Linux + macOS + Python 3 + linux-macos-py3: + name: ${{ matrix.os }}-py3 runs-on: ${{ matrix.os }} - timeout-minutes: 30 + timeout-minutes: 20 strategy: fail-fast: false matrix: @@ -35,11 +37,12 @@ jobs: PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python {project}/psutil/tests/runner.py && PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python {project}/psutil/tests/test_memleaks.py CIBW_TEST_EXTRAS: test - CIBW_SKIP: cp35-* pp* + CIBW_BUILD: 'cp37-* cp38-* cp39-* cp310-*' + CIBW_SKIP: '*-musllinux_*' steps: - name: Cancel previous runs - uses: styfle/cancel-workflow-action@0.6.0 + uses: styfle/cancel-workflow-action@0.9.1 with: access_token: ${{ github.token }} @@ -73,6 +76,57 @@ jobs: mv dist/psutil*.tar.gz wheelhouse/ python scripts/internal/print_hashes.py wheelhouse/ + # Linux + macOS + Python 2 + linux-macos-py2: + name: ${{ matrix.os }}-py2 + runs-on: ubuntu-latest + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + include: + - {name: Linux, python: '3.9', os: ubuntu-latest} + env: + CIBW_ARCHS: 'x86_64 i686' + CIBW_TEST_COMMAND: + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python {project}/psutil/tests/runner.py && + PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 python {project}/psutil/tests/test_memleaks.py + CIBW_TEST_EXTRAS: test + CIBW_BUILD: 'cp27-*' + CIBW_SKIP: '*-musllinux_*' + + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Install cibuildwheel + run: pip install cibuildwheel==1.12.0 + + - name: Run tests + run: cibuildwheel . + + - name: Create wheels + uses: actions/upload-artifact@v2 + with: + name: wheels + path: wheelhouse + + - name: Print hashes + if: matrix.os == 'ubuntu-latest' + run: | + make generate-manifest + python setup.py sdist + mv dist/psutil*.tar.gz wheelhouse/ + python scripts/internal/print_hashes.py wheelhouse/ + freebsd: runs-on: macos-latest steps: diff --git a/HISTORY.rst b/HISTORY.rst index 4b6ece58..37ee57f1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,6 @@ *Bug tracker at https://github.com/giampaolo/psutil/issues* -5.8.1 (IN DEVELOPMENT) +5.9.0 (IN DEVELOPMENT) ====================== XXXX-XX-XX diff --git a/Makefile b/Makefile index f255b651..01512b7c 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ INSTALL_OPTS = `$(PYTHON) -c \ "import sys; print('' if hasattr(sys, 'real_prefix') else '--user')"` TEST_PREFIX = PYTHONWARNINGS=always PSUTIL_DEBUG=1 -all: test +all: help # =================================================================== # Install @@ -214,9 +214,11 @@ install-git-hooks: ## Install GIT pre-commit hook. download-wheels-github: ## Download latest wheels hosted on github. $(PYTHON) scripts/internal/download_wheels_github.py --tokenfile=~/.github.token + ${MAKE} print-wheels download-wheels-appveyor: ## Download latest wheels hosted on appveyor. $(PYTHON) scripts/internal/download_wheels_appveyor.py + ${MAKE} print-wheels print-wheels: ## Print downloaded wheels $(PYTHON) scripts/internal/print_wheels.py diff --git a/appveyor.yml b/appveyor.yml index 83e570ae..485182d3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,10 +24,6 @@ environment: PYTHON_VERSION: "2.7.x" PYTHON_ARCH: "32" - - PYTHON: "C:\\Python36" - PYTHON_VERSION: "3.6.x" - PYTHON_ARCH: "32" - - PYTHON: "C:\\Python37" PYTHON_VERSION: "3.7.x" PYTHON_ARCH: "32" @@ -52,10 +48,6 @@ environment: PYTHON_VERSION: "2.7.x" PYTHON_ARCH: "64" - - PYTHON: "C:\\Python36-x64" - PYTHON_VERSION: "3.6.x" - PYTHON_ARCH: "64" - - PYTHON: "C:\\Python37-x64" PYTHON_VERSION: "3.7.x" PYTHON_ARCH: "64" diff --git a/psutil/__init__.py b/psutil/__init__.py index 2760c76b..4632aa85 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -210,7 +210,7 @@ if hasattr(_psplatform.Process, "rlimit"): AF_LINK = _psplatform.AF_LINK __author__ = "Giampaolo Rodola'" -__version__ = "5.8.1" +__version__ = "5.9.0" version_info = tuple([int(num) for num in __version__.split('.')]) _timer = getattr(time, 'monotonic', time.time) diff --git a/psutil/tests/runner.py b/psutil/tests/runner.py index 65f222c4..cd7e20b2 100755 --- a/psutil/tests/runner.py +++ b/psutil/tests/runner.py @@ -298,6 +298,8 @@ def get_runner(parallel=False): # Used by test_*,py modules. def run_from_name(name): + if CI_TESTING: + print_sysinfo() suite = TestLoader().from_name(name) runner = get_runner() runner.run(suite) diff --git a/psutil/tests/test_connections.py b/psutil/tests/test_connections.py index 6bbf2194..a7a97544 100755 --- a/psutil/tests/test_connections.py +++ b/psutil/tests/test_connections.py @@ -8,7 +8,6 @@ import os import socket -import sys import textwrap from contextlib import closing from socket import AF_INET @@ -47,7 +46,6 @@ from psutil.tests import wait_for_file thisproc = psutil.Process() SOCK_SEQPACKET = getattr(socket, "SOCK_SEQPACKET", object()) -PYTHON_39 = sys.version_info[:2] == (3, 9) @serialrun diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index 38322db6..7451e2bc 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -149,7 +149,7 @@ def free_swap(): """Parse 'free' cmd and return swap memory's s total, used and free values. """ - out = sh('free -b', env={"LANG": "C.UTF-8"}) + out = sh(["free", "-b"], env={"LANG": "C.UTF-8"}) lines = out.split('\n') for line in lines: if line.startswith('Swap'): @@ -168,7 +168,7 @@ def free_physmem(): # and 'cached' memory which may have different positions so we # do not return them. # https://github.com/giampaolo/psutil/issues/538#issuecomment-57059946 - out = sh('free -b', env={"LANG": "C.UTF-8"}) + out = sh(["free", "-b"], env={"LANG": "C.UTF-8"}) lines = out.split('\n') for line in lines: if line.startswith('Mem'): @@ -182,7 +182,7 @@ def free_physmem(): def vmstat(stat): - out = sh("vmstat -s", env={"LANG": "C.UTF-8"}) + out = sh(["vmstat", "-s"], env={"LANG": "C.UTF-8"}) for line in out.split("\n"): line = line.strip() if stat in line: @@ -191,7 +191,7 @@ def vmstat(stat): def get_free_version_info(): - out = sh("free -V").strip() + out = sh(["free", "-V"]).strip() if 'UNKNOWN' in out: raise unittest.SkipTest("can't determine free version") return tuple(map(int, out.split()[-1].split('.'))) @@ -312,7 +312,7 @@ class TestSystemVirtualMemory(PsutilTestCase): def test_available(self): # "free" output format has changed at some point: # https://github.com/giampaolo/psutil/issues/538#issuecomment-147192098 - out = sh("free -b") + out = sh(["free", "-b"]) lines = out.split('\n') if 'available' not in lines[0]: raise unittest.SkipTest("free does not support 'available' column") diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py index 70f6a37e..323c5406 100755 --- a/psutil/tests/test_misc.py +++ b/psutil/tests/test_misc.py @@ -17,7 +17,6 @@ import os import pickle import socket import stat -import sys from psutil import LINUX from psutil import POSIX @@ -50,9 +49,6 @@ import psutil import psutil.tests -PYTHON_39 = sys.version_info[:2] == (3, 9) - - # =================================================================== # --- Misc / generic tests. # =================================================================== @@ -414,7 +410,7 @@ class TestMisc(PsutilTestCase): msg = f.getvalue() assert msg.startswith("psutil-debug"), msg self.assertIn("hello", msg) - self.assertIn(__file__, msg) + self.assertIn(__file__.replace('.pyc', '.py'), msg) # supposed to use repr(exc) with redirect_stderr(StringIO()) as f: diff --git a/scripts/internal/download_wheels_appveyor.py b/scripts/internal/download_wheels_appveyor.py index bc6c9717..5e633d52 100755 --- a/scripts/internal/download_wheels_appveyor.py +++ b/scripts/internal/download_wheels_appveyor.py @@ -26,7 +26,7 @@ from psutil._common import print_color USER = "giampaolo" PROJECT = "psutil" BASE_URL = 'https://ci.appveyor.com/api' -PY_VERSIONS = ['2.7', '3.6', '3.7', '3.8', '3.9'] +PY_VERSIONS = ['2.7', '3.7', '3.8', '3.9', '3.10'] TIMEOUT = 30 diff --git a/scripts/internal/print_wheels.py b/scripts/internal/print_wheels.py index c2b8d36b..d13a6aa7 100755 --- a/scripts/internal/print_wheels.py +++ b/scripts/internal/print_wheels.py @@ -74,7 +74,7 @@ def main(): tot_files = 0 tot_size = 0 - templ = "%-54s %7s %7s %7s" + templ = "%-100s %7s %7s %7s" for platf, wheels in groups.items(): ppn = "%s (total = %s)" % (platf, len(wheels)) s = templ % (ppn, "size", "arch", "pyver") -- cgit v1.2.1