This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit b092549b47288e36d0f4e8d8bab73ca27459c0e6 Author: phantomjinx <[email protected]> AuthorDate: Tue Nov 23 18:11:19 2021 +0000 Adds a cleanup action for post workflow clearing up of the cluster * Since the cluster is being used more than once in custom use-cases, the cleaning up and resetting becomes crucial. --- .github/actions/e2e-kubernetes/action.yml | 4 +++ .github/actions/e2e-upgrade/action.yml | 4 +++ .github/actions/kamel-cleanup/action.yaml | 49 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/.github/actions/e2e-kubernetes/action.yml b/.github/actions/e2e-kubernetes/action.yml index 44adb5f..4d290d6 100644 --- a/.github/actions/e2e-kubernetes/action.yml +++ b/.github/actions/e2e-kubernetes/action.yml @@ -84,3 +84,7 @@ runs: make test-service-binding make test-quarkus-native make test-kustomize + + - name: Cleanup + uses: ./.github/actions/kamel-cleanup + if: ${{ always() }} diff --git a/.github/actions/e2e-upgrade/action.yml b/.github/actions/e2e-upgrade/action.yml index 5b3c36a..9ea4ed8 100644 --- a/.github/actions/e2e-upgrade/action.yml +++ b/.github/actions/e2e-upgrade/action.yml @@ -101,3 +101,7 @@ runs: # Then run integration tests make test-upgrade + + - name: Cleanup + uses: ./.github/actions/kamel-cleanup + if: ${{ always() }} diff --git a/.github/actions/kamel-cleanup/action.yaml b/.github/actions/kamel-cleanup/action.yaml new file mode 100644 index 0000000..fce1451 --- /dev/null +++ b/.github/actions/kamel-cleanup/action.yaml @@ -0,0 +1,49 @@ +# --------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# --------------------------------------------------------------------------- + +name: kamel-cleanup +description: 'Cleans up the target cluster, removing any e2e test resources' + +runs: + using: "composite" + steps: + - id: remove-installed-camel-crds + name: Remove Installed Camel CRDs + shell: bash + if: ${{ always() }} + run: | + set +e + kubectl get crds | grep camel | awk '{print $1}' | xargs kubectl delete crd &> /dev/null + set -e + + - id: remove-kamel-catalog-source + name: Remove Catalog Source + shell: bash + if: ${{ always() }} + run: | + if [ -z "${{ env.BUILD_BUNDLE_CATALOG_SOURCE }}" ]; then + # Catalog source never defined so nothing to do + exit 0 + fi + + set +e + CATALOG_NS=$(kubectl get catalogsource --all-namespaces | grep ${{ env.BUILD_BUNDLE_CATALOG_SOURCE }} | awk {'print $1'}) + for ns in ${CATALOG_NS} + do + kubectl delete CatalogSource ${{ env.BUILD_BUNDLE_CATALOG_SOURCE }} -n ${ns} + done + set -e
