Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: add job that checks README.rst against usbsdmux -h output #64

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/readme.py
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 17 additions & 0 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 18 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the indention from the conventional three spaces to four spaces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… conventional three spaces …

Tehe, the reStructuredText format never fails to surprise me.

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
-------------
Expand Down
Loading