Skip to content

Commit 0842df3

Browse files
committed
ci: add workflow to check CLI documentation sync
Add GitHub workflow that verifies CLI documentation stays in sync with implementation. The workflow runs on PRs, generates current docs, compares with existing docs, and comments on PR if outdated.
1 parent fe6e08e commit 0842df3

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Check CLI Documentation
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
check-docs:
9+
name: Verify CLI documentation is up-to-date
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.10"
19+
20+
- name: Install dependencies
21+
run: |
22+
python3 -m pip install --upgrade pip
23+
pip install -e .
24+
25+
- name: Generate current CLI documentation
26+
run: |
27+
typer pyaxm.cli utils docs --name pyaxm-cli --output /tmp/cli.md
28+
29+
- name: Compare with existing documentation
30+
id: compare_docs
31+
run: |
32+
# Calculate MD5 hashes for both files
33+
OLD_HASH=$(md5sum docs/cli.md | awk '{ print $1 }')
34+
NEW_HASH=$(md5sum /tmp/cli.md | awk '{ print $1 }')
35+
36+
# Compare hashes
37+
if [ "$OLD_HASH" != "$NEW_HASH" ]; then
38+
echo "docs_outdated=true" >> $GITHUB_OUTPUT
39+
exit 1
40+
else
41+
echo "CLI documentation is up-to-date."
42+
echo "Hash: $OLD_HASH"
43+
echo "docs_outdated=false" >> $GITHUB_OUTPUT
44+
fi
45+
46+
- name: Comment on PR if documentation is outdated
47+
if: ${{ steps.compare_docs.outputs.docs_outdated == 'true' }}
48+
uses: actions/github-script@v6
49+
with:
50+
github-token: ${{ secrets.GITHUB_TOKEN }}
51+
script: |
52+
const pull_request_number = context.issue.number;
53+
const comment = `🚨 **CLI Documentation Check Failed** 🚨
54+
55+
The CLI documentation in \`docs/cli.md\` is not up-to-date with the current code.
56+
57+
**What to do:**
58+
1. Run the following command locally to update the documentation:
59+
```bash
60+
typer pyaxm.cli utils docs --name pyaxm-cli --output docs/cli.md
61+
```
62+
2. Commit the updated \`docs/cli.md\` file
63+
3. Push your changes to update this pull request
64+
65+
This ensures that the documentation always reflects the actual CLI functionality.`;
66+
67+
github.rest.issues.createComment({
68+
owner: context.repo.owner,
69+
repo: context.repo.repo,
70+
issue_number: pull_request_number,
71+
body: comment
72+
});

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,19 @@ The token path is the location where the access token will be stored.
4141
## CLI:
4242
A command-line interface (CLI) tool called `pyaxm-cli` is included for easy access to the API.
4343

44-
For detailed usage instructions, available commands, options, and examples, please refer to the [CLI documentation](docs/cli.md).
44+
### Overview
45+
The CLI provides a convenient way to interact with the Apple Business Manager API directly from your terminal. It includes commands for managing devices, MDM servers, and retrieving device information.
46+
47+
### Detailed Documentation
48+
For comprehensive documentation of all available commands, options, and usage examples, please refer to the [CLI documentation](docs/cli.md).
49+
50+
### Updating Documentation
51+
The CLI documentation is automatically generated from the code. To update it after making changes to the CLI implementation, run:
52+
```bash
53+
typer pyaxm.cli utils docs --name pyaxm-cli --output docs/cli.md
54+
```
55+
56+
A GitHub workflow automatically checks that the documentation stays in sync.
4557

4658
# Client:
4759
Example usage:

0 commit comments

Comments
 (0)