Files
Heimdall/scripts/acceptance/sentry-telemetry-privacy.sh
arnaud.dartois 5009c96120
Heimdall Gitea / Detect CI scope (push) Successful in 6s
Heimdall Gitea / Build and tests (push) Skipped
Heimdall Gitea / Build and scan server image (push) Skipped
Heimdall Gitea / Build and scan agent image (push) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Skipped
Heimdall Gitea / Publish versioned installer release (push) Skipped
Heimdall Gitea / CI policy (push) Successful in 2s
docs: centralize Heimdall agent guidance (#418) (#420)
Co-authored-by: Arnaud Dartois <admin@tordais.cc>
2026-11-19 21:07:51 +01:00

106 lines
4.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
suffix="$(date -u +%Y%m%d%H%M%S)-$(od -An -N5 -tx1 /dev/urandom | tr -d ' \\n')"
project="heimdall-sentry-privacy-${suffix}"
temp_dir=$(mktemp -d "${TMPDIR:-/tmp}/${project}.XXXXXX")
env_file="$temp_dir/acceptance.env"
compose_file="$temp_dir/compose.yml"
props_file="$temp_dir/acceptance.props"
local_image_tags=()
cleanup() {
status=$?
trap - EXIT
# Cleanup must continue through every independent resource even when the
# caller enabled errexit/nounset or an earlier Docker query failed.
set +e
set +u
cleanup_failed=0
docker compose --project-directory "$repo_root" --env-file "$env_file" \
-f "$compose_file" -p "$project" down --volumes --remove-orphans || cleanup_failed=1
containers=$(docker ps -aq --filter "label=com.docker.compose.project=$project") || cleanup_failed=1
if [[ -n "$containers" ]]; then
while IFS= read -r container; do
[[ -z "$container" ]] || docker rm -f "$container" >/dev/null || cleanup_failed=1
done <<< "$containers"
fi
containers=$(docker ps -aq --filter "label=com.docker.compose.project=$project") || cleanup_failed=1
volumes=$(docker volume ls -q --filter "label=com.docker.compose.project=$project") || cleanup_failed=1
networks=$(docker network ls -q --filter "label=com.docker.compose.project=$project") || cleanup_failed=1
if [[ -n "$containers" || -n "$volumes" || -n "$networks" ]]; then
printf 'Project resources remain: containers=%s volumes=%s networks=%s\n' \
"${containers:-<none>}" "${volumes:-<none>}" "${networks:-<none>}" >&2
cleanup_failed=1
else
printf 'Verified no project containers, volumes, or networks remain: %s\n' "$project"
fi
if ((${#local_image_tags[@]} == 0)); then
printf 'Local images built: none; upstream SDK image retained.\n'
fi
for tag in "${local_image_tags[@]}"; do
docker image rm "$tag" >/dev/null 2>&1 || true
if docker image inspect "$tag" >/dev/null 2>&1; then
printf 'Recipe image remains: %s\n' "$tag" >&2
cleanup_failed=1
else
printf 'Verified recipe image absent: %s\n' "$tag"
fi
done
rm -f -- "$env_file" "$compose_file" "$props_file" || cleanup_failed=1
rmdir -- "$temp_dir" || cleanup_failed=1
if ((cleanup_failed)); then
printf 'Disposable Sentry privacy acceptance cleanup failed for %s\n' "$project" >&2
status=1
fi
exit "$status"
}
trap cleanup EXIT
cat > "$env_file" <<EOF
REPO_ROOT=$repo_root
ACCEPTANCE_PROJECT=$project
ACCEPTANCE_DIR=$temp_dir
ACCEPTANCE_UID=$(id -u)
ACCEPTANCE_GID=$(id -g)
EOF
cat > "$props_file" <<'EOF'
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath>/tmp/$(ACCEPTANCE_PROJECT)/obj/$(MSBuildProjectName)/</BaseIntermediateOutputPath>
<MSBuildProjectExtensionsPath>/tmp/$(ACCEPTANCE_PROJECT)/obj/$(MSBuildProjectName)/</MSBuildProjectExtensionsPath>
<BaseOutputPath>/tmp/$(ACCEPTANCE_PROJECT)/bin/$(MSBuildProjectName)/</BaseOutputPath>
<DefaultItemExcludes>$(DefaultItemExcludes);**/obj/**;**/bin/**</DefaultItemExcludes>
</PropertyGroup>
</Project>
EOF
cat > "$compose_file" <<'EOF'
services:
focused-tests:
image: mcr.microsoft.com/dotnet/sdk:10.0
entrypoint: ["dotnet"]
user: "${ACCEPTANCE_UID}:${ACCEPTANCE_GID}"
working_dir: /workspace
environment:
ACCEPTANCE_PROJECT: ${ACCEPTANCE_PROJECT}
volumes:
- ${REPO_ROOT}:/workspace
- ${ACCEPTANCE_DIR}:/acceptance
command:
- test
- tests/Heimdall.Web.Tests/Heimdall.Web.Tests.csproj
- --filter
- FullyQualifiedName~SentryTelemetryPrivacyTests
- --verbosity
- minimal
- -p:RestoreLockedMode=true
- -p:CustomBeforeDirectoryBuildProps=/acceptance/acceptance.props
EOF
printf 'Disposable project: %s\nLocal images built: none\n' "$project"
docker compose --project-directory "$repo_root" --env-file "$env_file" \
-f "$compose_file" -p "$project" config --quiet
docker compose --project-directory "$repo_root" --env-file "$env_file" \
-f "$compose_file" -p "$project" run --rm focused-tests