Fix github actions workflow file #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Integration Tests | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| integration-tests: | |
| name: Integration Tests - ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.21' | |
| cache-dependency-path: integration-test/go.sum | |
| - name: Set up Docker (Linux) | |
| if: runner.os == 'Linux' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set up Docker (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| docker version | |
| docker info | Select-String -Pattern "OSType" | |
| docker pull alpine:latest | |
| shell: powershell | |
| - name: Install Kind (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64 | |
| chmod +x ./kind | |
| sudo mv ./kind /usr/local/bin/kind | |
| - name: Install Kind (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| curl.exe -Lo kind-windows-amd64.exe https://kind.sigs.k8s.io/dl/v0.20.0/kind-windows-amd64 | |
| Move-Item .\kind-windows-amd64.exe C:\Windows\System32\kind.exe | |
| shell: powershell | |
| - name: Install kubectl (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | |
| chmod +x kubectl | |
| sudo mv kubectl /usr/local/bin/ | |
| - name: Install kubectl (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| curl.exe -LO "https://dl.k8s.io/release/v1.28.0/bin/windows/amd64/kubectl.exe" | |
| Move-Item .\kubectl.exe C:\Windows\System32\kubectl.exe | |
| shell: powershell | |
| - name: Install Helm (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash | |
| - name: Install Helm (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| choco install kubernetes-helm -y | |
| shell: powershell | |
| - name: Verify installations | |
| run: | | |
| docker version | |
| kind version | |
| kubectl version --client | |
| helm version | |
| - name: Build Docker images (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| make containers-build | |
| timeout-minutes: 30 | |
| - name: Build Docker images (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| Get-ChildItem -Path containers -Directory | ForEach-Object { | |
| $name = $_.Name | |
| Write-Host "Building $name..." | |
| docker build --platform linux/amd64 "containers/$name" -t "${name}:latest" | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "Failed to build $name" | |
| exit $LASTEXITCODE | |
| } | |
| Write-Host "Successfully built $name" | |
| } | |
| shell: powershell | |
| timeout-minutes: 30 | |
| - name: Create Kind cluster | |
| run: | | |
| kind create cluster --name aggregator --config k8s/kind-config.yaml --wait 120s | |
| timeout-minutes: 10 | |
| - name: Load images into Kind (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| for dir in containers/*; do | |
| if [ -d "$dir" ]; then | |
| name=$(basename "$dir") | |
| echo "Loading $name into kind..." | |
| kind load docker-image "$name:latest" --name aggregator | |
| fi | |
| done | |
| timeout-minutes: 20 | |
| - name: Load images into Kind (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| Get-ChildItem -Path containers -Directory | ForEach-Object { | |
| $name = $_.Name | |
| Write-Host "Loading $name into kind..." | |
| kind load docker-image "${name}:latest" --name aggregator | |
| } | |
| shell: powershell | |
| timeout-minutes: 20 | |
| - name: Generate key pair for UMA proxy | |
| run: | | |
| kubectl config use-context kind-aggregator | |
| kubectl wait --for=condition=Ready nodes --all --timeout=120s | |
| openssl genrsa -out uma-proxy.key 4096 | |
| openssl req -x509 -new -nodes -key uma-proxy.key -sha256 -days 3650 -out uma-proxy.crt -subj "/CN=Aggregator MITM CA" | |
| kubectl delete secret uma-proxy-key-pair -n default --ignore-not-found | |
| kubectl create secret generic uma-proxy-key-pair --from-file=uma-proxy.crt=uma-proxy.crt --from-file=uma-proxy.key=uma-proxy.key -n default | |
| rm uma-proxy.crt uma-proxy.key | |
| - name: Deploy aggregator-cleaner | |
| run: | | |
| kubectl apply -f k8s/ops/ns.yaml | |
| kubectl apply -f k8s/ops/cleaner.yaml | |
| kubectl wait --namespace aggregator-ops --for=condition=available deployment/aggregator-cleaner --timeout=60s || true | |
| - name: Deploy Traefik | |
| run: | | |
| helm repo add traefik https://traefik.github.io/charts | |
| helm repo update | |
| helm upgrade --install aggregator-traefik traefik/traefik \ | |
| --namespace aggregator-traefik \ | |
| --create-namespace \ | |
| --set ingressClass.enabled=true \ | |
| --set ingressClass.name=aggregator-traefik \ | |
| --set ports.web.hostPort=80 \ | |
| --set ports.websecure.hostPort=443 \ | |
| --set service.type=ClusterIP \ | |
| --set providers.kubernetesCRD.allowCrossNamespace=true \ | |
| --wait --timeout=3m | |
| kubectl rollout status deployment aggregator-traefik -n aggregator-traefik --timeout=180s | |
| - name: Deploy aggregator | |
| run: | | |
| kubectl apply -f k8s/app/ns.yaml | |
| kubectl apply -f k8s/app/config.yaml | |
| kubectl apply -f k8s/app/aggregator.yaml | |
| kubectl rollout status deployment aggregator-server -n aggregator-app --timeout=120s | |
| - name: Add /etc/hosts entry (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| echo "127.0.0.1 aggregator.local" | sudo tee -a /etc/hosts | |
| - name: Add hosts entry (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| Add-Content -Path C:\Windows\System32\drivers\etc\hosts -Value "127.0.0.1 aggregator.local" | |
| shell: powershell | |
| - name: Run integration tests | |
| run: | | |
| cd integration-test | |
| go test -v -timeout 30m ./... | |
| timeout-minutes: 35 | |
| - name: Collect logs on failure (Linux) | |
| if: failure() && runner.os == 'Linux' | |
| run: | | |
| echo "=== Cluster Info ===" | |
| kubectl cluster-info dump --output-directory=./cluster-logs --namespaces aggregator-app,aggregator-ops 2>&1 || true | |
| echo "=== Docker Containers ===" | |
| docker ps -a | |
| echo "=== Kind Logs ===" | |
| kind export logs ./kind-logs --name aggregator || true | |
| - name: Collect logs on failure (Windows) | |
| if: failure() && runner.os == 'Windows' | |
| run: | | |
| Write-Host "=== Cluster Info ===" | |
| kubectl cluster-info dump --output-directory=./cluster-logs --namespaces aggregator-app,aggregator-ops | |
| Write-Host "=== Docker Containers ===" | |
| docker ps -a | |
| Write-Host "=== Kind Logs ===" | |
| kind export logs ./kind-logs --name aggregator | |
| shell: powershell | |
| continue-on-error: true | |
| - name: Upload logs on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-logs-${{ matrix.os }} | |
| path: | | |
| cluster-logs/ | |
| kind-logs/ | |
| retention-days: 7 | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| kind delete cluster --name aggregator || true | |
| notify: | |
| name: Notify Results | |
| needs: integration-tests | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Check test results | |
| run: | | |
| if [ "${{ needs.integration-tests.result }}" == "success" ]; then | |
| echo "✅ All integration tests passed!" | |
| else | |
| echo "❌ Integration tests failed" | |
| exit 1 | |
| fi | |