[FA-13] Works locally, probably works in CICD

This commit is contained in:
gamer147
2025-11-22 18:14:01 -05:00
parent ceb4271182
commit df7978fb43
14 changed files with 236 additions and 19 deletions

View File

@@ -0,0 +1,104 @@
#!/usr/bin/env bash
set -euo pipefail
###############################################
# Resolve important directories
###############################################
# Directory where this script lives
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Services live one directory above the script's directory
SERVICES_DIR="$(cd "$ROOT/.." && pwd)"
###############################################
# Skip list (folder names, match exactly)
###############################################
SKIP_PROJECTS=(
"FictionArchive.Service.Shared"
"FictionArchive.Service.Legacy"
)
echo "----------------------------------------"
echo " Finding GraphQL services..."
echo "----------------------------------------"
SERVICE_LIST=()
# Convert skip projects into a single searchable string
SKIP_STRING=" ${SKIP_PROJECTS[*]} "
# Find service directories
shopt -s nullglob
for FOLDER in "$SERVICES_DIR"/FictionArchive.Service.*; do
[ -d "$FOLDER" ] || continue
PROJECT_NAME="$(basename "$FOLDER")"
# Skip entries that match the skip list
if [[ "$SKIP_STRING" == *" $PROJECT_NAME "* ]]; then
echo "Skipping service: $PROJECT_NAME"
continue
fi
echo "Found service: $PROJECT_NAME"
SERVICE_LIST+=("$FOLDER")
done
shopt -u nullglob
echo
echo "----------------------------------------"
echo " Exporting schemas and packing subgraphs..."
echo "----------------------------------------"
for SERVICE in "${SERVICE_LIST[@]}"; do
PROJECT_NAME="$(basename "$SERVICE")"
echo "Processing service: $PROJECT_NAME"
pushd "$SERVICE" >/dev/null
echo "Building service..."
dotnet build -c Release >/dev/null
# Automatically detect built DLL in bin/Release/<TFM>/
DLL_PATH="$(find "bin/Release" -maxdepth 3 -name '*.dll' | head -n 1)"
if [[ -z "$DLL_PATH" ]]; then
echo "ERROR: Could not locate DLL for $PROJECT_NAME"
popd >/dev/null
exit 1
fi
echo "Running schema export..."
dotnet exec "$DLL_PATH" schema export --output schema.graphql
echo "Running subgraph pack..."
fusion subgraph pack
popd >/dev/null
echo "Completed: $PROJECT_NAME"
echo
done
echo "----------------------------------------"
echo " Running fusion compose..."
echo "----------------------------------------"
pushd "$ROOT" >/dev/null
# Remove old composition file
rm -f gateway.fgp
for SERVICE in "${SERVICE_LIST[@]}"; do
SERVICE_NAME="$(basename "$SERVICE")"
echo "Composing subgraph: $SERVICE_NAME"
# Note: Fusion compose must reference parent dir (services live above ROOT)
fusion compose -p gateway.fgp -s "../$SERVICE_NAME"
done
popd >/dev/null
echo "----------------------------------------"
echo " Fusion build complete!"
echo "----------------------------------------"