[FA-13] Works locally, probably works in CICD
This commit is contained in:
99
FictionArchive.API/build_gateway.bat
Normal file
99
FictionArchive.API/build_gateway.bat
Normal file
@@ -0,0 +1,99 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
set ROOT=%~dp0
|
||||
|
||||
for %%A in ("%ROOT%..") do set SERVICES_DIR=%%~fA\
|
||||
|
||||
REM ----------------------------------------
|
||||
REM List of project names to skip
|
||||
REM (space-separated, match folder names exactly)
|
||||
REM ----------------------------------------
|
||||
set SKIP_PROJECTS=FictionArchive.Service.Shared FictionArchive.Service.AuthenticationService
|
||||
|
||||
echo ----------------------------------------
|
||||
echo Finding GraphQL services...
|
||||
echo ----------------------------------------
|
||||
|
||||
set SERVICE_LIST=
|
||||
|
||||
for /d %%F in ("%SERVICES_DIR%FictionArchive.Service.*") do (
|
||||
set "PROJECT_NAME=%%~nxF"
|
||||
set "SKIP=0"
|
||||
|
||||
REM Check if this project name is in the skip list
|
||||
for %%X in (%SKIP_PROJECTS%) do (
|
||||
if /I "!PROJECT_NAME!"=="%%X" (
|
||||
set "SKIP=1"
|
||||
)
|
||||
)
|
||||
|
||||
if !SKIP!==0 (
|
||||
echo Found service: !PROJECT_NAME!
|
||||
set SERVICE_LIST=!SERVICE_LIST! %%F
|
||||
) else (
|
||||
echo Skipping service: !PROJECT_NAME!
|
||||
)
|
||||
)
|
||||
|
||||
echo:
|
||||
echo ----------------------------------------
|
||||
echo Exporting schemas and packing subgraphs...
|
||||
echo ----------------------------------------
|
||||
|
||||
for %%S in (%SERVICE_LIST%) do (
|
||||
echo Processing service folder: %%S
|
||||
pushd "%%S"
|
||||
|
||||
echo Running schema export...
|
||||
dotnet run -- schema export --output schema.graphql
|
||||
if errorlevel 1 (
|
||||
echo ERROR during schema export in %%S
|
||||
popd
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Running fusion subgraph pack...
|
||||
fusion subgraph pack
|
||||
if errorlevel 1 (
|
||||
echo ERROR during subgraph pack in %%S
|
||||
popd
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
popd
|
||||
echo Completed: %%S
|
||||
echo.
|
||||
)
|
||||
|
||||
echo ----------------------------------------
|
||||
echo Running fusion compose...
|
||||
echo ----------------------------------------
|
||||
|
||||
pushd "%ROOT%"
|
||||
|
||||
if exist gateway.fgp del gateway.fgp
|
||||
|
||||
for %%S in (%SERVICE_LIST%) do (
|
||||
REM Extract the full folder name WITH dots preserved
|
||||
set "SERVICE_NAME=%%~nxS"
|
||||
|
||||
echo Composing subgraph: !SERVICE_NAME!
|
||||
|
||||
fusion compose -p gateway.fgp -s "..\!SERVICE_NAME!"
|
||||
if errorlevel 1 (
|
||||
echo ERROR during fusion compose
|
||||
popd
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
popd
|
||||
|
||||
|
||||
echo ----------------------------------------
|
||||
echo Fusion build complete!
|
||||
echo ----------------------------------------
|
||||
|
||||
endlocal
|
||||
exit /b 0
|
||||
104
FictionArchive.API/build_gateway.sh
Normal file
104
FictionArchive.API/build_gateway.sh
Normal 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 "----------------------------------------"
|
||||
Binary file not shown.
Reference in New Issue
Block a user