Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
63 changes: 63 additions & 0 deletions .github/workflows/manual_build_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Manual Build and Deploy

on:
workflow_dispatch:
inputs:
environment:
description: 'The environment to build in'
required: true
type: string

jobs:
build_sections:
strategy:
matrix:
target: [c, emojis, mcp, mcp-pages, png_icons, png_icons_pages, svg_icons, svg_icons_pages, t, tldr]
uses: ./.github/workflows/targeted-build.yml
with:
build_target: ${{ matrix.target }}
environment: ${{ github.event.inputs.environment }}
secrets: inherit
outputs:
target: ${{ matrix.target }}


merge_build_outputs:
runs-on: ubuntu-latest
needs: build_sections

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download all partial build artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: false
path: ./dist-sections

- name: Merge builds
run: |
mkdir -p frontend/dist
for part in dist-sections/*; do
echo "🔧 Merging $part..."
rsync -a "$part"/ frontend/dist/
done
echo "✅ Final merged build ready in ./frontend/dist"

# Perhaps we only want this for debugging purposes
- name: List content of the final dist directory
run: |
echo "📂 Listing final dist directory:"
cd frontend/dist
du -sh ./* | sort -h
echo ""
echo "🔎 Full directory structure:"
find . -type f | sort

# TODO: Once we are happy with the build, update this step so it deploys the
# merged build to the correct environment based in the "environment" variable
- name: Deploy (example)
run: echo "🚀 Deploying merged build..."
70 changes: 70 additions & 0 deletions .github/workflows/targeted_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Targeted Build

on:
workflow_call:
inputs:
build_target:
description: 'The build target passed in from the caller workflow'
required: true
type: string
environment:
description: 'The environment to build in'
required: true
type: string

defaults:
run:
working-directory: frontend

jobs:
partial_build:
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: "1.1.34"

- name: Cache Bun dependencies
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('frontend/bun.lockb') }}

- name: Install dependencies
run: |
echo "💿 Installing dependencies..."
bun install --frozen-lockfile --no-cache

- name: Prepare target folder
run: |
echo "⚠️ Preparing target folder..."
./scripts/prepare_tmp_folders.sh ${{ github.event.inputs.build_target }}

- name: Build project
run: |
echo "🏗️ Building project..."
bun run build:prod --outDir "dist-${{ github.event.inputs.build_target }} --silent"
env:
PUBLIC_GA_ID: ${{ secrets.PUBLIC_GA_ID }}
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }}

- name: Restore tmp folders
if: always()
run: |
echo "♻️ Restoring tmp folders..."
./scripts/restore_tmp_folders.sh ${{ github.event.inputs.build_target }}

- name: Upload partial build artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: dist-${{ github.event.inputs.build_target }}
path: frontend/dist-${{ github.event.inputs.build_target }}
88 changes: 88 additions & 0 deletions frontend/benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env bash
set -euo pipefail

# --------------------------------------
# 🚀 Astro Build Benchmark
# Sequential runs, live progress and merged JSON output
# --------------------------------------

NODE_MEMORY="--max-old-space-size=16384"
THREADPOOL_SIZE=4
CLEAN_CMD='rm -rf dist .astro'
RESULTS_FILE="hyperfine_results.json"
SPINNER_CHARS="/-\|"

# Define your benchmark targets
declare -a JOBS=(
"c"
"emojis"
"mcp"
"mcp-pages"
"png_icons"
"png_icons_pages"
"svg_icons"
"svg_icons_pages"
"t"
"tldr"
)

# Check dependencies
if ! command -v hyperfine >/dev/null 2>&1; then
echo "❌ 'hyperfine' not installed!"
exit 1
fi
if ! command -v jq >/dev/null 2>&1; then
echo "❌ 'jq' not installed!"
exit 1
fi

echo "🧹 Cleaning build directories..."
eval "$CLEAN_CMD"
echo "⚙️ Starting sequential benchmarks..."
echo

# Start with empty results array
echo '{"results":[]}' > "$RESULTS_FILE"

# Loop through jobs
for i in "${!JOBS[@]}"; do
JOB="${JOBS[$i]}"
printf "🔄 [%d/%d] %-15s " "$((i+1))" "${#JOBS[@]}" "$JOB"

# Run hyperfine in the background for this job
(
hyperfine \
--warmup 0 \
--runs 1 \
--prepare "$CLEAN_CMD" \
--export-json tmp_result.json \
"./scripts/prepare_tmp_folders.sh $JOB && UV_THREADPOOL_SIZE=$THREADPOOL_SIZE bun astro build --mode production --silent > /dev/null && ./scripts/restore_tmp_folders.sh" \
> /dev/null 2>&1
) &
PID=$!

# Spinner loop
j=0
while kill -0 "$PID" 2>/dev/null; do
j=$(( (j+1) %4 ))
printf "\r🔄 [%d/%d] %-15s %s" "$((i+1))" "${#JOBS[@]}" "$JOB" "${SPINNER_CHARS:$j:1}"
sleep 0.15
done

# Wait for job and print result
if wait "$PID"; then
printf "\r✅ [%d/%d] %-15s done!\n" "$((i+1))" "${#JOBS[@]}" "$JOB"
# Merge JSON arrays
jq --slurpfile new_results tmp_result.json '.results += $new_results[0].results' "$RESULTS_FILE" > tmp_merge.json
mv tmp_merge.json "$RESULTS_FILE"
else
printf "\r❌ [%d/%d] %-15s failed!\n" "$((i+1))" "${#JOBS[@]}" "$JOB"
fi
done

# Cleanup temp files
rm -f tmp_result.json tmp_merge.json

echo
echo "✅ Benchmark complete!"
echo "📊 Combined results saved to: $RESULTS_FILE"
Loading