#!/usr/bin/env bash # ci-cd.yml › backend — build, unit tests and the "entity changed but no migration" check. # The dotnet work runs inside a capped SDK container. ASPNETCORE_ENVIRONMENT=Development is set # explicitly for the EF step: `dotnet ef` boots Program.cs, and outside Development the startup # config check would (correctly) refuse to run without the deployment secrets CI doesn't have. # shellcheck source=common.sh source "$(dirname "${BASH_SOURCE[0]}")/common.sh" z="$(selinux_mount_suffix)" with_build_lock log "backend checks (capped: 2 CPU / 1500 MB)" # The inner script is single-quoted on purpose: it expands inside the container, not here. # shellcheck disable=SC2016 docker run --rm --cpus=2 --cpu-shares=512 --memory=1500m \ -e DOTNET_CLI_TELEMETRY_OPTOUT=1 -e DOTNET_NOLOGO=1 -e EF_VERSION="$DOTNET_EF_VERSION" \ -e ASPNETCORE_ENVIRONMENT=Development \ -v "$PWD/Backend:/src$z" \ -v erp-nuget:/root/.nuget/packages \ -v erp-dotnet-tools:/root/.dotnet/tools \ -w /src "$DOTNET_SDK_IMAGE" bash -ec ' dotnet restore ERPCore.sln dotnet build ERPCore.sln -c Release --no-restore dotnet test ERPCore.Tests/ERPCore.Tests.csproj -c Release --no-build # Program.cs suppresses PendingModelChangesWarning at runtime, so this is the only guard # against an entity/configuration change merged without its migration. --no-build is safe # here: the assembly was built from this exact source two commands ago. dotnet tool update --global dotnet-ef --version "$EF_VERSION" >/dev/null export PATH="$PATH:/root/.dotnet/tools" dotnet ef migrations has-pending-model-changes \ --project ERPCore/ERPCore.csproj --configuration Release --no-build '