This is an automated email from the ASF dual-hosted git repository.

tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit e3958ef5facdb47c88d23ab0da2908681b248919
Author: phantomjinx <p.g.richard...@phantomjinx.co.uk>
AuthorDate: Mon Jun 20 14:00:11 2022 +0100

    (e2e): Prepares environment for windows OS support
    
    * Removes the dotenv action from e2e test suite. No longer required and
      does not support windows OS
    
    * Assigns CLUSTER_TYPE in kamel-config-cluster. If not specified then 
default to
      cluster type of kind
    
    * Conditional use of sudo - only for linux
---
 .github/actions/e2e-builder/action.yml             |  1 -
 .github/actions/e2e-common/action.yml              |  1 -
 .github/actions/e2e-install-native/action.yml      |  1 -
 .github/actions/e2e-install/action.yml             |  1 -
 .github/actions/e2e-knative-yaks/action.yml        |  1 -
 .github/actions/e2e-knative/action.yml             |  1 -
 .github/actions/e2e-upgrade/action.yml             |  1 -
 .github/actions/kamel-build-binary/build-binary.sh |  5 ++-
 .../kamel-build-bundle/build-index-image.sh        |  2 +-
 .../actions/kamel-config-cluster-ocp3/action.yml   | 26 ++++++-------
 .github/actions/kamel-config-cluster/action.yaml   | 17 ++++++---
 .../kamel-install-knative/install-knative.sh       |  2 +-
 .github/actions/kamel-install-yaks/action.yml      |  2 +-
 .github/actions/kamel-prepare-env/action.yml       | 44 ++++++++++++++--------
 .github/workflows/builder.yml                      |  3 --
 .github/workflows/common.yml                       |  3 --
 .github/workflows/install.yml                      |  3 --
 .github/workflows/knative.yml                      |  3 --
 .github/workflows/release.yml                      |  3 --
 .github/workflows/upgrade.yml                      |  3 --
 .gitmodules                                        |  1 -
 21 files changed, 59 insertions(+), 65 deletions(-)

diff --git a/.github/actions/e2e-builder/action.yml 
b/.github/actions/e2e-builder/action.yml
index 96f0eb6a0..919a8c3f1 100644
--- a/.github/actions/e2e-builder/action.yml
+++ b/.github/actions/e2e-builder/action.yml
@@ -41,7 +41,6 @@ runs:
     name: Configure Platform
     uses: ./.github/actions/kamel-config-cluster
     with:
-      cluster-type: ${{ env.TEST_CLUSTER }}
       cluster-config-data: ${{ inputs.cluster-config-data }}
       cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
 
diff --git a/.github/actions/e2e-common/action.yml 
b/.github/actions/e2e-common/action.yml
index 12c6993e5..e75c35149 100644
--- a/.github/actions/e2e-common/action.yml
+++ b/.github/actions/e2e-common/action.yml
@@ -38,7 +38,6 @@ runs:
     name: Configure Platform
     uses: ./.github/actions/kamel-config-cluster
     with:
-      cluster-type: ${{ env.TEST_CLUSTER }}
       cluster-config-data: ${{ inputs.cluster-config-data }}
       cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
   #
diff --git a/.github/actions/e2e-install-native/action.yml 
b/.github/actions/e2e-install-native/action.yml
index 1061ff8e5..37b633462 100644
--- a/.github/actions/e2e-install-native/action.yml
+++ b/.github/actions/e2e-install-native/action.yml
@@ -38,7 +38,6 @@ runs:
     name: Configure Platform
     uses: ./.github/actions/kamel-config-cluster
     with:
-      cluster-type: ${{ env.TEST_CLUSTER }}
       cluster-config-data: ${{ inputs.cluster-config-data }}
       cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
 
diff --git a/.github/actions/e2e-install/action.yml 
b/.github/actions/e2e-install/action.yml
index 04fc81da8..68fee7459 100644
--- a/.github/actions/e2e-install/action.yml
+++ b/.github/actions/e2e-install/action.yml
@@ -38,7 +38,6 @@ runs:
     name: Configure Platform
     uses: ./.github/actions/kamel-config-cluster
     with:
-      cluster-type: ${{ env.TEST_CLUSTER }}
       cluster-config-data: ${{ inputs.cluster-config-data }}
       cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
 
diff --git a/.github/actions/e2e-knative-yaks/action.yml 
b/.github/actions/e2e-knative-yaks/action.yml
index 68f072e76..3e624da8e 100644
--- a/.github/actions/e2e-knative-yaks/action.yml
+++ b/.github/actions/e2e-knative-yaks/action.yml
@@ -38,7 +38,6 @@ runs:
     name: Configure Platform
     uses: ./.github/actions/kamel-config-cluster
     with:
-      cluster-type: ${{ env.TEST_CLUSTER }}
       cluster-config-data: ${{ inputs.cluster-config-data }}
       cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
 
