use aggregator-traefik repo #42
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 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.21' | |
| cache: true | |
| cache-dependency-path: integration-test/go.sum | |
| - name: Cache Go modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('integration-test/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Set up Docker | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: network=host | |
| - name: Cache Docker layers | |
| uses: actions/cache@v3 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: ${{ runner.os }}-buildx-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx- | |
| - name: Install Kind | |
| 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 kubectl | |
| 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 Helm | |
| run: | | |
| curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash | |
| - name: Verify installations | |
| run: | | |
| docker version | |
| kind version | |
| kubectl version --client | |
| helm version | |
| - name: Build Docker images | |
| run: | | |
| export DOCKER_BUILDKIT=1 | |
| export BUILDKIT_PROGRESS=plain | |
| make containers-build | |
| timeout-minutes: 30 | |
| env: | |
| DOCKER_BUILDKIT: 1 | |
| - 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 | |
| run: | | |
| echo "Loading images in parallel..." | |
| find containers -maxdepth 1 -mindepth 1 -type d | \ | |
| xargs -I {} -P 4 sh -c ' | |
| name=$(basename {}) | |
| echo "📥 Loading $name..." | |
| if kind load docker-image "$name:latest" --name aggregator; then | |
| echo "✅ Loaded $name" | |
| else | |
| echo "❌ Failed to load $name" | |
| exit 1 | |
| fi | |
| ' | |
| timeout-minutes: 10 | |
| - 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 | |
| run: | | |
| echo "127.0.0.1 aggregator.local" | sudo tee -a /etc/hosts | |
| - name: Run integration tests | |
| run: | | |
| cd integration-test | |
| go test -v -timeout 30m ./... | |
| timeout-minutes: 35 | |
| - name: Collect logs on failure | |
| if: failure() | |
| 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: Upload logs on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-logs | |
| 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 |