Skip to content

Commit c854208

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 4d51952 commit c854208

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

.github/workflows/manpage-lint.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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_US.UTF-8, fr_FR.UTF-8]
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+
export LANG=${{ matrix.locale }}
55+
56+
# Build and install manpages to temporary directory
57+
make install-manpages DESTDIR="${MANPAGE_DIR}"
58+
59+
- name: Validate manpages with mandoc (${{ matrix.locale }})
60+
run: |
61+
# Find all generated manpages
62+
MANPAGE_PATH="${MANPAGE_DIR}/usr/local/share/man/man1"
63+
64+
# Check if manpages were generated
65+
if [ ! -d "${MANPAGE_PATH}" ]; then
66+
echo "Error: No manpages found at ${MANPAGE_PATH}"
67+
exit 1
68+
fi
69+
70+
# Initialize error tracking
71+
ERRORS_FOUND=0
72+
ERROR_LOG=$(mktemp)
73+
74+
echo "Validating ${{ matrix.locale }} manpages with mandoc..."
75+
echo "=========================================="
76+
77+
# Validate each manpage
78+
for manpage in "${MANPAGE_PATH}"/*.1; do
79+
if [ -f "$manpage" ]; then
80+
filename=$(basename "$manpage")
81+
82+
# Run mandoc lint and capture output (only errors, not style warnings)
83+
if ! mandoc -T lint -W error "$manpage" 2>&1 | tee -a "$ERROR_LOG"; then
84+
echo "Errors found in $filename"
85+
ERRORS_FOUND=1
86+
else
87+
# Check if mandoc produced any output (errors only, not style warnings)
88+
if mandoc -T lint -W error "$manpage" 2>&1 | grep -q .; then
89+
echo "Warnings found in $filename"
90+
ERRORS_FOUND=1
91+
else
92+
echo "$filename is valid"
93+
fi
94+
fi
95+
fi
96+
done
97+
98+
echo ""
99+
echo "=================================="
100+
101+
# Summary and exit
102+
if [ "$ERRORS_FOUND" -eq 1 ]; then
103+
echo "Manpage validation failed. Issues found:"
104+
echo ""
105+
cat "$ERROR_LOG"
106+
exit 1
107+
else
108+
echo "All manpages validated successfully!"
109+
fi

0 commit comments

Comments
 (0)