diff --git a/.github/actions/e2e-knative/action.yml 
b/.github/actions/e2e-knative/action.yml
index 4a69be056..f445d51bd 100644
--- a/.github/actions/e2e-knative/action.yml
+++ b/.github/actions/e2e-knative/action.yml
@@ -38,7 +38,6 @@ runs:
     name: Configure Platform
     uses: ./.github/actions/kamel-config-cluster
     with:
-      cluster-type: ${{ env.TEST_CLUSTER }}
       cluster-config-data: ${{ inputs.cluster-config-data }}
       cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
 
diff --git a/.github/actions/e2e-upgrade/action.yml 
b/.github/actions/e2e-upgrade/action.yml
index 8da9ee656..bacf81189 100644
--- a/.github/actions/e2e-upgrade/action.yml
+++ b/.github/actions/e2e-upgrade/action.yml
@@ -38,7 +38,6 @@ runs:
     name: Configure Cluster
     uses: ./.github/actions/kamel-config-cluster
     with:
-      cluster-type: ${{ env.TEST_CLUSTER }}
       cluster-config-data: ${{ inputs.cluster-config-data }}
       cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
       require-olm: true
diff --git a/.github/actions/kamel-build-binary/build-binary.sh 
b/.github/actions/kamel-build-binary/build-binary.sh
index ed7228af9..0ba377283 100755
--- a/.github/actions/kamel-build-binary/build-binary.sh
+++ b/.github/actions/kamel-build-binary/build-binary.sh
@@ -95,8 +95,9 @@ else
   make ${RULES}
 fi
 
-echo "Moving kamel binary to /usr/local/bin"
-sudo mv ./kamel /usr/local/bin
+echo "Moving kamel binary to be visible on PATH"
+
+${SUDO} mv ./kamel /usr/bin
 echo "Kamel version installed: $(kamel version)"
 
 #
diff --git a/.github/actions/kamel-build-bundle/build-index-image.sh 
b/.github/actions/kamel-build-bundle/build-index-image.sh
index e5d1fbbbc..48d5c2a79 100755
--- a/.github/actions/kamel-build-bundle/build-index-image.sh
+++ b/.github/actions/kamel-build-bundle/build-index-image.sh
@@ -155,7 +155,7 @@ if [ "${PULL_REGISTRY}" != "${PUSH_REGISTRY}" ]; then
   #
   # Only add PULL_HOST if not already added (avoids repeated appended)
   #
-  sudo sed -i "/${PULL_HOST}/!s/localhost/& ${PULL_HOST} /" /etc/hosts
+  ${SUDO} sed -i "/${PULL_HOST}/!s/localhost/& ${PULL_HOST} /" /etc/hosts
 
   #
   # Bring up the registry:2 instance if not already started
diff --git a/.github/actions/kamel-config-cluster-ocp3/action.yml 
b/.github/actions/kamel-config-cluster-ocp3/action.yml
index 6f26853d6..aa772b547 100644
--- a/.github/actions/kamel-config-cluster-ocp3/action.yml
+++ b/.github/actions/kamel-config-cluster-ocp3/action.yml
@@ -29,26 +29,26 @@ runs:
         export OPENSHIFT_COMMIT=0cbc58b
         export 
MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
 
-        sudo rm -f /etc/resolv.conf
-        sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
-        sudo sh -c 'echo "DNS=8.8.8.8 4.4.4.4" >> /etc/systemd/resolved.conf'
-        sudo service systemd-resolved restart
+        {{ env.SUDO }} rm -f /etc/resolv.conf
+        {{ env.SUDO }} ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
+        {{ env.SUDO }} sh -c 'echo "DNS=8.8.8.8 4.4.4.4" >> 
/etc/systemd/resolved.conf'
+        {{ env.SUDO }} service systemd-resolved restart
 
         # set docker0 to promiscuous mode
-        sudo ip link set docker0 promisc on
+        {{ env.SUDO }} ip link set docker0 promisc on
 
         # Download and install the oc binary
-        sudo mount --make-shared /
+        {{ env.SUDO }} mount --make-shared /
 
-        sudo service docker stop
-        sudo echo '{"insecure-registries": ["172.30.0.0/16"]}' | sudo tee 
/etc/docker/daemon.json > /dev/null
-        sudo service docker start
+        {{ env.SUDO }} service docker stop
+        {{ env.SUDO }} echo '{"insecure-registries": ["172.30.0.0/16"]}' | {{ 
env.SUDO }} tee /etc/docker/daemon.json > /dev/null
+        {{ env.SUDO }} service docker start
 
         
DOWNLOAD_URL=https://github.com/openshift/origin/releases/download/$OPENSHIFT_VERSION/openshift-origin-client-tools-$OPENSHIFT_VERSION-$OPENSHIFT_COMMIT-linux-64bit.tar.gz
         wget -O client.tar.gz ${DOWNLOAD_URL}
         tar xvzOf client.tar.gz > oc.bin
