From 0c6827c77f8792161c05203d14d68d8c693b6f2d Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Thu, 23 May 2024 18:10:22 -0400 Subject: [PATCH] check non terminating samples Signed-off-by: Michael Valdron --- .github/workflows/validate-samples.yaml | 33 +++++++++++++++++++++++++ tests/check_non_terminating.sh | 33 +++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-samples.yaml b/.github/workflows/validate-samples.yaml index 6787940e5..be3e54683 100644 --- a/.github/workflows/validate-samples.yaml +++ b/.github/workflows/validate-samples.yaml @@ -65,3 +65,36 @@ jobs: - name: Validate samples if: ${{ env.STACKS != '' }} run: STACKS_DIR=$(pwd)/samples/.cache bash tests/validate_devfile_schemas.sh --samples + + non-terminating: + name: check for non-terminating images + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + with: + fetch-depth: 0 + + - name: Install yq + run: curl -sL -O https://github.com/mikefarah/yq/releases/download/${{ env.YQ_VERSION }}/yq_linux_amd64 -o /usr/local/bin/yq && mv ./yq_linux_amd64 /usr/local/bin/yq && chmod +x /usr/local/bin/yq + + - name: Test delta if on a pull request + if: ${{ github.event_name == 'pull_request' }} + run: echo "TEST_DELTA=true" >> $GITHUB_ENV + + - name: Build parents file and get child samples + run: echo "STACKS=$(bash tests/build_parents_file.sh)" >> $GITHUB_ENV + + - name: Setup Minikube + if: ${{ env.STACKS != '' }} + uses: manusa/actions-setup-minikube@92af4db914ab207f837251cd53eb7060e6477614 # v2.11.0 + with: + minikube version: ${{ env.MINIKUBE_VERSION }} + kubernetes version: ${{ env.KUBERNETES_VERSION }} + driver: "docker" + github token: ${{ secrets.GITHUB_TOKEN }} + start args: "--addons=ingress ${{ env.MINIKUBE_RESOURCES }}" + + - name: Check that containers components are non terminating + if: ${{ env.STACKS != '' }} + run: STACKS_DIR=$(pwd)/samples/.cache bash tests/check_non_terminating.sh --samples diff --git a/tests/check_non_terminating.sh b/tests/check_non_terminating.sh index a82303eb6..4673b19e8 100755 --- a/tests/check_non_terminating.sh +++ b/tests/check_non_terminating.sh @@ -1,11 +1,33 @@ #!/bin/bash + +POSITIONAL_ARGS=() +SAMPLES="false" + +while [[ $# -gt 0 ]]; do + case $1 in + -s|--samples) + SAMPLES="true" + shift # past argument + ;; + -*|--*) + echo "Unknown option $1" + exit 1 + ;; + *) + POSITIONAL_ARGS+=("$1") # save positional arg + shift # past argument + ;; + esac +done + +set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters set -o nounset set -o errexit -DEVFILES_DIR="$(pwd)/stacks" +DEVFILES_DIR=${STACKS_DIR:-"$(pwd)/stacks"} # The stacks to test as a string separated by spaces -STACKS=$(bash "$(pwd)/tests/get_stacks.sh") +STACKS=${STACKS:-"$(bash "$(pwd)/tests/get_stacks.sh")"} replaceVariables() { image=$1 @@ -124,6 +146,13 @@ isNonTerminating() { YQ_PATH=${YQ_PATH:-yq} TEST_NAMESPACE=${TEST_NAMESPACE:-default} +# Unzip resource files if samples +if [ "${SAMPLES}" == "true" ]; then + for sample_dir in $(ls $DEVFILES_DIR); do + unzip -n $DEVFILES_DIR/$sample_dir/sampleName.zip -d $DEVFILES_DIR + done +fi + if [ -z "${ENV:-}" ]; then ENV=minikube fi