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 b56619edd946a294ddad7cf1152513b0b9bbcfb4 Author: phantomjinx <[email protected]> AuthorDate: Mon Dec 13 17:00:27 2021 +0000 Converts kubernetes workflow to a composite action --- .github/actions/e2e-kubernetes/action.yml | 76 ++++++++++++++++++++ .github/actions/e2e-upgrade/action.yml | 39 ++++++----- .../{kamel-build => kamel-build-binary}/action.yml | 14 ++-- .github/actions/kamel-build-bundle/action.yaml | 8 +++ .github/actions/kamel-build/action.yml | 81 ++++++++++------------ .../actions/kamel-config-cluster-custom/action.yml | 64 +++++++++++------ .../actions/kamel-config-cluster-kind/action.yml | 29 ++++++-- .../actions/kamel-config-cluster-ocp3/action.yml | 32 ++++++++- .github/actions/kamel-config-cluster/action.yaml | 36 +++++----- .../actions/kamel-install-cluster-setup/action.yml | 5 +- .github/actions/kamel-prepare-env/action.yml | 64 ++++++++++------- .github/workflows/builder.yml | 2 +- .github/workflows/knative.yml | 4 +- .github/workflows/kubernetes.yml | 43 +----------- .github/workflows/local.yml | 2 +- .github/workflows/openshift.yml | 2 +- 16 files changed, 315 insertions(+), 186 deletions(-) diff --git a/.github/actions/e2e-kubernetes/action.yml b/.github/actions/e2e-kubernetes/action.yml new file mode 100644 index 0000000..1f55653 --- /dev/null +++ b/.github/actions/e2e-kubernetes/action.yml @@ -0,0 +1,76 @@ +# --------------------------------------------------------------------------- +# 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: e2e-kubernetes +description: 'End-to-End tests for 80/20 use-cases' + +inputs: + platform-config: + description: 'The configuration of the underlying cluster (if cluster-type is custom)' + required: false + +runs: + using: "composite" + + steps: + - id: prepare-env + name: Prepare Test Environment + uses: ./.github/actions/kamel-prepare-env + + - id: configure-platform + name: Configure Platform + uses: ./.github/actions/kamel-config-cluster + with: + cluster-type: ${{ steps.prepare-env.outputs.cluster-platform }} + platform-config: ${{ inputs.platform-config }} + + - id: build-kamel + name: Build Kamel + uses: ./.github/actions/kamel-build + with: + image-registry-push-host: ${{ steps.configure-platform.outputs.image-registry-push-host }} + image-registry-pull-host: ${{ steps.configure-platform.outputs.image-registry-pull-host }} + image-namespace: ${{ steps.configure-platform.outputs.image-namespace }} + # Builds the bundle if an OLM is available - depends on cluster being tested + build-bundle: ${{ steps.configure-platform.outputs.olm-available }} + + - id: install-kamel-cluster-setup + name: Install Kamel Cluster Setup + uses: ./.github/actions/kamel-install-cluster-setup + with: + kube-admin-user-ctx: ${{ steps.configure-platform.outputs.kube-admin-user-ctx }} + + - id: run-it + name: Run IT + shell: bash + run: | + # Cluster environment + export CUSTOM_IMAGE=${{ steps.build-kamel.outputs.local-image-name }} + export CUSTOM_VERSION=${{ steps.build-kamel.outputs.local-image-version }} + + export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) + export KAMEL_INSTALL_REGISTRY=${{ steps.configure-platform.outputs.image-registry-pull-host }} + export KAMEL_INSTALL_REGISTRY_INSECURE=${{ steps.configure-platform.outputs.image-registry-insecure }} + export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} + export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} + export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} + + # Then run integration tests + make test-integration + make test-service-binding + make test-quarkus-native + make test-kustomize diff --git a/.github/actions/e2e-upgrade/action.yml b/.github/actions/e2e-upgrade/action.yml index 6edc9b5..fb20822 100644 --- a/.github/actions/e2e-upgrade/action.yml +++ b/.github/actions/e2e-upgrade/action.yml @@ -30,8 +30,6 @@ runs: - id: prepare-env name: Prepare Test Environment uses: ./.github/actions/kamel-prepare-env - with: - install-opm: true - id: configure-platform name: Configure Platform @@ -39,6 +37,7 @@ runs: with: cluster-type: ${{ steps.prepare-env.outputs.cluster-platform }} platform-config: ${{ inputs.platform-config }} + require-olm: true - name: Get Released Kamel CLI shell: bash @@ -64,25 +63,17 @@ runs: exit 1 fi - - id: build-kamel-binary - name: Build Kamel Binary + - id: build-kamel + name: Build Kamel uses: ./.github/actions/kamel-build with: image-registry-push-host: ${{ steps.configure-platform.outputs.image-registry-push-host }} image-registry-pull-host: ${{ steps.configure-platform.outputs.image-registry-pull-host }} image-namespace: ${{ steps.configure-platform.outputs.image-namespace }} - # Avoid overwriting last-released version of binary - install-kamel-binary: false - - - id: build-kamel-bundle - name: Build Kamel Metadata Bundle - uses: ./.github/actions/kamel-build-bundle - with: - image-registry-push-host: ${{ steps.configure-platform.outputs.image-registry-push-host }} - image-registry-pull-host: ${{ steps.configure-platform.outputs.image-registry-pull-host }} - image-namespace: ${{ steps.configure-platform.outputs.image-namespace }} - local-image-name: ${{ steps.build-kamel-binary.outputs.local-image-name }} - local-image-version: ${{ steps.build-kamel-binary.outputs.local-image-version }} + # Builds the bundle if an OLM is available. + # Since configure-platform requires OLM then this should be true + build-bundle: ${{ steps.configure-platform.outputs.olm-available }} + kube-admin-user-ctx: ${{ steps.configure-platform.outputs.kube-admin-user-ctx }} - name: Run IT shell: bash @@ -93,17 +84,27 @@ runs: echo "Kamel version: $(${RELEASED_KAMEL_BIN} version)" # Configure install options - export CUSTOM_IMAGE=${{ steps.build-kamel-binary.outputs.local-image-name }} - export CUSTOM_VERSION=${{ steps.build-kamel-binary.outputs.local-image-version }} + export CUSTOM_IMAGE=${{ steps.build-kamel.outputs.local-image-name }} + export CUSTOM_VERSION=${{ steps.build-kamel.outputs.local-image-version }} export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) export KAMEL_INSTALL_REGISTRY=${{ steps.configure-platform.outputs.image-registry-pull-host }} export KAMEL_INSTALL_REGISTRY_INSECURE=${{ steps.configure-platform.outputs.image-registry-insecure }} + # Despite building a bundle we don't want it installed immediately so no OLM_INDEX_BUNDLE var + # Configure test options export CAMEL_K_PREV_IIB=quay.io/operatorhubio/catalog:latest - export CAMEL_K_NEW_IIB=${{ steps.build-kamel-bundle.outputs.local-image-bundle-index }} + export CAMEL_K_NEW_IIB=${{ steps.build-kamel.outputs.local-image-bundle-index }} export KAMEL_K_TEST_RELEASE_VERSION=$(make get-last-released-version) export KAMEL_K_TEST_OPERATOR_CURRENT_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} # Then run integration tests make test-upgrade + + - name: Cleanup-Tests + if: ${{ always() }} + shell: bash + run: | + if [ -n "${{ env.PLATFORM_CONFIG }}" ]; then + rm -f ${{ env.PLATFORM_CONFIG }} + fi diff --git a/.github/actions/kamel-build/action.yml b/.github/actions/kamel-build-binary/action.yml similarity index 88% copy from .github/actions/kamel-build/action.yml copy to .github/actions/kamel-build-binary/action.yml index f6af262..959d26c 100644 --- a/.github/actions/kamel-build/action.yml +++ b/.github/actions/kamel-build-binary/action.yml @@ -15,7 +15,7 @@ # limitations under the License. # --------------------------------------------------------------------------- -name: kamel-build +name: kamel-build-binary description: 'Builds kamel operator binary' inputs: @@ -32,10 +32,6 @@ inputs: make-rules: description: 'Override the default make rules' required: false - install-kamel-binary: - description: 'Install the kamel binary onto the path' - required: false - default: true runs: using: "composite" @@ -65,11 +61,9 @@ runs: make ${RULES} - if [ "${{ inputs.install-kamel-binary }}" == "true" ]; then - echo "Moving kamel binary to /usr/local/bin" - sudo mv ./kamel /usr/local/bin - echo "Kamel version installed: $(kamel version)" - fi + echo "Moving kamel binary to /usr/local/bin" + sudo mv ./kamel /usr/local/bin + echo "Kamel version installed: $(kamel version)" # # Use the PULL host to ensure the correct image:tag diff --git a/.github/actions/kamel-build-bundle/action.yaml b/.github/actions/kamel-build-bundle/action.yaml index f0eff2c..ee2b561 100644 --- a/.github/actions/kamel-build-bundle/action.yaml +++ b/.github/actions/kamel-build-bundle/action.yaml @@ -97,6 +97,14 @@ runs: export LOCAL_IMAGE_BUNDLE=${{ inputs.image-registry-pull-host }}/${{ inputs.image-namespace }}/camel-k-bundle:${{ inputs.local-image-version }} echo "::set-output name=local-image-bundle::$(echo ${LOCAL_IMAGE_BUNDLE})" + - id: install-opm + name: Install opm if required + shell: bash + run: | + curl -L https://github.com/operator-framework/operator-registry/releases/download/v1.16.1/linux-amd64-opm -o opm + chmod +x opm + sudo mv opm /usr/local/bin/ + - id: build-index-image name: Create New Index Image shell: bash diff --git a/.github/actions/kamel-build/action.yml b/.github/actions/kamel-build/action.yml index f6af262..8d14efa 100644 --- a/.github/actions/kamel-build/action.yml +++ b/.github/actions/kamel-build/action.yml @@ -16,7 +16,7 @@ # --------------------------------------------------------------------------- name: kamel-build -description: 'Builds kamel operator binary' +description: 'Builds kamel operator image and the bundle' inputs: image-registry-push-host: @@ -29,60 +29,55 @@ inputs: description: 'Namespace in which to store the image' required: false default: 'apache' - make-rules: - description: 'Override the default make rules' - required: false install-kamel-binary: description: 'Install the kamel binary onto the path' required: false default: true + make-rules: + description: 'Override the default make rules' + required: false + build-bundle: + description: 'Build a bundle for install into OLM catalog' + required: true + default: false runs: using: "composite" steps: - - id: build-operator - name: Build Kamel Operator - shell: bash - run: | - echo "Build Kamel from source" - - if [ -n "${{ inputs.image-registry-push-host }}" ]; then - # - # Build with the PUSH host to ensure the correct image:tag - # for docker to push the image. - # - export CUSTOM_IMAGE=${{ inputs.image-registry-push-host }}/${{ inputs.image-namespace }}/camel-k - fi - - RULES="PACKAGE_ARTIFACTS_STRATEGY=download build package-artifacts images" - if [ -n "${{ inputs.make-rules }}" ]; then - RULES="${{ inputs.make-rules }}" - fi - - if [ -n "${{ inputs.image-registry-push-host }}" ]; then - RULES="${RULES} images-push" - fi - - make ${RULES} - - if [ "${{ inputs.install-kamel-binary }}" == "true" ]; then - echo "Moving kamel binary to /usr/local/bin" - sudo mv ./kamel /usr/local/bin - echo "Kamel version installed: $(kamel version)" - fi + - id: build-kamel-binary + name: Build Kamel Binary + uses: ./.github/actions/kamel-build-binary + with: + image-registry-push-host: ${{ inputs.image-registry-push-host }} + image-registry-pull-host: ${{ inputs.image-registry-pull-host }} + image-namespace: ${{ inputs.image-namespace }} + make-rules: ${{ inputs.make-rules }} + install-kamel-binary: ${{ inputs.install-kamel-binary }} - # - # Use the PULL host to ensure the correct image:tag - # is passed into the tests for the deployment to pull from - # - export LOCAL_IMAGE_NAME=${{ inputs.image-registry-pull-host }}/${{ inputs.image-namespace }}/camel-k - echo "::set-output name=local-img-name::$(echo ${LOCAL_IMAGE_NAME})" - echo "::set-output name=local-img-version::$(make get-version)" + # + # By default do not build the image bundle + # + - id: build-kamel-bundle + name: Build Kamel Metadata Bundle + uses: ./.github/actions/kamel-build-bundle + if: ${{ inputs.build-bundle != true }} + with: + image-registry-push-host: ${{ inputs.image-registry-push-host }} + image-registry-pull-host: ${{ inputs.image-registry-pull-host }} + image-namespace: ${{ inputs.image-namespace }} + local-image-name: ${{ steps.build-kamel-binary.outputs.local-image-name }} + local-image-version: ${{ steps.build-kamel-binary.outputs.local-image-version }} outputs: local-image-name: description: "Reference of the camel-k image" - value: ${{ steps.build-operator.outputs.local-img-name }} + value: ${{ steps.build-kamel-binary.outputs.local-image-name }} local-image-version: description: "Reference of the camel-k image version" - value: ${{ steps.build-operator.outputs.local-img-version }} + value: ${{ steps.build-kamel-binary.outputs.local-image-version }} + local-image-bundle: + description: "Reference of the camel-k metadata bundle image" + value: ${{ steps.build-kamel-bundle.outputs.local-image-bundle }} + local-image-bundle-index: + description: "Reference of the camel-k metadata bundle index image" + value: ${{ steps.build-kamel-bundle.outputs.local-image-bundle-index }} diff --git a/.github/actions/kamel-config-cluster-custom/action.yml b/.github/actions/kamel-config-cluster-custom/action.yml index 1d521f8..dca1939 100644 --- a/.github/actions/kamel-config-cluster-custom/action.yml +++ b/.github/actions/kamel-config-cluster-custom/action.yml @@ -24,8 +24,17 @@ runs: - name: Read platform-config variable to temporary file & override PLATFORM_TYPE if platform config defined shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + export PLATFORM_CONFIG=/tmp/platform-config.json + if [ -f ${PLATFORM_CONFIG} ]; then + rm -f ${PLATFORM_CONFIG} + fi + touch "${PLATFORM_CONFIG}" if [ -z "${{ env.PLATFORM_CONFIG_DATA }}" ]; then echo "Error: No PLATFORM_CONFIG_DATA has been defined" @@ -50,15 +59,24 @@ runs: fi - name: Platform-config JSON to variables - uses: ./.github/actions/json-to-variables + uses: ./.github/actions/conditional with: - filename: ${{ env.PLATFORM_CONFIG }} - prefix: 'e2e' + if: ${{ env.CLUSTER_CONFIGURED != 'true' }} + step: | + uses: ./.github/actions/json-to-variables + with: + filename: ${{ env.PLATFORM_CONFIG }} + prefix: 'e2e' - id: connect-cluster name: Connect to cluster shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + if [ -z "${{ env.e2e_kube-config-data }}" ]; then echo "Error: kube config data property cannot be found" exit 1 @@ -112,14 +130,24 @@ runs: name: Info shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + kubectl describe nodes - id: configure-developer-user name: Configure Developer User shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + # Aggregate pod eviction permission to the default admin role - cat <<EOF | oc apply -f - + cat <<EOF | kubectl apply -f - kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: @@ -133,7 +161,7 @@ runs: EOF # Grant nodes permission to the default developer user - cat <<EOF | oc apply -f - + cat <<EOF | kubectl apply -f - kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: @@ -143,7 +171,8 @@ runs: resources: ["nodes"] verbs: ["get","list"] EOF - cat <<EOF | oc apply -f - + + cat <<EOF | kubectl apply -f - kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: @@ -177,6 +206,11 @@ runs: - id: extract-config shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + echo "IMAGE_REGISTRY_PUSH_HOST=${{ env.e2e_image-registry-push-host }}" >> $GITHUB_ENV echo "IMAGE_REGISTRY_PULL_HOST=${{ env.e2e_image-registry-pull-host }}" >> $GITHUB_ENV echo "IMAGE_REGISTRY_INSECURE=${{ env.e2e_image-registry-insecure }}" >> $GITHUB_ENV @@ -195,21 +229,11 @@ runs: echo "KUBE_USER_CTX=${{ env.e2e_kube-user-ctx }}" >> $GITHUB_ENV # - # Export the flag for installing olm + # Export the flag for olm capability # - echo "INSTALL_OLM=${{ env.e2e_install-olm }}" >> $GITHUB_ENV + echo "HAS_OLM=${{ env.e2e_has-olm }}" >> $GITHUB_ENV # - # Clear out environment variables no longer required + # Avoid configuring the cluster repeatedly # - echo "PLATFORM_CONFIG=" >> $GITHUB_ENV - echo "e2e_image-registry-push-host=" >> $GITHUB_ENV - echo "e2e_image-registry-pull-host=" >> $GITHUB_ENV - echo "e2e_image-namespace=" >> $GITHUB_ENV - echo "e2e_image-registry-user=" >> $GITHUB_ENV - echo "e2e_image-registry-token=" >> $GITHUB_ENV - echo "e2e_image-registry-insecure=" >> $GITHUB_ENV - echo "e2e_kube-admin-user-ctx=" >> $GITHUB_ENV - echo "e2e_kube-config-data=" >> $GITHUB_ENV - echo "e2e_kube-user-ctx=" >> $GITHUB_ENV - echo "e2e_install-olm=" >> $GITHUB_ENV + echo "CLUSTER_CONFIGURED=true" >> $GITHUB_ENV diff --git a/.github/actions/kamel-config-cluster-kind/action.yml b/.github/actions/kamel-config-cluster-kind/action.yml index e6b62b8..7181b36 100644 --- a/.github/actions/kamel-config-cluster-kind/action.yml +++ b/.github/actions/kamel-config-cluster-kind/action.yml @@ -23,20 +23,35 @@ runs: steps: - id: install-cluster name: Install Cluster - uses: container-tools/kind-action@v1 + uses: ./.github/actions/conditional with: - version: v0.11.0 - node_image: kindest/node:v1.21.1@sha256:fae9a58f17f18f06aeac9772ca8b5ac680ebbed985e266f711d936e91d113bad + if: ${{ env.CLUSTER_CONFIGURED != 'true' }} + step: | + uses: container-tools/kind-action@v1 + with: + version: v0.11.0 + node_image: kindest/node:v1.21.1@sha256:fae9a58f17f18f06aeac9772ca8b5ac680ebbed985e266f711d936e91d113bad + - id: info name: Info shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + kubectl cluster-info kubectl describe nodes - id: extract-config shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + # Kind has the same interface for both pushing and pulling images in its registry echo "IMAGE_REGISTRY_PUSH_HOST=${{ env.KIND_REGISTRY }}" >> $GITHUB_ENV echo "IMAGE_REGISTRY_PULL_HOST=${{ env.KIND_REGISTRY }}" >> $GITHUB_ENV @@ -50,7 +65,11 @@ runs: echo "KUBE_USER_CTX=$(kubectl config current-context)" >> $GITHUB_ENV # - # Export the flag for installing olm + # Export the flag for olm capability # - echo "INSTALL_OLM=true" >> $GITHUB_ENV + echo "HAS_OLM=false" >> $GITHUB_ENV + # + # Avoid configuring the cluster repeatedly + # + echo "CLUSTER_CONFIGURED=true" >> $GITHUB_ENV diff --git a/.github/actions/kamel-config-cluster-ocp3/action.yml b/.github/actions/kamel-config-cluster-ocp3/action.yml index a113361..330389d 100644 --- a/.github/actions/kamel-config-cluster-ocp3/action.yml +++ b/.github/actions/kamel-config-cluster-ocp3/action.yml @@ -24,6 +24,11 @@ runs: - name: Get OpenShift Client (oc) shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + export OPENSHIFT_VERSION=v3.11.0 export OPENSHIFT_COMMIT=0cbc58b export MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn @@ -53,6 +58,11 @@ runs: name: Start OpenShift Cluster shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + # Figure out this host's IP address IP_ADDR="$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)" @@ -91,12 +101,22 @@ runs: name: Info shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + oc describe nodes - id: configure-developer-user name: Configure Developer User shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + # Aggregate pod eviction permission to the default admin role cat <<EOF | oc apply -f - kind: ClusterRole @@ -188,7 +208,17 @@ runs: - id: extract-kube-config shell: bash run: | + if [ "${{ env.CLUSTER_CONFIGURED }}" == "true" ]; then + echo "Cluster configuration already performed ... skipping" + exit 0 + fi + echo "IMAGE_REGISTRY_PUSH_HOST=" >> $GITHUB_ENV echo "IMAGE_REGISTRY_PULL_HOST=" >> $GITHUB_ENV echo "IMAGE_REGISTRY_INSECURE=false" >> $GITHUB_ENV - echo "INSTALL_OLM=false" >> $GITHUB_ENV + echo "HAS_OLM=true" >> $GITHUB_ENV + + # + # Avoid configuring the cluster repeatedly + # + echo "CLUSTER_CONFIGURED=true" >> $GITHUB_ENV diff --git a/.github/actions/kamel-config-cluster/action.yaml b/.github/actions/kamel-config-cluster/action.yaml index 393baad..894fb34 100644 --- a/.github/actions/kamel-config-cluster/action.yaml +++ b/.github/actions/kamel-config-cluster/action.yaml @@ -26,6 +26,9 @@ inputs: platform-config: description: 'The JSON configuration of the platform - required for custom platform type only' required: false + require-olm: + description: 'If OLM is not available by default ensure that it is installed' + default: false runs: using: "composite" @@ -97,7 +100,7 @@ runs: echo "::set-output name=image-registry-insecure::$(echo ${{ env.IMAGE_REGISTRY_INSECURE }})" echo "::set-output name=kube-admin-user-ctx::$(echo ${{ env.KUBE_ADMIN_USER_CTX }})" echo "::set-output name=kube-user-ctx::$(echo ${{ env.KUBE_USER_CTX }})" - echo "::set-output name=install-olm::$(echo ${{ env.INSTALL_OLM }})" + echo "::set-output name=has-olm::$(echo ${{ env.HAS_OLM }})" if [ -n "${{ env.IMAGE_NAMESPACE }}" ]; then echo "::set-output name=image-namespace::$(echo ${{ env.IMAGE_NAMESPACE }})" @@ -105,19 +108,6 @@ runs: echo "::set-output name=image-namespace::$(echo ${{ env.DEFAULT_IMAGE_NAMESPACE }})" fi - # - # Clear out environment variables - # - echo "TEST_PLATFORM_CLUSTER=" >> $GITHUB_ENV - echo "IMAGE_REGISTRY_PUSH_HOST=" >> $GITHUB_ENV - echo "IMAGE_REGISTRY_PULL_HOST=" >> $GITHUB_ENV - echo "IMAGE_REGISTRY_INSECURE=" >> $GITHUB_ENV - echo "KUBE_ADMIN_USER_CTX=" >> $GITHUB_ENV - echo "KUBE_USER_CTX=" >> $GITHUB_ENV - echo "INSTALL_OLM=" >> $GITHUB_ENV - echo "IMAGE_NAMESPACE=" >> $GITHUB_ENV - echo "DEFAULT_IMAGE_NAMESPACE=" >> $GITHUB_ENV - # # Install opm if required # @@ -138,9 +128,17 @@ runs: name: Install OLM shell: bash run: | - if [ "${{ steps.platform-info.outputs.install-olm }}" == "false" ]; then - # OLM explicitly not required - installed by default - echo "OLM install not required for this cluster" + if [ "${{ steps.platform-info.outputs.has-olm }}" == "true" ]; then + # OLM already installed by default + echo "OLM already available in cluster" + echo "::set-output name=has-olm::$(echo true)" + exit 0 + fi + + if [ "${{ inputs.require-olm }}" != "true" ]; then + # OLM not explicitly requested + echo "OLM not explicity required for testing" + echo "::set-output name=has-olm::$(echo false)" exit 0 fi @@ -176,6 +174,7 @@ runs: kubectl config use-context "${ctx}" echo "Complete" + echo "::set-output name=has-olm::$(echo true)" outputs: image-registry-push-host: @@ -196,3 +195,6 @@ outputs: kube-user-ctx: description: "The user context of the cluster" value: ${{ steps.platform-info.outputs.kube-user-ctx }} + olm-available: + description: "Whether an OLM service is available in the cluster" + value: ${{ steps.install-olm.outputs.has-olm }} diff --git a/.github/actions/kamel-install-cluster-setup/action.yml b/.github/actions/kamel-install-cluster-setup/action.yml index e1ac5bb..a0f17ae 100644 --- a/.github/actions/kamel-install-cluster-setup/action.yml +++ b/.github/actions/kamel-install-cluster-setup/action.yml @@ -40,7 +40,10 @@ runs: # kubectl config use-context "${{ inputs.kube-admin-user-ctx }}" - kamel install --cluster-setup + # + # Ensure built binary CRDs are always installed by turning off olm + # + kamel install --cluster-setup --olm=false # # Change back to original context diff --git a/.github/actions/kamel-prepare-env/action.yml b/.github/actions/kamel-prepare-env/action.yml index 36b9278..f3ec458 100644 --- a/.github/actions/kamel-prepare-env/action.yml +++ b/.github/actions/kamel-prepare-env/action.yml @@ -18,12 +18,6 @@ name: kamel-prepare-env description: 'Initialise the test environment with tools' -inputs: - install-opm: - description: 'Install opm alongside cluster for bundle-related operations' - required: false - default: false - runs: using: "composite" steps: @@ -42,6 +36,14 @@ runs: - name: Cleanup shell: bash run: | + # + # Only perform the cleaning once. + # + if [ "${{ env.ENV_PREPARED }}" == "true" ]; then + echo "Cleaning of docker already performed ... skipping" + exit 0 + fi + ls -lart echo "Initial status:" df -h @@ -67,18 +69,34 @@ runs: df -h - name: Set up JDK 11 - uses: AdoptOpenJDK/install-jdk@v1 + uses: ./.github/actions/conditional with: - version: "11" + if: ${{ env.ENV_PREPARED != 'true' }} + step: | + uses: AdoptOpenJDK/install-jdk@v1 + with: + version: "11" - name: Set Go - uses: actions/setup-go@v2 # Version 2 adds GOBIN to PATH + uses: ./.github/actions/conditional with: - go-version: 1.16.x + if: ${{ env.ENV_PREPARED != 'true' }} + step: | + uses: actions/setup-go@v2 # Version 2 adds GOBIN to PATH + with: + go-version: 1.16.x - name: (Re-)install kustomize shell: bash run: | + # + # Only perform the kustomize install once. + # + if [ "${{ env.ENV_PREPARED }}" == "true" ]; then + echo "Install of kustomize already performed ... skipping" + exit 0 + fi + # reinstall kustomize to be always on the same version sudo rm $(which kustomize) make kustomize @@ -91,22 +109,13 @@ runs: # Install a version of kubectl for generic access to cluster # - id: install-kubectl - uses: azure/setup-kubectl@v1 + uses: ./.github/actions/conditional with: - version: 'latest' - - # - # Install opm if required - # - - id: install-opm - name: Install opm if required - shell: bash - run: | - if [ "${{ inputs.install-opm }}" == "true" ]; then - curl -L https://github.com/operator-framework/operator-registry/releases/download/v1.19.5/linux-amd64-opm -o opm - chmod +x opm - sudo mv opm /usr/local/bin/ - fi + if: ${{ env.ENV_PREPARED != 'true' }} + step: | + uses: azure/setup-kubectl@v1 + with: + version: 'latest' - id: report-platform name: Report Platform @@ -118,6 +127,11 @@ runs: echo "::set-output name=platform::$(echo kind)" fi + # + # Avoid preparing the environment repeatedly + # + echo "ENV_PREPARED=true" >> $GITHUB_ENV + outputs: cluster-platform: description: "Preferred environment set by .env file (default 'kind')" diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml index f78cc67..888e128 100644 --- a/.github/workflows/builder.yml +++ b/.github/workflows/builder.yml @@ -80,7 +80,7 @@ jobs: - id: build-kamel-binary name: Build Kamel Binary - uses: ./.github/actions/kamel-build + uses: ./.github/actions/kamel-build-binary with: image-registry: ${{ steps.configure-platform.outputs.image-registry }} diff --git a/.github/workflows/knative.yml b/.github/workflows/knative.yml index 950b127..e9048b0 100644 --- a/.github/workflows/knative.yml +++ b/.github/workflows/knative.yml @@ -73,7 +73,7 @@ jobs: - id: build-kamel-binary name: Build Kamel Binary - uses: ./.github/actions/kamel-build + uses: ./.github/actions/kamel-build-binary with: image-registry: ${{ steps.configure-platform.outputs.image-registry }} @@ -136,7 +136,7 @@ jobs: - id: build-kamel-binary name: Build Kamel Binary - uses: ./.github/actions/kamel-build + uses: ./.github/actions/kamel-build-binary with: image-registry: ${{ steps.configure-platform.outputs.image-registry }} diff --git a/.github/workflows/kubernetes.yml b/.github/workflows/kubernetes.yml index ca23a01..fa5b64c 100644 --- a/.github/workflows/kubernetes.yml +++ b/.github/workflows/kubernetes.yml @@ -59,44 +59,7 @@ jobs: persist-credentials: false submodules: recursive - - id: prepare-env - name: Prepare Test Environment - uses: ./.github/actions/kamel-prepare-env - - - id: configure-platform - name: Configure Platform - uses: ./.github/actions/kamel-config-cluster - with: - cluster-type: ${{ steps.prepare-env.outputs.cluster-platform }} - - - id: build-kamel-binary - name: Build Kamel Binary - uses: ./.github/actions/kamel-build - with: - image-registry: ${{ steps.configure-platform.outputs.image-registry }} - - - name: Install Kamel Cluster Setup - uses: ./.github/actions/kamel-install-cluster-setup + - name: Execute Tests + uses: ./.github/actions/e2e-kubernetes with: - kube-admin-user-ctx: ${{ steps.configure-platform.outputs.kube-admin-user-ctx }} - - - name: Run IT - run: | - # Cluster environment - export KAMEL_INSTALL_REGISTRY=${{ steps.configure-platform.outputs.image-registry }} - export KAMEL_INSTALL_REGISTRY_INSECURE=${{ steps.configure-platform.outputs.image-registry-insecure }} - export CUSTOM_IMAGE=${{ steps.build-kamel-binary.outputs.local-image-name }} - export CUSTOM_VERSION=${{ steps.build-kamel-binary.outputs.local-image-version }} - export KAMEL_INSTALL_OPERATOR_IMAGE=${CUSTOM_IMAGE}:${CUSTOM_VERSION} - export CAMEL_K_TEST_IMAGE_NAME=${CUSTOM_IMAGE} - export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION} - - # Test options - export KAMEL_INSTALL_MAVEN_REPOSITORIES=$(make get-staging-repo) - export KAMEL_INSTALL_BUILD_PUBLISH_STRATEGY=Spectrum - - # Then run integration tests - make test-integration - make test-service-binding - make test-quarkus-native - make test-kustomize + platform-config: ${{ secrets.E2E_PLATFORM_CONFIG }} diff --git a/.github/workflows/local.yml b/.github/workflows/local.yml index 16d8eb6..cd8a9a2 100644 --- a/.github/workflows/local.yml +++ b/.github/workflows/local.yml @@ -65,7 +65,7 @@ jobs: - id: build-kamel-binary name: Build Kamel Binary - uses: ./.github/actions/kamel-build + uses: ./.github/actions/kamel-build-binary with: make-rules: 'build-kamel' diff --git a/.github/workflows/openshift.yml b/.github/workflows/openshift.yml index 64d28b6..0470dbb 100644 --- a/.github/workflows/openshift.yml +++ b/.github/workflows/openshift.yml @@ -71,7 +71,7 @@ jobs: - id: build-kamel-binary name: Build Kamel Binary - uses: ./.github/actions/kamel-build + uses: ./.github/actions/kamel-build-binary - name: Install Kamel Cluster Setup uses: ./.github/actions/kamel-install-cluster-setup
