|
| 1 | +#!/usr/bin/env pwsh |
| 2 | +# Validates that the latest published packages work together |
| 3 | +# This ensures the latest release on NuGet.org and Docker Hub are compatible |
| 4 | +# Usage: ./validate-latest-release.ps1 |
| 5 | + |
| 6 | +param( |
| 7 | + [Parameter(Mandatory=$false)] |
| 8 | + [string]$DockerTag = "latest" |
| 9 | +) |
| 10 | + |
| 11 | +$ErrorActionPreference = "Stop" |
| 12 | + |
| 13 | +Write-Host "🧪 Validating Latest Release Packages" -ForegroundColor Cyan |
| 14 | +Write-Host "======================================" -ForegroundColor Cyan |
| 15 | +Write-Host "This validates that the latest published packages work together:" -ForegroundColor Yellow |
| 16 | +Write-Host " - NuGet.org: FlinkDotnet (latest)" -ForegroundColor Yellow |
| 17 | +Write-Host " - Docker Hub: flinkdotnet/jobgateway:$DockerTag" -ForegroundColor Yellow |
| 18 | +Write-Host "" |
| 19 | + |
| 20 | +# Step 1: Remove any local NuGet feed |
| 21 | +Write-Host "📦 Step 1: Cleaning up local NuGet sources..." -ForegroundColor Yellow |
| 22 | +dotnet nuget remove source LocalFeed 2>$null |
| 23 | +Write-Host "✅ Local sources cleaned" -ForegroundColor Green |
| 24 | + |
| 25 | +# Step 2: Ensure we're using the latest from NuGet.org |
| 26 | +Write-Host "`n📦 Step 2: Configuring to use NuGet.org..." -ForegroundColor Yellow |
| 27 | +# Update the csproj to NOT use conditional reference |
| 28 | +$csprojPath = "./ReleasePackagesTesting/ReleasePackagesTesting.IntegrationTests/ReleasePackagesTesting.IntegrationTests.csproj" |
| 29 | +$csprojContent = Get-Content $csprojPath -Raw |
| 30 | + |
| 31 | +# Temporarily enable the package reference for this test |
| 32 | +$updatedContent = $csprojContent -replace 'PackageReference Include="FlinkDotnet" Version="\*" Condition="\$\(UseReleasePackages\)" == ''true''"', 'PackageReference Include="FlinkDotnet" Version="*"' |
| 33 | + |
| 34 | +# Create a temporary csproj for this test |
| 35 | +$tempCsprojPath = "./ReleasePackagesTesting/ReleasePackagesTesting.IntegrationTests/ReleasePackagesTesting.IntegrationTests.csproj.temp" |
| 36 | +$updatedContent | Set-Content $tempCsprojPath |
| 37 | +Copy-Item $tempCsprojPath $csprojPath -Force |
| 38 | +Remove-Item $tempCsprojPath |
| 39 | + |
| 40 | +Write-Host "✅ Configured to use NuGet.org" -ForegroundColor Green |
| 41 | + |
| 42 | +# Step 3: Pull latest Docker image |
| 43 | +Write-Host "`n📦 Step 3: Pulling latest Docker image from Docker Hub..." -ForegroundColor Yellow |
| 44 | +Write-Host "Pulling flinkdotnet/jobgateway:$DockerTag..." |
| 45 | +docker pull flinkdotnet/jobgateway:$DockerTag |
| 46 | +if ($LASTEXITCODE -ne 0) { |
| 47 | + Write-Host "❌ Failed to pull Docker image" -ForegroundColor Red |
| 48 | + Write-Host " Make sure the image exists on Docker Hub" -ForegroundColor Yellow |
| 49 | + exit 1 |
| 50 | +} |
| 51 | +Write-Host "✅ Docker image pulled successfully" -ForegroundColor Green |
| 52 | + |
| 53 | +# Step 4: Tag it as latest for the test |
| 54 | +if ($DockerTag -ne "latest") { |
| 55 | + Write-Host "`n📦 Tagging image as latest for compatibility..." -ForegroundColor Yellow |
| 56 | + docker tag flinkdotnet/jobgateway:$DockerTag flinkdotnet/jobgateway:latest |
| 57 | + Write-Host "✅ Image tagged" -ForegroundColor Green |
| 58 | +} |
| 59 | + |
| 60 | +# Step 5: Restore packages from NuGet.org |
| 61 | +Write-Host "`n📦 Step 4: Restoring packages from NuGet.org..." -ForegroundColor Yellow |
| 62 | +Push-Location ReleasePackagesTesting |
| 63 | + |
| 64 | +# Clear local package cache to force download from NuGet.org |
| 65 | +Write-Host "Clearing local package cache for FlinkDotnet..." |
| 66 | +dotnet nuget locals all --clear |
| 67 | + |
| 68 | +dotnet restore |
| 69 | +if ($LASTEXITCODE -ne 0) { |
| 70 | + Pop-Location |
| 71 | + Write-Host "❌ Failed to restore packages from NuGet.org" -ForegroundColor Red |
| 72 | + Write-Host " Make sure FlinkDotnet package is published on NuGet.org" -ForegroundColor Yellow |
| 73 | + exit 1 |
| 74 | +} |
| 75 | +Write-Host "✅ Packages restored from NuGet.org" -ForegroundColor Green |
| 76 | + |
| 77 | +# Step 6: Build solution |
| 78 | +Write-Host "`n📦 Step 5: Building solution..." -ForegroundColor Yellow |
| 79 | +dotnet build --configuration Release --no-restore |
| 80 | +if ($LASTEXITCODE -ne 0) { |
| 81 | + Pop-Location |
| 82 | + Write-Host "❌ Build failed" -ForegroundColor Red |
| 83 | + exit 1 |
| 84 | +} |
| 85 | +Write-Host "✅ Build successful" -ForegroundColor Green |
| 86 | + |
| 87 | +# Step 7: Run tests |
| 88 | +Write-Host "`n📦 Step 6: Running integration tests..." -ForegroundColor Yellow |
| 89 | +Write-Host "Testing that NuGet package and Docker image work together..." -ForegroundColor Yellow |
| 90 | +dotnet test --configuration Release --no-build --verbosity normal |
| 91 | +$testResult = $LASTEXITCODE |
| 92 | +Pop-Location |
| 93 | + |
| 94 | +if ($testResult -ne 0) { |
| 95 | + Write-Host "`n❌ Tests FAILED - Latest release packages have compatibility issues!" -ForegroundColor Red |
| 96 | + Write-Host " This indicates the published packages on NuGet.org and Docker Hub are incompatible" -ForegroundColor Yellow |
| 97 | + exit 1 |
| 98 | +} |
| 99 | + |
| 100 | +Write-Host "`n✅ All tests PASSED - Latest release packages work correctly together!" -ForegroundColor Green |
| 101 | +Write-Host "======================================" -ForegroundColor Cyan |
| 102 | +Write-Host "✅ Latest release validation complete" -ForegroundColor Cyan |
| 103 | +Write-Host "" |
| 104 | +Write-Host "Validated packages:" -ForegroundColor Green |
| 105 | +Write-Host " - FlinkDotnet from NuGet.org (latest)" -ForegroundColor Green |
| 106 | +Write-Host " - flinkdotnet/jobgateway:$DockerTag from Docker Hub" -ForegroundColor Green |
| 107 | + |
| 108 | +exit 0 |
0 commit comments