Files
cs249r_book/.github/workflows/mlsysim-preview-dev.yml
Vijay Janapa Reddi e5ecf995ee chore(tutorial): update CI pipelines, docs, and Makefiles for the new 4-module tutorial structure
- Updated all GitHub Actions workflows (build-pdfs, preview-dev, publish-live, update-pdfs) to loop over `tutorial_module1` through `tutorial_module4` instead of the legacy `part1`/`part2`.
- Updated Quarto documentation (`slides.qmd`, `_quarto-html.yml`) to correctly surface the 4 new module PDFs on the website.
- Updated the tutorial Makefile to compile all 4 modules.
- Updated `.gitignore` and instructor quickstart documentation to reflect the new slide outputs.
2026-05-27 16:47:56 -04:00

195 lines
6.6 KiB
YAML

name: '🧮 MLSYSIM · 👁️ Preview (Dev)'
# =============================================================================
# MLSYSIM — Dev Preview Deploy
# =============================================================================
#
# Builds the MLSYSIM simulation engine docs site (Quarto) with the research
# paper PDF and deploys to the dev preview site via SSH.
#
# Flow:
# 1. BUILD_PDF — Compile research paper PDF (reusable workflow)
# 2. BUILD_SITE — Quarto render + inject PDF into docs
# 3. DEPLOY — Push to dev preview repo via SSH
#
# Triggers:
# - push: dev branch, mlsysim/** paths
# - workflow_dispatch: manual
#
# Deploys to: harvard-edge.github.io/{DEV_REPO}/{DEV_MLSYSIM_PATH}/
# Secrets: SSH_DEPLOY_KEY
# Vars: MLSYSIM_DOCS, BOOK_TOOLS, DEV_REPO, DEV_REPO_URL, DEV_MLSYSIM_PATH
#
# Related:
# - mlsysim-validate-dev.yml — Tests + build validation
# - mlsysim-publish-live.yml — Production deploy to mlsysbook.ai/mlsysim/
# - mlsysim-build-pdfs.yml — Reusable PDF build
#
# =============================================================================
on:
workflow_dispatch:
push:
branches: [dev]
paths:
- 'mlsysim/**'
permissions:
contents: read
actions: read
concurrency:
group: mlsysim-dev-deploy
cancel-in-progress: true
jobs:
# Run the full validate-dev workflow inline. Deploy depends on it so
# Preview can never deploy on a SHA where validate failed (the bug
# this gating closes is the screenshot pattern of "Preview ✅ but
# Validate ❌ on the same SHA"). Validate runs in parallel with
# build-pdf, so wall-clock impact is small.
validate:
name: '✅ Validate (Dev)'
uses: ./.github/workflows/mlsysim-validate-dev.yml
# Build PDF first (reusable workflow)
build-pdf:
name: '📄 Build PDF'
uses: ./.github/workflows/mlsysim-build-pdfs.yml
with:
ref: ${{ github.ref }}
build-and-deploy:
name: '🧮 Build & Deploy MLSYSIM (Dev)'
runs-on: ubuntu-latest
needs: [validate, build-pdf]
steps:
- name: 📥 Checkout
uses: actions/checkout@v6
- name: 🔧 Setup Quarto
uses: quarto-dev/quarto-actions/setup@v2
- name: 🐍 Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: 🐍 Install Python dependencies
working-directory: mlsysim
run: pip install ".[docs]"
- name: 📥 Download Paper PDF
uses: actions/download-artifact@v8
continue-on-error: true
with:
name: MLSYSIM-Paper
path: ./pdf-artifacts/
- name: 📥 Download Tutorial Slides
uses: actions/download-artifact@v8
continue-on-error: true
with:
name: MLSYSIM-Slides
path: ./slide-artifacts/
- name: 📁 Inject PDFs into docs
run: |
if [ -f ./pdf-artifacts/paper.pdf ]; then
cp ./pdf-artifacts/paper.pdf ${{ vars.MLSYSIM_DOCS }}/mlsysim-paper.pdf
echo "✅ Injected mlsysim-paper.pdf"
else
echo "⚠️ Paper PDF not found in artifacts, continuing without it"
fi
for part in tutorial_module1 tutorial_module2 tutorial_module3 tutorial_module4; do
src="./slide-artifacts/${part}.pdf"
if [ -f "$src" ]; then
cp "$src" "${{ vars.MLSYSIM_DOCS }}/${part}.pdf"
echo "✅ Injected ${part}.pdf"
else
echo "⚠️ ${part}.pdf not found in artifacts, continuing without it"
fi
done
- name: 🔨 Build MLSYSIM Site
working-directory: ${{ vars.MLSYSIM_DOCS }}
run: |
quarto render
touch _build/.nojekyll
- name: 🔗 Rewrite URLs for dev site
run: bash .github/scripts/rewrite-dev-urls.sh mlsysim ${{ vars.MLSYSIM_DOCS }}/_build
- name: 🔧 Modify announcement for dev preview
run: |
echo "🔧 Modifying announcement banner for development preview..."
COMMIT_SHORT="${{ github.sha }}"
COMMIT_SHORT="${COMMIT_SHORT:0:8}"
python3 ${{ vars.BOOK_TOOLS }}/scripts/publish/modify_dev_announcement.py \
${{ vars.MLSYSIM_DOCS }}/_build \
--verbose \
--commit-hash "${{ github.sha }}" \
--commit-short "$COMMIT_SHORT"
- name: 🚀 Deploy to Dev Site via SSH
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
run: |
echo "🔐 Starting ssh-agent..."
eval "$(ssh-agent -s)"
echo "$SSH_DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null
# Add github.com to known hosts
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
echo "🔧 Configuring git..."
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
echo "🔄 Cloning dev preview repository (${{ vars.DEV_REPO }})..."
git clone --depth=1 ${{ vars.DEV_REPO_URL }} target-repo
cd target-repo
echo "🧹 Cleaning ${{ vars.DEV_MLSYSIM_PATH }} directory..."
rm -rf ${{ vars.DEV_MLSYSIM_PATH }}
mkdir -p ${{ vars.DEV_MLSYSIM_PATH }}
echo "🚚 Copying MLSYSIM site content..."
cp -r "${{ github.workspace }}/${{ vars.MLSYSIM_DOCS }}/_build/." ${{ vars.DEV_MLSYSIM_PATH }}/
echo "🔍 Validating deployment content..."
if [ ! -f "${{ vars.DEV_MLSYSIM_PATH }}/index.html" ]; then
echo "❌ CRITICAL: ${{ vars.DEV_MLSYSIM_PATH }}/index.html is missing. Aborting deployment."
exit 1
fi
echo "🧮 Contents of ${{ vars.DEV_MLSYSIM_PATH }}/:"
ls -la ${{ vars.DEV_MLSYSIM_PATH }}/ | head -10
echo "🧮 Committing and pushing changes..."
git add .
git commit -m "🧮 Deploy MLSYSIM dev to /${{ vars.DEV_MLSYSIM_PATH }}/ from ${{ github.sha }}" --allow-empty || echo "🟡 Nothing to commit"
# Retry push with rebase to handle concurrent deploys
PUSHED=false
for i in 1 2 3; do
if git push origin main 2>/dev/null; then
echo "✅ Push succeeded on attempt $i"
PUSHED=true
break
fi
echo "⚠️ Push failed (attempt $i/3), pulling with rebase..."
git pull --rebase origin main || true
done
if [ "$PUSHED" != "true" ]; then
echo "❌ Push failed after 3 attempts."
exit 1
fi
echo "✅ MLSYSIM deployed to: https://harvard-edge.github.io/${{ vars.DEV_REPO }}/${{ vars.DEV_MLSYSIM_PATH }}/"