Skip to content

ci: Enhance the GHA #19

ci: Enhance the GHA

ci: Enhance the GHA #19

name: PodDefaults Integration Test
on:
pull_request:
paths:
- components/admission-webhook/**
- releasing/version/VERSION
- .github/workflows/poddefaults_intergration_test.yaml
branches:
- main
- v*-branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.number }}
cancel-in-progress: true
env:
IMG: ghcr.io/kubeflow/kubeflow/poddefaults-webhook
TAG: integration-test
jobs:
integration-test:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install KinD
run: ./testing/gh-actions/install_kind.sh
- name: Create KinD Cluster
run: kind create cluster --config testing/gh-actions/kind-1-25.yaml
- name: Install kustomize
run: ./testing/gh-actions/install_kustomize.sh
- name: Install Istio
run: ./testing/gh-actions/install_istio.sh
- name: Install cert-manager
run: ./testing/gh-actions/install_cert_manager.sh
- name: Create Kubeflow Namespace
run: kubectl create namespace kubeflow
- name: Make Scripts Executable
run: chmod +x testing/gh-actions/*.sh
- name: Deploy PodDefaults Webhook Component
run: |
cd components/admission-webhook
if [ -f "Makefile" ]; then
if grep -q "docker-build-multi-arch" Makefile; then
make docker-build-multi-arch IMG="${IMG}" TAG="${TAG}"
else
make docker-build IMG="${IMG}" TAG="${TAG}"
fi
fi
kind load docker-image "${IMG}:${TAG}"
cd manifests
export CURRENT_IMAGE="${IMG}"
export PR_IMAGE="${IMG}:${TAG}"
export CURRENT_IMAGE_ESCAPED=$(echo "$CURRENT_IMAGE" | sed 's|\.|\\.|g')
export PR_IMAGE_ESCAPED=$(echo "$PR_IMAGE" | sed 's|\.|\\.|g')
kustomize build overlays/cert-manager \
| sed "s|${CURRENT_IMAGE_ESCAPED}:[a-zA-Z0-9_.-]*|${PR_IMAGE_ESCAPED}|g" \
| kubectl apply -f -
- name: Wait for Admission Webhook to be Ready
run: |
kubectl wait --for=condition=Ready pods -n kubeflow -l app=poddefaults --timeout=300s
kubectl wait --for=condition=Available deployment -n kubeflow admission-webhook-deployment --timeout=300s
- name: Validate Webhook Configuration
run: |
./testing/gh-actions/test_poddefault.sh validate-webhook kubeflow
- name: Create Test Namespace
run: |
./testing/gh-actions/test_poddefault.sh create-namespace test-poddefaults
- name: Create Test PodDefault
run: |
./testing/gh-actions/test_poddefault.sh create-poddefault test-poddefaults test-poddefault
- name: Test PodDefault Mutation
run: |
./testing/gh-actions/test_poddefault.sh test-mutation test-poddefaults test-poddefault test-pod
- name: Create Multiple PodDefaults for Testing
run: |
./testing/gh-actions/test_poddefault.sh create-multi-poddefault test-poddefaults test-poddefault
- name: Test Multiple PodDefaults Mutation
run: |
./testing/gh-actions/test_poddefault.sh test-multi-mutation test-poddefaults test-poddefault test-pod
- name: Test Error Handling
run: |
./testing/gh-actions/test_poddefault.sh test-error-handling test-poddefaults
- name: Check Webhook Logs
run: |
kubectl logs -n kubeflow -l app=poddefaults --tail=100
- name: Check for Errors in Webhook Logs
run: |
kubectl logs -n kubeflow -l app=poddefaults --tail=100 | grep -i error || echo "No errors found in webhook logs"
- name: Cleanup Test Resources
run: |
./testing/gh-actions/test_poddefault.sh cleanup test-poddefaults