diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 39fccaeb..dfafa981 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,57 +3,37 @@ on: [push, pull_request] name: tests +concurrency: + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }} + cancel-in-progress: true jobs: - linux: + # Run unit tests + py3: + name: "py-${{ matrix.python-version }}, ${{ matrix.os }}" runs-on: ${{ matrix.os }} + timeout-minutes: 20 strategy: + fail-fast: false matrix: python-version: ["3.11"] - os: [ubuntu-latest] + os: [ubuntu-latest, windows-latest] steps: - - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + - name: Set up Python + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install pydeps - run: | - make setup-dev-env PYTHON=python - - - name: Tests + - name: Install pydeps ${{ matrix.os }} + if: matrix.os == 'windows-latest' run: | - make test PYTHON=python - - windows: - runs-on: windows-2019 - strategy: - matrix: - python-version: ["3.11"] - - steps: - - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - - name: Install pydeps + python.exe -m pip install --upgrade pypiwin32 wmi pyopenssl psutil pytest + - name: Install pydeps ${{ matrix.os }} + if: matrix.os != 'windows-latest' run: | - python.exe -m pip install --upgrade --user setuptools pip wheel - python.exe -m pip install --upgrade mock ipaddress pypiwin32 wmi pyopenssl psutil pytest - python.exe -m pip freeze - python.exe setup.py install + make setup-dev-env - name: Tests run: | @@ -63,10 +43,10 @@ jobs: linters: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - name: 'Run linters' run: | - python3 -m pip install black ruff rstcheck toml-sort sphinx-rtd-theme + python3 -m pip install --upgrade black ruff rstcheck toml-sort sphinx-rtd-theme python3 -m pip freeze make lint-all diff --git a/Makefile b/Makefile index 936b0e0a..ea341678 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,34 @@ # Shortcuts for various tasks (UNIX only). # To use a specific Python version run: -# $ make install PYTHON=python3.7 +# $ make install PYTHON=python3.7 +# To run a specific test: +# $ make test ARGS="-v -s pyftpdlib/test/test_functional.py::TestIPv6MixedEnvironment::test_port_v4" PYTHON = python3 ARGS = + +# mandatory deps for running tests PYDEPS = \ - black \ - check-manifest \ - coverage \ psutil \ - pylint \ pyopenssl \ pytest \ - pytest-cov \ - rstcheck \ - ruff \ - setuptools \ - teyit \ - toml-sort \ - twine -PYVER = $(shell $(PYTHON) -c "import sys; print(sys.version_info[0])") -ifeq ($(PYVER), 2) + setuptools +# dev deps +ifndef GITHUB_ACTIONS + PYDEPS += \ + black \ + check-manifest \ + coverage \ + pylint \ + pytest-cov \ + rstcheck \ + ruff \ + teyit \ + toml-sort \ + twine +endif +# python 2 deps +ifeq ($(shell $(PYTHON) -c "import sys; print(sys.version_info[0])"), 2) PYDEPS = \ ipaddress \ mock \ @@ -37,6 +45,8 @@ TEST_PREFIX = PYTHONWARNINGS=always PYTEST_ARGS = -v --tb=native -o cache_dir=/tmp/pyftpdlib-pytest-cache NUM_WORKERS = `$(PYTHON) -c "import os; print(os.cpu_count() or 1)"` +# if make is invoked with no arg, default to `make help` +.DEFAULT_GOAL := help # =================================================================== # Install diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index 6d40904e..ee78907a 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -46,6 +46,7 @@ "setuptools", "wmi", ] + if sys.version_info[:2] == (2, 7): DEPS.extend( [