From d80277615eb4a1c751bb6bb91b9b401bcb5bd569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Thu, 21 Dec 2023 09:12:18 +0100 Subject: [PATCH 1/2] CI: add job that checks README.rst against usbsdmux -h output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The usbsdmux -h output in the README.rst has become out of date with the actual output in multiple PRs recently. Make sure that does not happen again. Signed-off-by: Leonard Göhrs --- .github/workflows/readme.py | 21 +++++++++++++++++++++ .github/workflows/readme.yml | 17 +++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 .github/workflows/readme.py create mode 100644 .github/workflows/readme.yml diff --git a/.github/workflows/readme.py b/.github/workflows/readme.py new file mode 100644 index 0000000..e9957cb --- /dev/null +++ b/.github/workflows/readme.py @@ -0,0 +1,21 @@ +import subprocess +import sys + +usbsdmux_help = subprocess.run(["usbsdmux", "-h"], capture_output=True).stdout +usbsdmux_help = usbsdmux_help.decode("utf-8") + +# Convert to the indentation we have in the README.rst +usbsdmux_help = "$ usbsdmux -h\n" + usbsdmux_help +usbsdmux_help = "\n".join((" " + line) if line.strip() != "" else "" for line in usbsdmux_help.split("\n")) + +readme_help = open("README.rst").read() + +if usbsdmux_help not in readme_help: + print("The help text in the README.rst is not up to date.") + print("Update the README.rst with the following content:") + print("") + print(".. code-block:: text") + print("") + print(usbsdmux_help) + + sys.exit(1) diff --git a/.github/workflows/readme.yml b/.github/workflows/readme.yml new file mode 100644 index 0000000..95b90d2 --- /dev/null +++ b/.github/workflows/readme.yml @@ -0,0 +1,17 @@ +name: readme + +on: [push, pull_request] + +jobs: + readme-help: + name: usbsdmux -h is up to date + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install dependencies and usbsdmux tool + run: | + python3 -m pip install --upgrade pip + python3 -m pip install . + - name: Run the check + run: | + python3 .github/workflows/readme.py From 326cb9054354b438f9d9e2f8753ef5dd4e1dbaaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Thu, 21 Dec 2023 09:20:51 +0100 Subject: [PATCH 2/2] README: sync the usbsdmux -h output with the actual output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A README that does not match the behaviour of the program can be quite confusing. Sync the usbsdmux -h output with the actual output. Signed-off-by: Leonard Göhrs --- README.rst | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/README.rst b/README.rst index f691f44..e6521d2 100644 --- a/README.rst +++ b/README.rst @@ -65,21 +65,24 @@ command invocations: .. code-block:: text - $ usbsdmux -h - usage: usbsdmux [-h] SG {get,dut,client,host,off} - - positional arguments: - SG /dev/sg* to use - {get,dut,client,host,off} - Action: - get - return selected mode - dut - set to dut mode - client - set to dut mode (alias for dut) - host - set to host mode - off - set to off mode - - optional arguments: - -h, --help show this help message and exit + $ usbsdmux -h + usage: usbsdmux [-h] [--json] SG {get,dut,client,host,off,gpio,info} ... + + positional arguments: + SG /dev/sg* to use + {get,dut,client,host,off,gpio,info} + Supply one of the following commands to interact with the device + get Read the current state of the USB-SD-Mux + dut Switch to the DUT + client Switch to the DUT + host Switch to the host + off Disconnect from host and DUT + gpio Manipulate a GPIO (open drain output only) + info Show information about the SD card + + options: + -h, --help show this help message and exit + --json Format output as json. Useful for scripting. Using as root -------------