Skip to content

Commit 27f45d4

Browse files
committed
ci: add GitHub Action to validate manpages with mandoc
Add a new workflow that builds and validates all manpages using mandoc -T lint. The workflow runs on PRs and pushes that modify manpage-related files and validates both English and French manpages in parallel.
1 parent bf9a10f commit 27f45d4

1 file changed

Lines changed: 120 additions & 0 deletions

File tree

.github/workflows/manpage-lint.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# spell-checker:ignore mandoc uudoc manpages dtolnay libsystemd libattr libcap DESTDIR
2+
3+
name: Manpage Validation
4+
5+
on:
6+
pull_request:
7+
paths:
8+
- 'src/bin/uudoc.rs'
9+
- 'src/uu/*/locales/*.ftl'
10+
- 'src/uu/*/src/*.rs'
11+
- 'Cargo.toml'
12+
- 'GNUmakefile'
13+
- '.github/workflows/manpage-lint.yml'
14+
push:
15+
branches:
16+
- main
17+
paths:
18+
- 'src/bin/uudoc.rs'
19+
- 'src/uu/*/locales/*.ftl'
20+
- 'src/uu/*/src/*.rs'
21+
- 'Cargo.toml'
22+
- 'GNUmakefile'
23+
- '.github/workflows/manpage-lint.yml'
24+
25+
jobs:
26+
manpage-lint:
27+
name: Validate manpages with mandoc
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
locale: [en, fr]
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v6
36+
37+
- name: Install prerequisites
38+
shell: bash
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y mandoc locales-all
42+
sudo apt-get install -y libselinux1-dev libsystemd-dev libacl1-dev libattr1-dev libcap-dev
43+
44+
- name: Install Rust toolchain
45+
uses: dtolnay/rust-toolchain@stable
46+
47+
- name: Build manpages (${{ matrix.locale }})
48+
run: |
49+
# Create temporary directory for manpages
50+
MANPAGE_DIR=$(mktemp -d)
51+
echo "MANPAGE_DIR=${MANPAGE_DIR}" >> $GITHUB_ENV
52+
53+
# Set locale for manpage generation
54+
if [ "${{ matrix.locale }}" = "fr" ]; then
55+
export LANGUAGE=fr_FR.UTF-8
56+
export LANG=fr_FR.UTF-8
57+
export LC_ALL=fr_FR.UTF-8
58+
fi
59+
60+
# Build and install manpages to temporary directory
61+
make install-manpages DESTDIR="${MANPAGE_DIR}"
62+
63+
- name: Validate manpages with mandoc (${{ matrix.locale }})
64+
run: |
65+
# Find all generated manpages
66+
MANPAGE_PATH="${MANPAGE_DIR}/usr/local/share/man/man1"
67+
68+
# Check if manpages were generated
69+
if [ ! -d "${MANPAGE_PATH}" ]; then
70+
echo "Error: No manpages found at ${MANPAGE_PATH}"
71+
exit 1
72+
fi
73+
74+
# Initialize error tracking
75+
ERRORS_FOUND=0
76+
ERROR_LOG=$(mktemp)
77+
78+
echo "Validating ${{ matrix.locale }} manpages with mandoc..."
79+
echo "=========================================="
80+
81+
# Validate each manpage
82+
for manpage in "${MANPAGE_PATH}"/*.1; do
83+
if [ -f "$manpage" ]; then
84+
filename=$(basename "$manpage")
85+
echo "Checking: $filename"
86+
87+
# Run mandoc lint and capture output
88+
if ! mandoc -T lint "$manpage" 2>&1 | tee -a "$ERROR_LOG"; then
89+
echo " ✗ Errors found in $filename"
90+
ERRORS_FOUND=1
91+
else
92+
# Check if mandoc produced any output (warnings/errors)
93+
if mandoc -T lint "$manpage" 2>&1 | grep -q .; then
94+
echo " ⚠ Warnings found in $filename"
95+
ERRORS_FOUND=1
96+
else
97+
echo "$filename is valid"
98+
fi
99+
fi
100+
fi
101+
done
102+
103+
echo ""
104+
echo "=================================="
105+
106+
# Summary and exit
107+
if [ "$ERRORS_FOUND" -eq 1 ]; then
108+
echo "Manpage validation failed. Issues found:"
109+
echo ""
110+
cat "$ERROR_LOG"
111+
exit 1
112+
else
113+
echo "All manpages validated successfully!"
114+
fi
115+
116+
- name: Count manpages (${{ matrix.locale }})
117+
run: |
118+
MANPAGE_PATH="${MANPAGE_DIR}/usr/local/share/man/man1"
119+
COUNT=$(find "${MANPAGE_PATH}" -name "*.1" -type f | wc -l)
120+
echo "Total ${{ matrix.locale }} manpages generated: $COUNT"

0 commit comments

Comments
 (0)