Skip to content

Feature/static collections 118 #193

Feature/static collections 118

Feature/static collections 118 #193

Workflow file for this run

# Workflow for deploying Sphinx documentation to GitHub Pages
name: Deploy Documentation to Pages
on:
# Runs on pushes targeting the default branch or tags
push:
branches: ["main"]
tags:
- '[0-9]+.[0-9]+.[0-9]+'
# Runs on pull requests to test the build
pull_request:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
version:
description: 'Version to build and deploy (leave empty for automatic detection)'
required: false
default: ''
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
# We need history to get tags
fetch-depth: 0
- name: Setup Dagger CLI
run: |
curl -L https://dl.dagger.io/dagger/install.sh | sh
echo "$HOME/.dagger/bin" >> $GITHUB_PATH
- name: Start Docker service (required for Dagger)
run: |
# Ensure Docker is running
sudo systemctl status docker || sudo systemctl start docker
docker version
- name: Check Dagger version
run: |
export PATH="$(pwd)/bin:$PATH"
pwd
find . -name "dagger"
dagger version
echo $PATH
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: llvm-tools-preview
- name: Cache cargo dependencies
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: Determine versions to build
id: get-versions
run: |
VERSIONS_TO_PASS=""
if [ -n "${{ github.event.inputs.version }}" ]; then
VERSIONS_TO_PASS="${{ github.event.inputs.version }}"
echo "::notice::Using specific version(s) from input: $VERSIONS_TO_PASS"
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSIONS_TO_PASS="${{ github.ref_name }}"
echo "::notice::Building docs for tag: $VERSIONS_TO_PASS"
elif [[ "${{ github.ref_name }}" == "main" && "${{ github.ref_type }}" == "branch" ]]; then
VERSIONS_TO_PASS="main"
echo "::notice::Building docs for main branch"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
# For pull requests, build as 'local' version to use local working directory
VERSIONS_TO_PASS="local"
echo "::notice::Building docs for pull request using local working directory"
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
# This case handles manual trigger where inputs.version was empty (default)
VERSIONS_TO_PASS="main"
echo "::notice::Manual trigger with no specific version input, defaulting to build 'main'."
else
echo "::error::Could not determine a version to build. Event: ${{ github.event_name }}, Ref: ${{ github.ref }} (Name: ${{ github.ref_name }}, Type: ${{ github.ref_type }})"
exit 1
fi
# If VERSIONS_TO_PASS can contain multiple space-separated versions (e.g. from input), ensure uniqueness.
# The cargo-wrt expects space-separated versions.
UNIQUE_VERSIONS=$(echo "$VERSIONS_TO_PASS" | xargs -n1 | sort -u | xargs)
echo "VERSIONS_TO_BUILD=$UNIQUE_VERSIONS" >> $GITHUB_ENV
echo "Final list of versions to build for cargo-wrt: $UNIQUE_VERSIONS"
- name: Generate code coverage for documentation
run: |
echo "Generating code coverage for documentation inclusion"
# Ensure cargo-wrt is compiled and installed
cargo build --package cargo-wrt
cargo install --path cargo-wrt --force
# Add Dagger to PATH
export PATH="$HOME/.dagger/bin:$(pwd)/bin:$PATH"
echo $PATH
# Run coverage analysis in best-effort mode for documentation
echo "Running coverage analysis in best-effort mode..."
cargo-wrt coverage --html --best-effort
env:
RUST_LOG: info
RUST_BACKTRACE: 1
# Dagger configuration
_EXPERIMENTAL_DAGGER_CLOUD_TOKEN: ""
DAGGER_LOG_LEVEL: info
# CI environment flag
CI: true
- name: Build documentation via cargo-wrt
run: |
echo "Building documentation for versions: ${{ env.VERSIONS_TO_BUILD }}"
export PATH="$HOME/.dagger/bin:$(pwd)/bin:$PATH"
cargo-wrt docs --open --private --output-dir ./docs_output
env:
RUST_LOG: info
RUST_BACKTRACE: 1
# Dagger configuration
_EXPERIMENTAL_DAGGER_CLOUD_TOKEN: ""
DAGGER_LOG_LEVEL: info
DAGGER_LOG_FORMAT: plain
# CI environment flag
CI: true
- name: Prepare documentation artifact
run: |
# Create the expected artifact directory
mkdir -p ./docs_artifact_final
# Copy Sphinx HTML documentation if it exists
if [ -d "./docs_output/sphinx/html" ]; then
echo "📚 Found Sphinx documentation"
cp -r ./docs_output/sphinx/html/* ./docs_artifact_final/
elif [ -d "./docs/build/html" ]; then
echo "📚 Found Sphinx documentation (fallback path)"
cp -r ./docs/build/html/* ./docs_artifact_final/
fi
# Copy Rust API documentation
if [ -d "./docs_output/doc" ]; then
echo "📖 Found Rust API documentation"
mkdir -p ./docs_artifact_final/api
cp -r ./docs_output/doc/* ./docs_artifact_final/api/
elif [ -d "./target/doc" ]; then
echo "📖 Found Rust API documentation (fallback path)"
mkdir -p ./docs_artifact_final/api
cp -r ./target/doc/* ./docs_artifact_final/api/
fi
# Create a simple index.html if none exists
if [ ! -f "./docs_artifact_final/index.html" ]; then
echo "⚠️ No index.html found, creating redirect to API docs"
cat > ./docs_artifact_final/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WRT Documentation</title>
<meta http-equiv="refresh" content="0; url=api/wrt/index.html">
</head>
<body>
<p>Redirecting to <a href="api/wrt/index.html">WRT API Documentation</a>...</p>
</body>
</html>
EOF
fi
# List what we're uploading
echo "📦 Documentation artifact contents:"
ls -la ./docs_artifact_final/
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: './docs_artifact_final' # Path to the prepared documentation artifact
# Deployment job
deploy:
# Only deploy when not a pull request
if: github.event_name != 'pull_request'
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