fix docs build #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Cache: 202509060012 | |
| name: Docs | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "docs/**" | |
| - ".github/workflows/docs.yml" | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| test_and_lint: | |
| name: CI Gate (tests + lint) | |
| runs-on: ubuntu-latest | |
| container: | |
| image: rust:1.88.0 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Install rustfmt and clippy | |
| run: | | |
| rustup component add rustfmt clippy | |
| - name: Get pnpm store directory | |
| id: pnpm-cache | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path)" >> "$GITHUB_OUTPUT" | |
| - name: Cache pnpm dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm- | |
| - name: Cache cargo dependencies and build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo | |
| target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Install pnpm dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Add node_modules/.bin to PATH | |
| run: echo "$PWD/node_modules/.bin" >> "$GITHUB_PATH" | |
| - name: Download cargo dependencies | |
| run: cargo fetch --locked | |
| - name: Check formatting | |
| run: cargo fmt -- --check | |
| - name: Run linting | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| - name: Run tests | |
| run: cargo test --all | |
| build: | |
| name: Build Docs | |
| runs-on: ubuntu-latest | |
| needs: test_and_lint | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Install root deps (if any) | |
| run: | | |
| pnpm install --frozen-lockfile || pnpm install | |
| - name: Build docs (if present) | |
| run: | | |
| set -e | |
| if [ -f docs/package.json ]; then | |
| cd docs | |
| pnpm install --frozen-lockfile || pnpm install | |
| if pnpm run -s build; then | |
| echo "Docs built with pnpm" | |
| elif npm run build; then | |
| echo "Docs built with npm" | |
| else | |
| echo "Docs build script not found" >&2 | |
| exit 1 | |
| fi | |
| if [ ! -d dist ]; then | |
| echo "Docs build output not found at dist/" >&2 | |
| exit 1 | |
| fi | |
| else | |
| echo "docs/package.json not found; docs site missing" >&2 | |
| exit 1 | |
| fi | |
| - name: Verify docs output exists | |
| run: | | |
| if [ ! -d docs/dist ]; then | |
| echo "Docs build output not found at docs/dist" >&2 | |
| exit 1 | |
| fi | |
| - name: Configure Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: docs/dist | |
| deploy: | |
| name: Deploy Docs | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |