-
Notifications
You must be signed in to change notification settings - Fork 354
Initial CI automation on test for GitOps operator support for xKS #1188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
3daba04
528a7df
cc5b2bd
d02c14c
35a1984
2da27ae
1797477
b10c424
a9b3dbd
cbc80d1
f565daa
d78b341
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| name: Build, Deploy and Test on kind | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - "master" | ||
| - "v*" | ||
|
|
||
| env: | ||
| IMG: gitops-operator:test | ||
|
|
||
| jobs: | ||
| ci-build: | ||
| name: Build image, deploy to kind cluster | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
|
|
||
| - name: Create kind cluster | ||
| uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1 | ||
| with: | ||
| cluster_name: gitops-test | ||
|
|
||
| # TODO: check if porting is required for non-OCP clusters | ||
| - name: Disable webhook and conversion for non-OCP cluster | ||
| run: | | ||
| sed -i 's|^- ../prometheus|#- ../prometheus|' config/default/kustomization.yaml | ||
| sed -i 's|^- ../webhook|#- ../webhook|' config/default/kustomization.yaml | ||
| sed -i 's|^- patches/webhook_in_argocds.yaml|#- patches/webhook_in_argocds.yaml|' config/crd/kustomization.yaml | ||
| sed -i 's|^- patches/cainjection_in_argocds.yaml|#- patches/cainjection_in_argocds.yaml|' config/crd/kustomization.yaml | ||
| echo "=== Verify sed applied ===" | ||
| grep -n 'webhook\|prometheus' config/default/kustomization.yaml | ||
| grep -n 'patches/' config/crd/kustomization.yaml | ||
|
|
||
| - name: Build manager image | ||
| run: | | ||
| make docker-build IMG=${{ env.IMG }} | ||
|
svghadi marked this conversation as resolved.
|
||
|
|
||
| - name: Load image into kind | ||
| run: | | ||
| kind load docker-image ${{ env.IMG }} --name gitops-test | ||
|
|
||
| - name: Install CRDs | ||
| run: | | ||
| make install | ||
|
|
||
| - name: Deploy operator | ||
| run: | | ||
| echo "manifests: $(KUSTOMIZE) build config/default" | ||
| make deploy IMG=${{ env.IMG }} | tee /tmp/deploy.log | ||
|
|
||
| - name: Verify Controller Manager deployment is available | ||
| run: | | ||
| kubectl get deployment -n openshift-gitops-operator | ||
| kubectl describe deployment -n openshift-gitops-operator | ||
| kubectl wait --for=condition=available --timeout=300s \ | ||
| deployment/openshift-gitops-operator-controller-manager \ | ||
| -n openshift-gitops-operator | ||
|
|
||
| - name: Create ArgoCD instance | ||
| run: | | ||
| kubectl create ns test-argocd | ||
| kubectl apply -f - <<'EOF' | ||
| apiVersion: argoproj.io/v1beta1 | ||
| kind: ArgoCD | ||
| metadata: | ||
| name: argocd | ||
| namespace: test-argocd | ||
| EOF | ||
|
|
||
| - name: Wait for ArgoCD component pods to exist | ||
| run: | | ||
| EXPECTED_LABELS=("argocd-application-controller" "argocd-redis" "argocd-repo-server" "argocd-server") | ||
| TIMEOUT=300 | ||
| INTERVAL=10 | ||
| ELAPSED=0 | ||
|
|
||
| echo "Waiting for ArgoCD component pods to exist in test-argocd..." | ||
| while true; do | ||
| ALL_EXIST=true | ||
| for label in "${EXPECTED_LABELS[@]}"; do | ||
| if ! kubectl get pod -n test-argocd -l "app.kubernetes.io/name=${label}" --no-headers 2>/dev/null | grep -q .; then | ||
| ALL_EXIST=false | ||
| break | ||
| fi | ||
| done | ||
|
|
||
| if $ALL_EXIST; then | ||
| echo "All ArgoCD component pods exist after ${ELAPSED}s." | ||
| break | ||
| fi | ||
|
|
||
| if [ $ELAPSED -ge $TIMEOUT ]; then | ||
| echo "Timed out after ${TIMEOUT}s waiting for ArgoCD pods." | ||
| kubectl get pods -n test-argocd | ||
| kubectl get argocd -n test-argocd -o yaml | ||
| exit 1 | ||
| fi | ||
|
|
||
| sleep $INTERVAL | ||
| ELAPSED=$((ELAPSED + INTERVAL)) | ||
| done | ||
|
|
||
| - name: Verify ArgoCD components are ready | ||
| run: | | ||
| kubectl get pods -n test-argocd | ||
| kubectl wait --for=condition=Ready -n test-argocd pod --timeout=300s \ | ||
| -l 'app.kubernetes.io/name in (argocd-application-controller,argocd-redis,argocd-repo-server,argocd-server)' | ||
| echo "All ArgoCD components are ready." | ||
| kubectl get pods -n test-argocd | ||
|
|
||
| - name: Collect operator debug info on failure | ||
| if: failure() | ||
| run: | | ||
| echo "=== Deployment status ===" | ||
| kubectl get deployment -n openshift-gitops-operator -o wide || true | ||
| echo "" | ||
| echo "=== Pod status ===" | ||
| kubectl get pods -n openshift-gitops-operator -o wide || true | ||
| echo "" | ||
| echo "=== Pod descriptions ===" | ||
| kubectl describe pods -n openshift-gitops-operator || true | ||
| echo "" | ||
| echo "=== Controller manager logs ===" | ||
| kubectl logs deployment/openshift-gitops-operator-controller-manager \ | ||
| -n openshift-gitops-operator --all-containers=true --tail=200 || true | ||
| echo "" | ||
| echo "=== Events in operator namespace ===" | ||
| kubectl get events -n openshift-gitops-operator --sort-by='.lastTimestamp' || true | ||
| echo "" | ||
| echo "=== CRD conversion config ===" | ||
| kubectl get crd argocds.argoproj.io -o jsonpath='{.spec.conversion}' || true | ||
| echo "" | ||
|
|
||
| - name: Collect ArgoCD debug info on failure | ||
| if: failure() | ||
| run: | | ||
| echo "=== ArgoCD resources ===" | ||
| kubectl get argocds -n test-argocd -o yaml 2>/dev/null || true | ||
| echo "" | ||
| echo "=== Pods in test-argocd ===" | ||
| kubectl get pods -n test-argocd -o wide 2>/dev/null || true | ||
| echo "" | ||
| echo "=== Pod descriptions in test-argocd ===" | ||
| kubectl describe pods -n test-argocd 2>/dev/null || true | ||
| echo "" | ||
| echo "=== Events in test-argocd ===" | ||
| kubectl get events -n test-argocd --sort-by='.lastTimestamp' 2>/dev/null || true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,4 @@ spec: | |
| secret: | ||
| defaultMode: 420 | ||
| secretName: webhook-server-cert | ||
| optional: true | ||
|
Comment on lines
21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== deploy-test workflow disables the webhook patch =="
sed -n '25,40p' .github/workflows/deploy-test.yaml | nl -ba
echo
echo "== default kustomization still includes the webhook patch =="
sed -n '35,45p' config/default/kustomization.yaml | nl -ba
echo
echo "== changed patch content =="
sed -n '15,30p' config/default/manager_webhook_patch.yaml | nl -baRepository: redhat-developer/gitops-operator Length of output: 264 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== deploy-test workflow =="
sed -n '1,120p' .github/workflows/deploy-test.yaml | cat -n
echo
echo "== default kustomization =="
sed -n '1,120p' config/default/kustomization.yaml | cat -n
echo
echo "== manager_webhook_patch =="
sed -n '1,80p' config/default/manager_webhook_patch.yaml | cat -nRepository: redhat-developer/gitops-operator Length of output: 6356 Cover the webhook patch change in deploy-test 🧰 Tools🪛 Checkov (3.3.1)[medium] 1-24: Containers should not run with allowPrivilegeEscalation (CKV_K8S_20) [medium] 1-24: Minimize the admission of root containers (CKV_K8S_23) 🤖 Prompt for AI Agents |
||
Uh oh!
There was an error while loading. Please reload this page.