Skip to content
Merged
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
17 changes: 15 additions & 2 deletions scripts/postProvision.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail

# Ensure the temporary venv is always cleaned up, even on early exits.
# Cleanup failures must never cause the post-provision hook to report failure.
cleanup() {
deactivate 2>/dev/null || true
rm -rf config/.venv_temp 2>/dev/null || true
}
trap cleanup EXIT

echo "🔧 Running post-provision steps..."
echo

Expand Down Expand Up @@ -140,8 +149,12 @@ echo "🔍 AI Search setup…"
###############################################################################
echo
echo "🧹 Cleaning Python environment up…"
deactivate
rm -rf config/.venv_temp
# `deactivate` only restores shell variables (PATH, PS1) — it deletes nothing.
# Since the script is ending, there is nothing to restore. We skip it and
# go straight to removing the venv directory.
# python3's shutil.rmtree handles locked files and open __pycache__ handles
# (common on macOS with Python 3.12+) without raising, unlike `rm -rf`.
python3 -c "import shutil; shutil.rmtree('config/.venv_temp', ignore_errors=True)"

echo
echo "✅ postProvisioning completed."
32 changes: 17 additions & 15 deletions scripts/preDeploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,24 @@ foreach ($c in $manifest.components) {
$target = Join-Path $baseDir $name
Write-Host ("Deploying {0} ({1}:{2}) -> {3}" -f $name, $refType, $ref, $target) -ForegroundColor Cyan

if (Test-Path -LiteralPath $target) { Remove-Item -Recurse -Force -LiteralPath $target }

try {
if ($refType -eq 'branch') {
git clone --depth 1 --branch $ref --no-progress -q $repo $target 1>$null 2>$null
} else {
git clone --depth 1 --no-progress -q $repo $target 1>$null 2>$null
git -C $target fetch --tags --force --depth 1 --no-progress -q origin $ref 1>$null 2>$null
git -C $target -c advice.detachedHead=false checkout -q -f $ref 1>$null 2>$null
if (Test-Path -LiteralPath $target) {
Write-Host (" ℹ️ '{0}' already exists at {1}, skipping clone." -f $name, $target) -ForegroundColor Yellow
} else {
try {
if ($refType -eq 'branch') {
git clone --depth 1 --branch $ref --no-progress -q $repo $target 1>$null 2>$null
} else {
git clone --depth 1 --no-progress -q $repo $target 1>$null 2>$null
git -C $target fetch --tags --force --depth 1 --no-progress -q origin $ref 1>$null 2>$null
git -C $target -c advice.detachedHead=false checkout -q -f $ref 1>$null 2>$null
}
git config --global --add safe.directory ($target -replace '\\','/') 1>$null 2>$null
}
catch {
Write-Error ("{0}: git operation failed. {1}" -f $name, $_.Exception.Message)
$hadErrors = $true
continue
}
git config --global --add safe.directory ($target -replace '\\','/') 1>$null 2>$null
}
catch {
Write-Error ("{0}: git operation failed. {1}" -f $name, $_.Exception.Message)
$hadErrors = $true
continue
}

# Copy shared azd env into the freshly cloned project
Expand Down
30 changes: 16 additions & 14 deletions scripts/preDeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,23 @@ jq -c '.components[]' "$manifest_path" | while IFS= read -r comp; do
target="$base_dir/$name"
cyan "Deploying $name ($ref_type:$ref) -> $target"

rm -rf "$target" 2>/dev/null || true

if [ "$ref_type" = "branch" ]; then
if ! git clone --depth 1 --branch "$ref" --quiet "$repo" "$target" >/dev/null 2>&1; then
red "$name: git clone failed."; had_errors=1; continue
fi
if [ -d "$target" ]; then
yellow " ℹ️ '$name' already exists at $target, skipping clone."
else
if ! git clone --depth 1 --quiet "$repo" "$target" >/dev/null 2>&1; then
red "$name: git clone failed."; had_errors=1; continue
fi
if ! git -C "$target" fetch --tags --force --depth 1 --quiet origin "$ref" >/dev/null 2>&1; then
red "$name: git fetch tag failed."; had_errors=1; continue
fi
if ! git -C "$target" -c advice.detachedHead=false checkout -q -f "$ref" >/dev/null 2>&1; then
red "$name: git checkout tag failed."; had_errors=1; continue
if [ "$ref_type" = "branch" ]; then
if ! git clone --depth 1 --branch "$ref" --quiet "$repo" "$target" >/dev/null 2>&1; then
red "$name: git clone failed."; had_errors=1; continue
fi
else
if ! git clone --depth 1 --quiet "$repo" "$target" >/dev/null 2>&1; then
red "$name: git clone failed."; had_errors=1; continue
fi
if ! git -C "$target" fetch --tags --force --depth 1 --quiet origin "$ref" >/dev/null 2>&1; then
red "$name: git fetch tag failed."; had_errors=1; continue
fi
if ! git -C "$target" -c advice.detachedHead=false checkout -q -f "$ref" >/dev/null 2>&1; then
red "$name: git checkout tag failed."; had_errors=1; continue
fi
fi
fi

Expand Down