Add new GitHub Actions workflows for documentation

This commit is contained in:
geoffsee
2025-08-14 16:39:28 -04:00
parent 24d7d0bf5a
commit 21c816b4cc

135
.github/workflows/docs.yml vendored Normal file
View File

@@ -0,0 +1,135 @@
name: Documentation
on:
push:
branches: [main]
paths:
- 'crates/hyper-custom-cert/src/**'
- 'crates/hyper-custom-cert/README.md'
- 'README.md'
- 'crates/hyper-custom-cert/Cargo.toml'
- '.github/workflows/docs.yml'
pull_request:
branches: [main]
paths:
- 'crates/hyper-custom-cert/src/**'
- 'crates/hyper-custom-cert/README.md'
- 'README.md'
- 'crates/hyper-custom-cert/Cargo.toml'
- '.github/workflows/docs.yml'
jobs:
docs:
name: Build and validate documentation
runs-on: ubuntu-latest
defaults:
run:
working-directory: crates/hyper-custom-cert
strategy:
fail-fast: false
matrix:
include:
- name: default-features
features: ""
no-default-features: false
- name: no-default-features
features: ""
no-default-features: true
- name: rustls
features: "rustls"
no-default-features: true
- name: insecure-dangerous
features: "insecure-dangerous"
no-default-features: false
- name: all-features
features: "rustls,insecure-dangerous"
no-default-features: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Build documentation
shell: bash
run: |
FLAGS=""
if [ "${{ matrix.no-default-features }}" = "true" ]; then FLAGS="$FLAGS --no-default-features"; fi
if [ -n "${{ matrix.features }}" ]; then FLAGS="$FLAGS --features ${{ matrix.features }}"; fi
echo "Running: cargo doc $FLAGS --no-deps"
cargo doc $FLAGS --no-deps
- name: Check documentation warnings
shell: bash
run: |
FLAGS=""
if [ "${{ matrix.no-default-features }}" = "true" ]; then FLAGS="$FLAGS --no-default-features"; fi
if [ -n "${{ matrix.features }}" ]; then FLAGS="$FLAGS --features ${{ matrix.features }}"; fi
echo "Running: cargo doc $FLAGS --no-deps"
RUSTDOCFLAGS="-D warnings" cargo doc $FLAGS --no-deps
- name: Test documentation examples
shell: bash
run: |
FLAGS=""
if [ "${{ matrix.no-default-features }}" = "true" ]; then FLAGS="$FLAGS --no-default-features"; fi
if [ -n "${{ matrix.features }}" ]; then FLAGS="$FLAGS --features ${{ matrix.features }}"; fi
echo "Running: cargo test --doc $FLAGS"
cargo test --doc $FLAGS
readme-sync:
name: Check README synchronization
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-readme
run: cargo install cargo-readme
- name: Check README is up to date
working-directory: crates/hyper-custom-cert
run: |
# Generate README from lib.rs documentation
cargo readme > README_generated.md
# Compare with existing README
if ! diff -u README.md README_generated.md; then
echo "ERROR: README.md is not synchronized with lib.rs documentation"
echo "Run 'cargo readme > README.md' in crates/hyper-custom-cert/ to update"
exit 1
fi
# Clean up
rm README_generated.md
link-check:
name: Check documentation links
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Build documentation
working-directory: crates/hyper-custom-cert
run: cargo doc --all-features --no-deps
- name: Install lychee
run: |
curl -sSL https://github.com/lycheeverse/lychee/releases/latest/download/lychee-x86_64-unknown-linux-gnu.tar.gz | tar xz
sudo mv lychee /usr/local/bin/
- name: Check links in documentation
run: |
# Check links in generated documentation
lychee 'crates/hyper-custom-cert/target/doc/**/*.html' --exclude-path target --base crates/hyper-custom-cert/target/doc
# Check links in README files
lychee README.md crates/hyper-custom-cert/README.md