name: Documentation on: push: tags: - 'v*' 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 - uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Setup Rust run: rustup update stable && rustup default 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 - uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Setup Rust run: rustup update stable && rustup default 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 - uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Setup Rust run: rustup update stable && rustup default 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