summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-07-19 06:53:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-07-19 06:53:07 +0000
commitdae41402954ef8b5c43369ae6d539689c59e99fd (patch)
treef1761f2e43ab84d71d12e92ac646f06afd677e48
parentReleasing progress-linux version 0.6.1-1~progress6+u1. (diff)
downloadport-for-dae41402954ef8b5c43369ae6d539689c59e99fd.tar.xz
port-for-dae41402954ef8b5c43369ae6d539689c59e99fd.zip
Merging upstream version 0.6.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--.bumpversion.cfg2
-rw-r--r--.github/workflows/automerge.yml63
-rw-r--r--.github/workflows/build.yml17
-rw-r--r--.github/workflows/linters.yml72
-rw-r--r--.github/workflows/pypi.yml29
-rw-r--r--.github/workflows/tests-macos.yml37
-rw-r--r--.github/workflows/tests.yml33
-rw-r--r--CHANGES.rst8
-rw-r--r--requirements-lint.txt6
-rw-r--r--requirements-test.txt7
-rw-r--r--setup.cfg6
-rw-r--r--src/port_for/__init__.py2
-rw-r--r--src/port_for/api.py9
-rw-r--r--src/port_for/ephemeral.py5
-rw-r--r--tests/test_cases.py2
15 files changed, 82 insertions, 216 deletions
diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index 6c2ba5c..85a103c 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -2,7 +2,7 @@
commit = True
tag = True
message = "Release {new_version}"
-current_version = 0.6.1
+current_version = 0.6.2
[bumpversion:file:setup.cfg]
search = version = {current_version}
diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml
index 78dff52..8d1f004 100644
--- a/.github/workflows/automerge.yml
+++ b/.github/workflows/automerge.yml
@@ -1,41 +1,38 @@
-name: Automerge Pull Requests
+name: Merge me test dependencies!
+
on:
- pull_request:
- types:
- - labeled
- - unlabeled
- - synchronize
- - opened
- - edited
- - ready_for_review
- - reopened
- - unlocked
- pull_request_review:
- types:
- - submitted
- check_suite:
+ workflow_run:
types:
- completed
- status: {}
+ workflows:
+ # List all required workflow names here.
+ - 'Run linters'
+ - 'Run tests'
+ - 'Run tests on macos'
+ - 'Test build package'
jobs:
- automerge:
- name: Automerge Dependabot
+ merge-me:
+ name: Merge me!
runs-on: ubuntu-latest
- if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
steps:
- - name: 'Wait for status checks'
- id: waitforstatuschecks
- uses: "WyriHaximus/github-action-wait-for-status@v1.3"
+ - # It is often a desired behavior to merge only when a workflow execution
+ # succeeds. This can be changed as needed.
+ if: ${{ github.event.workflow_run.conclusion == 'success' }}
+ name: Merge me!
+ uses: ridedott/merge-me-action@v2
with:
- ignoreActions: Automerge Dependabot
- checkInterval: 13
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- - name: Merge pull requests
- uses: pascalgn/automerge-action@v0.13.1
- if: steps.waitforstatuschecks.outputs.status == 'success'
- env:
- MERGE_METHOD: "squash"
- MERGE_LABELS: ""
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
+ # Depending on branch protection rules, a manually populated
+ # `GITHUB_TOKEN_WORKAROUND` secret with permissions to push to
+ # a protected branch must be used. This secret can have an arbitrary
+ # name, as an example, this repository uses `DOTTBOTT_TOKEN`.
+ #
+ # When using a custom token, it is recommended to leave the following
+ # comment for other developers to be aware of the reasoning behind it:
+ #
+ # This must be used as GitHub Actions token does not support pushing
+ # to protected branches.
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ MERGE_METHOD: MERGE
+ PRESET: DEPENDABOT_MINOR
+ ENABLED_FOR_MANUAL_CHANGES: 'true'
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 6e8f64e..09bdb11 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -8,19 +8,4 @@ on:
jobs:
build:
- name: Build Python 🐍 distributions 📦
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@master
- - name: Set up Python 3.9
- uses: actions/setup-python@v2
- with:
- python-version: 3.9
- - name: Install build tools
- run: pip install build
- - name: Build a wheel package
- run: python -m build .
- - name: Install twine to check the package
- run: pip install twine
- - name: Check the package
- run: twine check dist/*
+ uses: fizyk/actions-reuse/.github/workflows/pypi.yml@v1.3.1
diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml
index 9db1a52..e2fc90f 100644
--- a/.github/workflows/linters.yml
+++ b/.github/workflows/linters.yml
@@ -9,72 +9,8 @@ on:
- requirements-lint.txt
pull_request:
branches: [ master ]
- paths:
- - '**.py'
- - .github/workflows/linters.yml
- - requirements-lint.txt
-
jobs:
- pydocstyle:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
-
- steps:
- - uses: actions/checkout@v2
- - name: Set up Python 3.9
- uses: actions/setup-python@v2
- with:
- python-version: 3.9
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install -r requirements-lint.txt
- - name: Run pydocstyle
- run: |
- pydocstyle src/ tests/
-
- pycodestyle:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
-
- steps:
- - uses: actions/checkout@v2
- - name: Set up Python 3.9
- uses: actions/setup-python@v2
- with:
- python-version: 3.9
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install -r requirements-lint.txt
- - name: Run pydocstyle
- run: |
- pycodestyle src/ tests/
-
- black:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-python@v2
- - uses: psf/black@main
-
- mypy:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
-
- steps:
- - uses: actions/checkout@v2
- - name: Set up Python 3.9
- uses: actions/setup-python@v2
- with:
- python-version: 3.9
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install -r requirements-lint.txt
- - name: Run mypy
- run: |
- mypy src/port_for/ tests/ scripts/port-for
+ lint:
+ uses: fizyk/actions-reuse/.github/workflows/linters-python.yml@main
+ with:
+ mypy: true \ No newline at end of file
diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml
index 8328230..fa2f20d 100644
--- a/.github/workflows/pypi.yml
+++ b/.github/workflows/pypi.yml
@@ -4,26 +4,9 @@ on:
tags:
- v*
jobs:
- build-n-publish:
- name: Build and publish Python 🐍 distributions 📦 to PyPI
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@master
- - name: Set up Python 3.9
- uses: actions/setup-python@v2
- with:
- python-version: 3.9
- - name: Install build tools
- run: pip install build
- - name: Build a wheel package
- run: python -m build .
-# - name: Publish distribution 📦 to Test PyPI
-# uses: pypa/gh-action-pypi-publish@master
-# with:
-# password: ${{ secrets.test_pypi_token }}
-# repository_url: https://test.pypi.org/legacy/
- - name: Publish distribution 📦 to PyPI
- uses: pypa/gh-action-pypi-publish@master
- with:
- password: ${{ secrets.pypi_token }}
- verbose: true
+ build:
+ uses: fizyk/actions-reuse/.github/workflows/pypi.yml@v1.3.1
+ with:
+ publish: true
+ secrets:
+ pypi_token: ${{ secrets.pypi_token }}
diff --git a/.github/workflows/tests-macos.yml b/.github/workflows/tests-macos.yml
index f22044f..8cb5cbe 100644
--- a/.github/workflows/tests-macos.yml
+++ b/.github/workflows/tests-macos.yml
@@ -14,34 +14,11 @@ on:
- .github/workflows/tests-macos.yml
- requirements-test.txt
-jobs:
- macostests:
- runs-on: macos-latest
- strategy:
- fail-fast: false
- matrix:
- python-version: [3.7, 3.8, 3.9, pypy-3.7-v7.3.3]
- env:
- OS: macos-latest
- PYTHON: ${{ matrix.python-version }}
- steps:
- - uses: actions/checkout@v2
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v2
- with:
- python-version: ${{ matrix.python-version }}
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install -r requirements-test.txt
- - name: Run test
- run: |
- pytest --cov-report=xml
- - name: Upload coverage to Codecov
- uses: codecov/codecov-action@v1
- with:
- file: ./coverage.xml
- flags: macos
- env_vars: OS, PYTHON
- fail_ci_if_error: true
+jobs:
+ tests:
+ uses: fizyk/actions-reuse/.github/workflows/tests-pytests.yml@v1.3.1
+ with:
+ python-versions: '["3.7", "3.8", "3.9", "3.10", "pypy-3.8"]'
+ cover_package: src/port_for
+ os: macos-latest
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 3900c89..2cbfa82 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -12,32 +12,7 @@ on:
jobs:
tests:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- python-version: [3.7, 3.8, 3.9, pypy-3.7-v7.3.3]
- env:
- OS: ubuntu-latest
- PYTHON: ${{ matrix.python-version }}
-
- steps:
- - uses: actions/checkout@v2
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v2
- with:
- python-version: ${{ matrix.python-version }}
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install -r requirements-test.txt
- - name: Run test
- run: |
- pytest --cov-report=xml
- - name: Upload coverage to Codecov
- uses: codecov/codecov-action@v1
- with:
- file: ./coverage.xml
- flags: linux
- env_vars: OS, PYTHON
- fail_ci_if_error: true
+ uses: fizyk/actions-reuse/.github/workflows/tests-pytests.yml@v1.3.1
+ with:
+ python-versions: '["3.7", "3.8", "3.9", "3.10", "pypy-3.8"]'
+ cover_package: src/port_for
diff --git a/CHANGES.rst b/CHANGES.rst
index 8698c22..6f42e21 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,14 @@
CHANGELOG
=========
+0.6.2
+----------
+
+Misc
+++++
+
+- Added Python 3.10 to trove classifiers and to CI
+
0.6.1
----------
diff --git a/requirements-lint.txt b/requirements-lint.txt
index 0a40402..c7a8e5f 100644
--- a/requirements-lint.txt
+++ b/requirements-lint.txt
@@ -1,7 +1,7 @@
# linters
-pycodestyle==2.7.0
+pycodestyle==2.8.0
pydocstyle==6.1.1
pygments
-black==21.5b2
-mypy==0.812
+black==22.1.0
+mypy==0.931
-r requirements-test.txt
diff --git a/requirements-test.txt b/requirements-test.txt
index c75f872..7c3c551 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,6 +1,5 @@
# test runs requirements (versions we'll be testing against) - automatically updated
-mock==4.0.3
-pytest==6.2.4 # tests framework used
-pytest-cov==2.12.0 # coverage reports to verify tests quality
-coverage==5.5 # pytest-cov
+pytest==7.0.1 # tests framework used
+pytest-cov==3.0.0 # coverage reports to verify tests quality
+coverage==6.3.1 # pytest-cov
-e .[tests]
diff --git a/setup.cfg b/setup.cfg
index edb34b1..6f8e78c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = port-for
-version = 0.6.1
+version = 0.6.2
url = https://github.com/kmike/port-for/
description = Utility that helps with local TCP ports management. It can find an unused TCP localhost port and remember the association.
long_description = file: README.rst, CHANGES.rst
@@ -22,6 +22,7 @@ classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
+ Programming Language :: Python :: 3.10
Operating System :: POSIX
Topic :: System :: Installation/Setup
Topic :: System :: Systems Administration
@@ -44,7 +45,6 @@ where = src
tests =
pytest
pytest-cov
- mock
[options.package_data]
port_for = py.typed
@@ -61,4 +61,4 @@ match = '(?!docs|build|venv).*\.py'
addopts = -vvv --capture=no --showlocals --cov src/port_for --cov tests --ignore src/port_for/_download_ranges.py
testpaths = tests/
filterwarnings = error
-xfail_strict = True \ No newline at end of file
+xfail_strict = True
diff --git a/src/port_for/__init__.py b/src/port_for/__init__.py
index a291517..54ec646 100644
--- a/src/port_for/__init__.py
+++ b/src/port_for/__init__.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-__version__ = "0.6.1"
+__version__ = "0.6.2"
from ._ranges import UNASSIGNED_RANGES
from .api import (
diff --git a/src/port_for/api.py b/src/port_for/api.py
index 0fc6acd..dfdf4cd 100644
--- a/src/port_for/api.py
+++ b/src/port_for/api.py
@@ -55,6 +55,15 @@ def available_ports(
exclude_ranges = []
available = utils.ranges_to_set(UNASSIGNED_RANGES)
exclude = utils.ranges_to_set(
+ # Motivation behind excluding ephemeral port ranges:
+ # let's say you decided to use an ephemeral local port
+ # as a persistent port, and "reserve" it to your software.
+ # OS won't know about it, and still can try to use this port.
+ # This is not a problem if your service is always running and occupying
+ # this port (OS would pick next one). But if the service is temporarily
+ # not using the port (because of restart of other reason),
+ # OS might reuse the same port,
+ # which might prevent the service from starting.
ephemeral.port_ranges()
+ exclude_ranges
+ [SYSTEM_PORT_RANGE, (SYSTEM_PORT_RANGE[1], low), (high, 65536)]
diff --git a/src/port_for/ephemeral.py b/src/port_for/ephemeral.py
index 9d1e903..a3c03ec 100644
--- a/src/port_for/ephemeral.py
+++ b/src/port_for/ephemeral.py
@@ -45,10 +45,7 @@ def _bsd_ranges() -> List[Tuple[int, int]]:
lines = stdout.decode("ascii").split("\n")
out: Dict[str, str] = dict(
[
- [
- x.strip().rsplit(".")[-1] # type: ignore[misc]
- for x in line.split(":")
- ]
+ [x.strip().rsplit(".")[-1] for x in line.split(":")]
for line in lines
if line
]
diff --git a/tests/test_cases.py b/tests/test_cases.py
index 0d97e96..004b856 100644
--- a/tests/test_cases.py
+++ b/tests/test_cases.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import unittest
import tempfile
-import mock
+from unittest import mock
import socket
import os
from typing import Union, List, Set, Tuple