-        sudo mv oc.bin /usr/local/bin/oc
-        sudo chmod 755 /usr/local/bin/oc
+        {{ env.SUDO }} mv oc.bin /usr/bin/oc
+        {{ env.SUDO }} chmod 755 /usr/bin/oc
 
     - id: start-openshift
       name: Start OpenShift Cluster
@@ -59,8 +59,8 @@ runs:
         IP_ADDR="$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut 
-d/ -f1)"
 
         # Setup cluster dir
-        sudo mkdir -p /home/runner/lib/oc
-        sudo chmod 777 /home/runner/lib/oc
+        {{ env.SUDO }} mkdir -p /home/runner/lib/oc
+        {{ env.SUDO }} chmod 777 /home/runner/lib/oc
         cd /home/runner/lib/oc
 
         # Start OpenShift
diff --git a/.github/actions/kamel-config-cluster/action.yaml 
b/.github/actions/kamel-config-cluster/action.yaml
index f58327aad..3f2b88e52 100644
--- a/.github/actions/kamel-config-cluster/action.yaml
+++ b/.github/actions/kamel-config-cluster/action.yaml
@@ -20,11 +20,10 @@ description: 'Delegates to respective cluster action 
depending on type of reques
 
 inputs:
   cluster-type:
-    description: 'The type of cluster required: [kind, ocp3, custom]'
-    required: true
-    default: 'kind'
+    description: 'The type of cluster required: [kind, ocp3, custom] - 
optional (see Override Cluster Type step)'
+    required: false
   cluster-config-data:
-    description: 'Variables for the cluster configuration - required for 
custom cluster type only'
+    description: 'Variables for the cluster configuration - required for 
custom cluster type only optional (see Override Cluster Type step)'
     required: false
   cluster-kube-config-data:
     description: 'Base16 encoded kube config - required for custom cluster 
type only'
@@ -43,12 +42,18 @@ runs:
           #
           # Have custom cluster-config-data so override cluster-type
           #
+          echo "Have cluster-config-data so setting cluster-type to custom"
           echo "CLUSTER_TYPE=custom" >> $GITHUB_ENV
-        else
-          echo "Info: No cluster configuration supplied."
+        elif [ -n "${{ inputs.cluster-type }}" ]; then
+          echo "Cluster-type specified so setting accordingly"
           echo "CLUSTER_TYPE=${{ inputs.cluster-type }}" >> $GITHUB_ENV
+        else
+          echo "Info: No cluster configuration supplied. Default to kind."
+          echo "CLUSTER_TYPE=kind" >> $GITHUB_ENV
         fi
 
+        echo "CLUSTER_TYPE -> ${{ env.CLUSTER_TYPE }}"
+
     - id: execute-kind
       name: Maybe Execute Kind Cluster
       uses: ./.github/actions/kamel-config-cluster-kind
diff --git a/.github/actions/kamel-install-knative/install-knative.sh 
b/.github/actions/kamel-install-knative/install-knative.sh
index 8434afc94..ed529a568 100755
--- a/.github/actions/kamel-install-knative/install-knative.sh
+++ b/.github/actions/kamel-install-knative/install-knative.sh
@@ -26,7 +26,7 @@
 set -e
 
 # Prerequisites
-sudo wget 
https://github.com/mikefarah/yq/releases/download/v4.26.1/yq_linux_amd64 -O 
/usr/bin/yq && sudo chmod +x /usr/bin/yq
+${SUDO} wget 
https://github.com/mikefarah/yq/releases/download/v4.26.1/yq_linux_amd64 -O 
/usr/bin/yq && ${SUDO} chmod +x /usr/bin/yq
 
 set +e
 
diff --git a/.github/actions/kamel-install-yaks/action.yml 
b/.github/actions/kamel-install-yaks/action.yml
index 39f0f2f0b..7f21c1473 100644
--- a/.github/actions/kamel-install-yaks/action.yml
+++ b/.github/actions/kamel-install-yaks/action.yml
@@ -43,7 +43,7 @@ runs:
 
         curl --fail -L 
https://github.com/citrusframework/yaks/releases/download/${DOWNLOAD_VERSION}/yaks-${{
 inputs.version }}-linux-64bit.tar.gz -o yaks.tar.gz
         tar -zxf yaks.tar.gz
-        sudo mv yaks /usr/local/bin/
+        ${{ env.SUDO }} mv yaks /usr/bin/
 
     - name: Install YAKS
       shell: bash
