| 1 |
# spell-checker:ignore mandoc uudoc manpages 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 |
permissions: |
| 26 |
contents: read |
| 27 |
|
| 28 |
jobs: |
| 29 |
manpage-lint: |
| 30 |
name: Validate manpages with mandoc |
| 31 |
runs-on: ubuntu-latest |
| 32 |
strategy: |
| 33 |
matrix: |
| 34 |
locale: [en_US.UTF-8, fr_FR.UTF-8] |
| 35 |
|
| 36 |
steps: |
| 37 |
- name: Checkout repository |
| 38 |
uses: actions/[email protected] |
| 39 |
with: |
| 40 |
persist-credentials: false |
| 41 |
|
| 42 |
- name: Install prerequisites |
| 43 |
shell: bash |
| 44 |
run: | |
| 45 |
sudo apt-get update |
| 46 |
sudo apt-get install -y mandoc locales-all |
| 47 |
sudo apt-get install -y libselinux1-dev libsystemd-dev libacl1-dev libattr1-dev libcap-dev |
| 48 |
|
| 49 |
- name: Build manpages (${{ matrix.locale }}) |
| 50 |
run: | |
| 51 |
# Create temporary directory for manpages |
| 52 |
MANPAGE_DIR=$(mktemp -d) |
| 53 |
echo "MANPAGE_DIR=${MANPAGE_DIR}" >> $GITHUB_ENV |
| 54 |
|
| 55 |
# Set locale for manpage generation |
| 56 |
export LANG=${{ matrix.locale }} |
| 57 |
|
| 58 |
# Build and install manpages to temporary directory |
| 59 |
make install-manpages DESTDIR="${MANPAGE_DIR}" |
| 60 |
|
| 61 |
- name: Validate manpages with mandoc (${{ matrix.locale }}) |
| 62 |
run: | |
| 63 |
# Find all generated manpages |
| 64 |
MANPAGE_PATH="${MANPAGE_DIR}/usr/local/share/man/man1" |
| 65 |
|
| 66 |
# Check if manpages were generated |
| 67 |
if [ ! -d "${MANPAGE_PATH}" ]; then |
| 68 |
echo "Error: No manpages found at ${MANPAGE_PATH}" |
| 69 |
exit 1 |
| 70 |
fi |
| 71 |
|
| 72 |
# Initialize error tracking |
| 73 |
ERRORS_FOUND=0 |
| 74 |
ERROR_LOG=$(mktemp) |
| 75 |
|
| 76 |
echo "Validating ${{ matrix.locale }} manpages with mandoc..." |
| 77 |
echo "==========================================" |
| 78 |
|
| 79 |
# Validate each manpage |
| 80 |
for manpage in "${MANPAGE_PATH}"/*.1; do |
| 81 |
if [ -f "$manpage" ]; then |
| 82 |
filename=$(basename "$manpage") |
| 83 |
|
| 84 |
# Run mandoc lint and capture output (only errors, not style warnings) |
| 85 |
if ! mandoc -T lint -W error "$manpage" 2>&1 | tee -a "$ERROR_LOG"; then |
| 86 |
echo "Errors found in $filename" |
| 87 |
ERRORS_FOUND=1 |
| 88 |
else |
| 89 |
# Check if mandoc produced any output (errors only, not style warnings) |
| 90 |
if mandoc -T lint -W error "$manpage" 2>&1 | grep -q .; then |
| 91 |
echo "Warnings found in $filename" |
| 92 |
ERRORS_FOUND=1 |
| 93 |
else |
| 94 |
echo "$filename is valid" |
| 95 |
fi |
| 96 |
fi |
| 97 |
fi |
| 98 |
done |
| 99 |
|
| 100 |
echo "" |
| 101 |
echo "==================================" |
| 102 |
|
| 103 |
# Summary and exit |
| 104 |
if [ "$ERRORS_FOUND" -eq 1 ]; then |
| 105 |
echo "Manpage validation failed. Issues found:" |
| 106 |
echo "" |
| 107 |
cat "$ERROR_LOG" |
| 108 |
exit 1 |
| 109 |
else |
| 110 |
echo "All manpages validated successfully!" |
| 111 |
fi |