Skip to content

Commit

Permalink
(e2e): Prepares environment for windows OS support
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
phantomjinx authored and tadayosi committed Dec 20, 2022
1 parent fd02506 commit e3958ef
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 65 deletions.
1 change: 0 additions & 1 deletion .github/actions/e2e-builder/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
1 change: 0 additions & 1 deletion .github/actions/e2e-common/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
#
Expand Down
1 change: 0 additions & 1 deletion .github/actions/e2e-install-native/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
1 change: 0 additions & 1 deletion .github/actions/e2e-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
1 change: 0 additions & 1 deletion .github/actions/e2e-knative-yaks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
1 change: 0 additions & 1 deletion .github/actions/e2e-knative/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
1 change: 0 additions & 1 deletion .github/actions/e2e-upgrade/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions .github/actions/kamel-build-binary/build-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"

#
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/kamel-build-bundle/build-index-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions .github/actions/kamel-config-cluster-ocp3/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 11 additions & 6 deletions .github/actions/kamel-config-cluster/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/kamel-install-knative/install-knative.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/kamel-install-yaks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 29 additions & 15 deletions .github/actions/kamel-prepare-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

name: builder

env:
TEST_CLUSTER: kind

on:
pull_request:
branches:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

name: common

env:
TEST_CLUSTER: kind

on:
pull_request:
branches:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

name: install

env:
TEST_CLUSTER: kind

on:
pull_request:
branches:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/knative.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

name: knative

env:
TEST_CLUSTER: kind

on:
pull_request:
branches:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
# limitations under the License.
name: release

env:
TEST_CLUSTER: kind

on:
schedule:
- cron: "10 23 * * *"
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

name: upgrade

env:
TEST_CLUSTER: kind

on:
pull_request:
branches:
Expand Down
1 change: 0 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
[submodule ".github/actions/changelog"]
path = .github/actions/changelog
url = https://github.com/CharMixer/auto-changelog-action

0 comments on commit e3958ef

Please sign in to comment.