diff --git a/.github/actions/kamel-prepare-env/action.yml 
b/.github/actions/kamel-prepare-env/action.yml
index 90e0bc8d5..3fe70aa0a 100644
--- a/.github/actions/kamel-prepare-env/action.yml
+++ b/.github/actions/kamel-prepare-env/action.yml
@@ -21,7 +21,21 @@ description: 'Initialise the test environment with tools. 
(Will only run once pe
 runs:
   using: "composite"
   steps:
-  
+    - name: Set Env Vars
+      shell: bash
+      run: |
+        if [ "$RUNNER_OS" == "Linux" ]; then
+          SUDO=sudo
+        fi
+
+        echo "SUDO=${SUDO}" >> $GITHUB_ENV
+    #
+    # This is a docker action so its pre-builds the image prior to
+    # running it. The building occurs prior to all steps regardless
+    # of where its located to run. Therefore, it must be run prior to
+    # clean-up since that step removes all docker image in order to
+    # claim back as much space as possible.
+    #
     - name: Cleanup
       shell: bash
       if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
@@ -32,21 +46,19 @@ runs:
 
         if [ "$RUNNER_OS" == "Linux" ]; then
           echo "Cleaning up resources:"
-          sudo swapoff -a
-          sudo rm -f /swapfile
-          sudo apt clean
-          sudo rm -rf /usr/share/dotnet
-          sudo rm -rf /opt/ghc
-          sudo rm -rf "/usr/local/share/boost"
-          sudo rm -rf "$AGENT_TOOLSDIRECTORY"
-          df -kh
-          docker rmi $(docker image ls -aq) || true # Don't fail if image is 
not present
-          df -kh
-        else
-          echo "OS $RUNNER_OS is not yet supported"
-          exit 1
+          ${{ env.SUDO }} swapoff -a
+          ${{ env.SUDO }} rm -f /swapfile
+          ${{ env.SUDO }} apt clean
+          ${{ env.SUDO }} rm -rf /usr/share/dotnet
+          ${{ env.SUDO }} rm -rf /opt/ghc
+          ${{ env.SUDO }} rm -rf "/usr/local/share/boost"
+          ${{ env.SUDO }} rm -rf "$AGENT_TOOLSDIRECTORY"
         fi
 
+        df -kh
+        docker rmi $(docker image ls -aq) || true # Don't fail if image is not 
present
+        df -kh
+
         echo "Final status:"
         df -h
 
@@ -67,7 +79,9 @@ runs:
       if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
       run: |
         # reinstall kustomize to be always on the same version
-        sudo rm $(which kustomize)
+        if [ $(which kustomize) == "0" ]; then
+          ${{ env.SUDO }} rm $(which kustomize)
+        fi
         make kustomize
 
         # Add kustomize to PATH
diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml
index 4a00e2a5e..a72cce9cd 100644
--- a/.github/workflows/builder.yml
+++ b/.github/workflows/builder.yml
@@ -17,9 +17,6 @@
 
 name: builder
 
-env:
-  TEST_CLUSTER: kind
-
 on:
   pull_request:
     branches:
diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml
index f9dc3df4b..f1a1d5681 100644
--- a/.github/workflows/common.yml
+++ b/.github/workflows/common.yml
@@ -17,9 +17,6 @@
 
 name: common
 
-env:
-  TEST_CLUSTER: kind
-
 on:
   pull_request:
     branches:
diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml
index ec41b023f..c48d4a045 100644
--- a/.github/workflows/install.yml
+++ b/.github/workflows/install.yml
@@ -17,9 +17,6 @@
 
 name: install
 
-env:
-  TEST_CLUSTER: kind
-
 on:
   pull_request:
     branches:
diff --git a/.github/workflows/knative.yml b/.github/workflows/knative.yml
index 63ab9400d..34cd9e1df 100644
--- a/.github/workflows/knative.yml
+++ b/.github/workflows/knative.yml
@@ -17,9 +17,6 @@
 
 name: knative
 
-env:
-  TEST_CLUSTER: kind
-
 on:
   pull_request:
     branches:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 4631d7a52..cad9d2704 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -17,9 +17,6 @@
 # limitations under the License.
 name: release
 
-env:
-  TEST_CLUSTER: kind
-
 on:
   schedule:
     - cron: "10 23 * * *"
diff --git a/.github/workflows/upgrade.yml b/.github/workflows/upgrade.yml
index 153a24cbe..802182494 100644
--- a/.github/workflows/upgrade.yml
+++ b/.github/workflows/upgrade.yml
@@ -17,9 +17,6 @@
 
 name: upgrade
 
-env:
-  TEST_CLUSTER: kind
-
 on:
   pull_request:
     branches:
diff --git a/.gitmodules b/.gitmodules
index 5dd35b063..38b2437b4 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,4 +4,3 @@
 [submodule ".github/actions/changelog"]
        path = .github/actions/changelog
        url = https://github.com/CharMixer/auto-changelog-action
-       

Reply via email to