Skip to content
Open
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
109 changes: 109 additions & 0 deletions .github/workflows/manpage-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# spell-checker:ignore mandoc uudoc manpages dtolnay libsystemd libattr libcap DESTDIR

name: Manpage Validation

on:
pull_request:
paths:
- 'src/bin/uudoc.rs'
- 'src/uu/*/locales/*.ftl'
- 'src/uu/*/src/*.rs'
- 'Cargo.toml'
- 'GNUmakefile'
- '.github/workflows/manpage-lint.yml'
push:
branches:
- main
paths:
- 'src/bin/uudoc.rs'
- 'src/uu/*/locales/*.ftl'
- 'src/uu/*/src/*.rs'
- 'Cargo.toml'
- 'GNUmakefile'
- '.github/workflows/manpage-lint.yml'

jobs:
manpage-lint:
name: Validate manpages with mandoc
runs-on: ubuntu-latest
strategy:
matrix:
locale: [en_US.UTF-8, fr_FR.UTF-8]

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Install prerequisites
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y mandoc locales-all
sudo apt-get install -y libselinux1-dev libsystemd-dev libacl1-dev libattr1-dev libcap-dev

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Build manpages (${{ matrix.locale }})
run: |
# Create temporary directory for manpages
MANPAGE_DIR=$(mktemp -d)
echo "MANPAGE_DIR=${MANPAGE_DIR}" >> $GITHUB_ENV

# Set locale for manpage generation
export LANG=${{ matrix.locale }}

# Build and install manpages to temporary directory
make install-manpages DESTDIR="${MANPAGE_DIR}"

- name: Validate manpages with mandoc (${{ matrix.locale }})
run: |
# Find all generated manpages
MANPAGE_PATH="${MANPAGE_DIR}/usr/local/share/man/man1"

# Check if manpages were generated
if [ ! -d "${MANPAGE_PATH}" ]; then
echo "Error: No manpages found at ${MANPAGE_PATH}"
exit 1
fi

# Initialize error tracking
ERRORS_FOUND=0
ERROR_LOG=$(mktemp)

echo "Validating ${{ matrix.locale }} manpages with mandoc..."
echo "=========================================="

# Validate each manpage
for manpage in "${MANPAGE_PATH}"/*.1; do
if [ -f "$manpage" ]; then
filename=$(basename "$manpage")

# Run mandoc lint and capture output (only errors, not style warnings)
if ! mandoc -T lint -W error "$manpage" 2>&1 | tee -a "$ERROR_LOG"; then
echo "Errors found in $filename"
ERRORS_FOUND=1
else
# Check if mandoc produced any output (errors only, not style warnings)
if mandoc -T lint -W error "$manpage" 2>&1 | grep -q .; then
echo "Warnings found in $filename"
ERRORS_FOUND=1
else
echo "$filename is valid"
fi
fi
fi
done

echo ""
echo "=================================="

# Summary and exit
if [ "$ERRORS_FOUND" -eq 1 ]; then
echo "Manpage validation failed. Issues found:"
echo ""
cat "$ERROR_LOG"
exit 1
else
echo "All manpages validated successfully!"
fi
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ expensive_tests = []
# "test_risky_names" == enable tests that create problematic file names (would make a network share inaccessible to Windows, breaks SVN on Mac OS, etc.)
test_risky_names = []
# * only build `uudoc` when `--feature uudoc` is activated
uudoc = ["dep:clap_complete", "dep:clap_mangen", "dep:fluent-syntax", "dep:zip"]
uudoc = [
"dep:clap_complete",
"dep:clap_mangen",
"dep:fluent-syntax",
"dep:jiff",
"dep:regex",
"dep:zip",
]
## features
## Optional feature for stdbuf
# "feat_external_libstdbuf" == use an external libstdbuf.so for stdbuf instead of embedding it
Expand Down Expand Up @@ -475,6 +482,8 @@ clap_complete = { workspace = true, optional = true }
clap_mangen = { workspace = true, optional = true }
clap.workspace = true
fluent-syntax = { workspace = true, optional = true }
jiff = { workspace = true, optional = true }
regex = { workspace = true, optional = true }
itertools.workspace = true
phf.workspace = true
selinux = { workspace = true, optional = true }
Expand Down
Loading
Loading