diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77b0dd5..6d6d96e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,7 @@ jobs: outputs: version: ${{ steps.get_version.outputs.version }} upload_url: ${{ steps.create_release.outputs.upload_url }} + new_sha: ${{ steps.commit_updated.outputs.sha }} steps: @@ -19,12 +20,14 @@ jobs: bin/bump_version.py - name: Commit updated version.py + id: commit_updated run: | git config --global user.name 'github-actions' git config --global user.email 'bot@noreply.github.com' git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} git add setup.py git commit -m "bump version" && git push || echo "No changes to commit" + git log -n 1 --pretty=format:"%H" | tail -n 1 | awk '{print "::set-output name=sha::"$0}' - name: Get version id: get_version @@ -45,9 +48,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout - uses: actions/checkout@v2 - - name: Set up Python 3.9 uses: actions/setup-python@v2 with: @@ -82,7 +82,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + with: + ref: ${{ needs.release_create.outputs.new_sha }} - name: Set up Python 3.9 uses: actions/setup-python@v2 @@ -127,7 +129,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + with: + ref: ${{ needs.release_create.outputs.new_sha }} - name: Set up Python 3.9 uses: actions/setup-python@v2 @@ -167,7 +171,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + with: + ref: ${{ needs.release_create.outputs.new_sha }} - name: Set up Python 3.9 uses: actions/setup-python@v2 diff --git a/examples/show_ports.py b/examples/show_ports.py new file mode 100644 index 0000000..30c9cd9 --- /dev/null +++ b/examples/show_ports.py @@ -0,0 +1,6 @@ +"""Simple program to show serial ports. +""" + +from meshtastic.util import findPorts + +print(findPorts()) diff --git a/meshtastic/tests/test_util.py b/meshtastic/tests/test_util.py index 08faebb..ed01070 100644 --- a/meshtastic/tests/test_util.py +++ b/meshtastic/tests/test_util.py @@ -266,6 +266,22 @@ def test_findPorts_when_duplicate_found_and_duplicate_option_used(patch_comports patch_comports.assert_called() +@pytest.mark.unitslow +@patch('serial.tools.list_ports.comports') +def test_findPorts_when_duplicate_found_and_duplicate_option_used_ports_reversed(patch_comports): + """Test findPorts()""" + class TempPort: + """ temp class for port""" + def __init__(self, device=None, vid=None): + self.device = device + self.vid = vid + fake1 = TempPort('/dev/cu.usbserial-1430', vid='fake1') + fake2 = TempPort('/dev/cu.wchusbserial1430', vid='fake2') + patch_comports.return_value = [fake2, fake1] + assert findPorts(eliminate_duplicates=True) == ['/dev/cu.wchusbserial1430'] + patch_comports.assert_called() + + @pytest.mark.unitslow @patch('serial.tools.list_ports.comports') def test_findPorts_when_duplicate_found_and_duplicate_option_not_used(patch_comports): @@ -317,11 +333,13 @@ def test_eliminate_duplicate_port(): assert eliminate_duplicate_port(['/dev/fake', '/dev/fake1']) == ['/dev/fake', '/dev/fake1'] assert eliminate_duplicate_port(['/dev/fake', '/dev/fake1', '/dev/fake2']) == ['/dev/fake', '/dev/fake1', '/dev/fake2'] assert eliminate_duplicate_port(['/dev/cu.usbserial-1430', '/dev/cu.wchusbserial1430']) == ['/dev/cu.wchusbserial1430'] + assert eliminate_duplicate_port(['/dev/cu.wchusbserial1430', '/dev/cu.usbserial-1430']) == ['/dev/cu.wchusbserial1430'] assert eliminate_duplicate_port(['/dev/cu.SLAB_USBtoUART', '/dev/cu.usbserial-0001']) == ['/dev/cu.usbserial-0001'] + assert eliminate_duplicate_port(['/dev/cu.usbserial-0001', '/dev/cu.SLAB_USBtoUART']) == ['/dev/cu.usbserial-0001'] assert eliminate_duplicate_port(['/dev/cu.usbmodem11301', '/dev/cu.wchusbserial11301']) == ['/dev/cu.wchusbserial11301'] assert eliminate_duplicate_port(['/dev/cu.usbmodem53230051441', '/dev/cu.wchusbserial53230051441']) == ['/dev/cu.wchusbserial53230051441'] assert eliminate_duplicate_port(['/dev/cu.wchusbserial53230051441', '/dev/cu.usbmodem53230051441']) == ['/dev/cu.wchusbserial53230051441'] - + assert eliminate_duplicate_port(['/dev/cu.wchusbserial11301', '/dev/cu.usbmodem11301']) == ['/dev/cu.wchusbserial11301'] @patch('platform.version', return_value='10.0.22000.194') @patch('platform.release', return_value='10') diff --git a/setup.py b/setup.py index d64e9f2..f643790 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ with open("README.md", "r") as fh: # This call to setup() does all the work setup( name="meshtastic", - version="1.2.88", + version="1.2.89", description="Python API & client shell for talking to Meshtastic devices", long_description=long_description, long_description_content_type="text/markdown",