Skip to content

Commit

Permalink
check non terminating samples
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Valdron <[email protected]>
  • Loading branch information
michael-valdron committed May 23, 2024
1 parent a4ac51c commit 0c6827c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/validate-samples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 31 additions & 2 deletions tests/check_non_terminating.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0c6827c

Please sign in to comment.