Skip to content

Commit

Permalink
add clean for ci (#148)
Browse files Browse the repository at this point in the history
Signed-off-by: ii2day <[email protected]>
  • Loading branch information
ii2day authored Aug 25, 2023
1 parent e68ca59 commit ec8a387
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/call-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,20 @@ jobs:
path: ${{ env.E2E_GINKGO_REPORT_PATH }}
retention-days: 30

- name: helm uninstalls kdoctor and cleans kdoctor CRD
id: clean
run: |
RESULT=0
make clean_e2e_kdoctor || RESULT=1
if ((RESULT==0)) ; then
echo "CLEAN_E2E_PASS=true" >> $GITHUB_ENV
else
echo "CLEAN_E2E_PASS=false" >> $GITHUB_ENV
fi
- name: Show e2e Result
run: |
if ${{ env.RUN_PASS == 'true' }} ;then
if ${{ env.RUN_PASS == 'true' && env.CLEAN_E2E_PASS == 'true' }} ;then
exit 0
else
exit 1
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ e2e_run:
e2e_clean:
make -C test clean


.PHONY: clean_e2e_kdoctor
clean_e2e_kdoctor:
make -C test uninstall_kdoctor
#============ doc

.PHONY: preview_doc
Expand Down
34 changes: 34 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,40 @@ install_nginx:
--set controller.ingressClassResource.default=true \
$${HELM_OPTION}

.PHONY: clean_kdoctor_crd
clean_kdoctor_crd: KIND_KUBECONFIG ?= $(E2E_KIND_KUBECONFIG_PATH)
clean_kdoctor_crd:
@echo -e "\033[35m [clean kdoctor crd] \033[0m"
@kubectl delete crd netdnses.kdoctor.io --kubeconfig $(KIND_KUBECONFIG)
@kubectl delete crd apphttphealthies.kdoctor.io --kubeconfig $(KIND_KUBECONFIG)
@kubectl delete crd netreaches.kdoctor.io --kubeconfig $(KIND_KUBECONFIG)
@ALL_CRD=`kubectl get crd -n $(E2E_INSTALL_NAMESPACE) --kubeconfig $(KIND_KUBECONFIG) | awk '{print $$1 } ' ` ; FAIL="false" ; FOUND="false"; \
for CRD in $$ALL_CRD ; do \
echo $${CRD} | grep -q 'kdoctor.io' && FOUND="true" && echo "error, failed to clean kdoctor crd: $${CRD}" ; \
if [ "$$FOUND" == "true" ] ; then \
echo -e "\033[35m [===== describe crd: $${CRD} =====] \033[0m" ; \
kubectl describe crd $${CRD} --kubeconfig $(KIND_KUBECONFIG) ; \
echo -e "\033[35m [===== get crd: $${CRD} -ojson =====] \033[0m" ; \
kubectl get crd $${CRD} -ojson --kubeconfig $(KIND_KUBECONFIG) ; \
FAIL="true" ; \
FOUND="false" ; \
fi ; \
done ; \
[ "$$FAIL" == "true" ] && echo "kdoctor crd cleanup failed" && exit 1 ; \
echo -e "\033[35m [done] all kdoctor crd cleaned up !!! \033[0m"

.PHONY: helm_uninstall_kdoctor
helm_uninstall_kdoctor: KIND_KUBECONFIG ?= $(E2E_KIND_KUBECONFIG_PATH)
helm_uninstall_kdoctor:
@echo -e "\033[35m [helm uninstall kdoctor] \033[0m"
helm uninstall project --wait --debug -n $(E2E_INSTALL_NAMESPACE) \
--kubeconfig $(KIND_KUBECONFIG) || { KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) ./scripts/debugCluster.sh $(KIND_KUBECONFIG) "detail" ; exit 1 ; } ; \

.PHONY: uninstall_kdoctor
uninstall_kdoctor:
@echo -e "\033[35m [uninstall kdoctor] \033[0m"
@ make helm_uninstall_kdoctor
@ make clean_kdoctor_crd


#==========================
Expand Down

0 comments on commit ec8a387

Please sign in to comment.