Skip to content

Commit

Permalink
Include test suite execution on top of minikube (#6)
Browse files Browse the repository at this point in the history
Resolves: #5

Signed-off-by: Sergio Arroutbi <[email protected]>
  • Loading branch information
sarroutbi authored Oct 4, 2023
1 parent a6a1658 commit 26750cc
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/run_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: "Test Execution"

on:
push:
branches: [main]
paths-ignore:
- '**.md'
- '.wordlist.txt'
pull_request:
paths-ignore:
- '**.md'
- '.wordlist.txt'
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@vmaster

- name: Minikube Installation
id: minikube
uses: medyagh/setup-minikube@latest

- name: Status
run: minikube status

- name: Install operator-sdk
run: |
sh .github/workflows/scripts/retrieve_and_install_operator_sdk.sh \
"v1.31.0" "5m" "${GITHUB_HEAD_REF}"
- name: Install dependencies (kubectl, helm, clamscan, make)
run: |
sh .github/workflows/scripts/install_dependencies.sh
- name: Run test
run: |
tree; make
49 changes: 49 additions & 0 deletions .github/workflows/scripts/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh -ex
#
# MIT License
#
# Copyright (c) 2023 Sergio Arroutbi
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
COMMON="git file tree make"

case "${DISTRO}" in
debian:*|ubuntu:*)
export DEBIAN_FRONTEND=noninteractive
apt clean
apt update
# We get some errors once in a while, so let's try a few times.
for i in 1 2 3; do
apt -y install ${COMMON} ${DEBIAN_UBUNTU} && break
sleep 1
done
;;
fedora:*|*centos:*)
echo 'max_parallel_downloads=10' >> /etc/dnf/dnf.conf
dnf -y clean all
dnf -y --setopt=deltarpm=0 update
dnf -y install ${COMMON} ${FEDORA_CENTOS}
;;
esac

echo "================= SYSTEM ================="
cat /etc/os-release
uname -a
echo "=========================================="
78 changes: 78 additions & 0 deletions .github/workflows/scripts/retrieve_and_install_operator_sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash
# Copyright 2021.
#
# Licensed 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.
#
set -x -e

OPERATOR_SDK_DEFAULT_RELEASE_VERSION="v1.31.0"
DEFAULT_TIMEOUT="5m"
DEFAULT_GITHUB_BRANCH="main"

OPERATOR_SDK_RELEASE_VERSION="${1}"
TIMEOUT="${2}"
GITHUB_REF="${3}"
GITHUB_BRANCH="${3##*/}"

test -z "${GITHUB_BRANCH}" && GITHUB_BRANCH="main"
ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n "$(uname -m)" ;; esac)
OS=$(uname | awk '{print tolower($0)}')

dump_info() {
cat << EOF
==================$0 INFO ===================
OPERATOR_SDK_RELEASE_VERSION="${OPERATOR_SDK_RELEASE_VERSION}"
TIMEOUT="${TIMEOUT}"
GITHUB_SHA="${GITHUB_SHA}"
GITHUB_REF="${GITHUB_REF}"
GITHUB_BRANCH="${GITHUB_BRANCH}"
ARCH=${ARCH}
OS=${OS}
==================$0 INFO ===================
EOF
}

if [ -z "${OPERATOR_SDK_RELEASE_VERSION}" ]; then
echo "INFO: operator-sdk release version is not set. Setting default version:${OPERATOR_SDK_DEFAULT_RELEASE_VERSION}"
OPERATOR_SDK_RELEASE_VERSION="${OPERATOR_SDK_DEFAULT_RELEASE_VERSION}"
fi

OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_RELEASE_VERSION}

if [ -z "${TIMEOUT}" ]; then
echo "INFO: using default timeout: ${DEFAULT_TIMEOUT}"
TIMEOUT="${DEFAULT_TIMEOUT}"
fi

if [ -z "${BUNDLE_IMG}" ]; then
echo "INFO: using default bundle image: ${DEFAULT_BUNDLE_IMG}"
BUNDLE_IMG="${DEFAULT_BUNDLE_IMG}"
fi

if [ -z "${GITHUB_BRANCH}" ]; then
echo "INFO: using default github branch: ${DEFAULT_GITHUB_BRANCH}"
GITHUB_BRANCH=${DEFAULT_GITHUB_BRANCH}
fi

dump_info

curl -L -o "operator-sdk_${OS}_${ARCH}" -L "${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}"
gpg --keyserver keyserver.ubuntu.com --recv-keys 052996E2A20B5C7E
curl -LO "${OPERATOR_SDK_DL_URL}"/checksums.txt
curl -LO "${OPERATOR_SDK_DL_URL}"/checksums.txt.asc
gpg -u "Operator SDK (release) <[email protected]>" --verify checksums.txt.asc
grep "operator-sdk_${OS}_${ARCH}" checksums.txt | sha256sum -c -

mv "operator-sdk_${OS}_${ARCH}" "$(pwd)/operator-sdk"
chmod +x "$(pwd)/operator-sdk"
"$(pwd)"/operator-sdk olm install --timeout "${TIMEOUT}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*~

0 comments on commit 26750cc

Please sign in to comment.