feat(pdf): pcolormesh inline image (Flate) for smaller PDFs (#1231) #730
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
name: Deploy Documentation to GitHub Pages | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: ["main"] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# 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@v4 | |
- name: Setup Fortran | |
uses: fortran-lang/setup-fortran@v1 | |
with: | |
compiler: gcc | |
version: 13 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
cache: 'pip' | |
cache-dependency-path: 'doc/requirements-doc.txt' | |
- name: Cache and install APT packages (ffmpeg) | |
uses: awalsh128/cache-apt-pkgs-action@v1 | |
with: | |
packages: ffmpeg | |
version: 1.1 | |
- name: Install BLAS/LAPACK runtime | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libblas3 liblapack3 | |
- name: Install dependencies | |
run: | | |
# Python packages (cached via setup-python) | |
pip install -r doc/requirements-doc.txt | |
# Install fpm (Fortran Package Manager) - same version as CI | |
wget https://github.com/fortran-lang/fpm/releases/download/v0.12.0/fpm-0.12.0-linux-x86_64-gcc-12 | |
chmod +x fpm-0.12.0-linux-x86_64-gcc-12 | |
sudo mv fpm-0.12.0-linux-x86_64-gcc-12 /usr/local/bin/fpm | |
- name: Build fortplot | |
run: make build | |
- name: Generate example outputs | |
run: | | |
# Create output directories | |
mkdir -p doc/media/examples | |
# Run all examples to generate outputs | |
make example | |
# Build and run special examples (including animation) | |
chmod +x scripts/compile_special_examples.sh | |
# Do not swallow failures here; if animation fails, we want CI to fail | |
./scripts/compile_special_examples.sh | |
# Copy generated outputs to media directory (preserving structure) | |
for dir in output/example/fortran/*/; do | |
if [ -d "$dir" ]; then | |
example_name=$(basename "$dir") | |
mkdir -p "doc/media/examples/${example_name}" | |
cp "${dir}"*.png "doc/media/examples/${example_name}/" 2>/dev/null || true | |
cp "${dir}"*.txt "doc/media/examples/${example_name}/" 2>/dev/null || true | |
cp "${dir}"*.pdf "doc/media/examples/${example_name}/" 2>/dev/null || true | |
cp "${dir}"*.mp4 "doc/media/examples/${example_name}/" 2>/dev/null || true | |
fi | |
done | |
# Documentation now consolidated in example/fortran/*/README.md - no generation needed | |
- name: Build documentation | |
run: | | |
# Run make doc (which runs FORD then copies media) | |
make doc | |
# Verify all example pages were generated | |
echo "Checking generated example pages..." | |
expected_pages="animation annotation_demo ascii_heatmap basic_plots colored_contours contour_demo format_string_demo legend_box_demo legend_demo line_styles marker_demo pcolormesh_demo scale_examples show_viewer_demo smart_show_demo streamplot_demo unicode_demo" | |
expected_count=$(echo $expected_pages | wc -w) | |
echo "Expecting $expected_count example pages" | |
missing_pages="" | |
for page in $expected_pages; do | |
if [ ! -f "build/doc/page/examples/${page}.html" ]; then | |
echo "WARNING: Missing example page: ${page}.html" | |
missing_pages="$missing_pages $page" | |
fi | |
done | |
if [ -n "$missing_pages" ]; then | |
missing_count=$(echo $missing_pages | wc -w) | |
found_count=$((expected_count - missing_count)) | |
echo "ERROR: Generated only $found_count/$expected_count pages. Missing:$missing_pages" | |
echo "Listing actually generated pages:" | |
ls -la build/doc/page/examples/*.html || echo "No HTML files found" | |
exit 1 | |
fi | |
echo "SUCCESS: All $expected_count expected example pages generated" | |
# Documentation consolidated to example/fortran/*/README.md files | |
- name: Validate docs media (no silent failures) | |
run: | | |
set -euo pipefail | |
# Basic structure check | |
bash scripts/validate_github_pages_images.sh | |
# Animation must exist at page-relative media path used by FORD pages | |
test -f build/doc/page/media/examples/animation/animation.mp4 || { | |
echo "CRITICAL: animation.mp4 missing under build/doc/page/media/examples/animation/"; | |
echo "Listing nearby files for debugging:"; | |
find build/doc -maxdepth 4 -type f -name "animation.mp4" -printf "%p\n" || true; | |
echo "Listing output/example tree:"; | |
find output/example/fortran -maxdepth 2 -type f -printf "%p\n" || true; | |
exit 1; | |
} | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
# Upload only the documentation directory | |
path: './build/doc' | |
# Deploy job | |
deploy: | |
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 |