From 079a01bb0b1571dcc95f4a31d41d2d3228e5e5b7 Mon Sep 17 00:00:00 2001 From: Lucas Yoon Date: Fri, 25 Jul 2025 12:18:40 -0400 Subject: [PATCH 1/4] devfile#1721, add test cases & renovate setup Signed-off-by: Lucas Yoon --- .github/workflows/ci.yaml | 28 +++ .github/workflows/validate-with-registry.yaml | 88 ++++++++ renovate.json | 18 ++ tests/README.md | 5 + tests/check_non_terminating.sh | 211 ++++++++++++++++++ tests/check_odov3.sh | 38 ++++ tests/validate_devfile_schemas.sh | 67 ++++++ 7 files changed, 455 insertions(+) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/validate-with-registry.yaml create mode 100644 renovate.json create mode 100644 tests/README.md create mode 100644 tests/check_non_terminating.sh create mode 100644 tests/check_odov3.sh create mode 100644 tests/validate_devfile_schemas.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..3b58e61c --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,28 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... diff --git a/.github/workflows/validate-with-registry.yaml b/.github/workflows/validate-with-registry.yaml new file mode 100644 index 00000000..f286c8e9 --- /dev/null +++ b/.github/workflows/validate-with-registry.yaml @@ -0,0 +1,88 @@ +name: Validate with Devfile Registry Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} + cancel-in-progress: true + +env: + MINIKUBE_VERSION: 'v1.29.0' + MINIKUBE_RESOURCES: '--memory 14gb --cpus 4' + KUBERNETES_VERSION: 'v1.25.2' + TEST_DELTA: false + REGISTRY_PATH: ${{ github.workspace }}/registry + GO_VERSION: '1.23' + GINKGO_VERSION: v2.19.0 + YQ_VERSION: v4.44.1 + +jobs: + validate-devfile-schema: + name: validate devfile schemas + runs-on: ubuntu-latest + steps: + - name: Checkout current repo + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + path: current-repo + + - name: Checkout devfile registry + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + repository: devfile/registry + path: ${{ env.REGISTRY_PATH }} + + - name: Setup Go + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + with: + go-version: ${{ env.GO_VERSION }} + + - 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: Install Ginkgo + run: go install github.com/onsi/ginkgo/v2/ginkgo@${{ env.GINKGO_VERSION }} + + - name: Validate sample + run: (cd ${{ env.REGISTRY_PATH }} && bash tests/validate_devfile_schemas.sh --stacksPath ${{ github.workspace }} --stackDirs current-repo) + + non-terminating: + name: check for non-terminating images + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + path: current-repo + fetch-depth: 0 + + - name: Checkout devfile registry + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + repository: devfile/registry + path: ${{ env.REGISTRY_PATH }} + + - name: Setup Go + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Setup Minikube + uses: manusa/actions-setup-minikube@0e8062ceff873bd77979f39cf8fd3621416afe4d # v2.13.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 + run: | + go build -C ${{ env.REGISTRY_PATH }}/tests/check_non_terminating -o flatten-parent + (cd ${{ env.REGISTRY_PATH }} && bash ${{ env.REGISTRY_PATH }}/tests/check_non_terminating.sh --stacksPath ${{ github.workspace }} --stackDirs current-repo) diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..499b218d --- /dev/null +++ b/renovate.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "enabledManagers": ["gomod"], + "gomod": { + "fileMatch": ["go\\.mod$", "go\\.sum$"] + }, + "packageRules": [ + { + "matchManagers": ["gomod"], + "groupName": "go dependencies", + "groupSlug": "go-deps", + "commitMessageTopic": "Go {{depName}}" + } + ], + "vulnerabilityAlerts": { + "enabled": true + } +} \ No newline at end of file diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 00000000..03c6e350 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,5 @@ +# Test Scripts + +These test scripts are adapted from the [devfile/registry](https://github.com/devfile/registry) repository. + +Our CI workflow clones the registry repository and uses their test infrastructure, with the ability to override any test scripts by placing them in this directory. \ No newline at end of file diff --git a/tests/check_non_terminating.sh b/tests/check_non_terminating.sh new file mode 100644 index 00000000..161c9205 --- /dev/null +++ b/tests/check_non_terminating.sh @@ -0,0 +1,211 @@ +#!/bin/bash +set -o nounset +set -o errexit + +DEVFILE_PATH=${DEVFILE_PATH:-"$(pwd)/devfile.yaml"} + +REGISTRY_PATH=${REGISTRY_PATH:-"../registry"} + +BIN_NAME=${BIN_NAME:-"flatten-parent"} +NON_TERMINATING_MODULE_BIN="${REGISTRY_PATH}/tests/check_non_terminating/$BIN_NAME" + +replaceVariables() { + image=$1 + VAR_KEYS=(liberty-version) + VAR_VALUES=(22.0.0.1) + + for i in "${!VAR_KEYS[@]}"; do + key='{{' + key+=${VAR_KEYS[i]} + key+='}}' + value=${VAR_VALUES[i]} + image=${image/${key}/${value}} + done + echo "$image" +} + +getContainerComponentsNum() { + devfilePath=$1 + component_num=$($YQ_PATH eval '[ .components[] | select(has("container")) ] | length' "$devfilePath" -r) + echo "${component_num}" +} + +getName() { + devfilePath=$1 + name=$($YQ_PATH eval '.metadata.name' "$devfilePath" -r) + echo "${name}" +} + +getFirstContainerComponentImage() { + devfilePath=$1 + + image_original=$($YQ_PATH eval '[ .components[] | select(has("container")) ] | .[0].container.image' "$devfilePath" -r) + image_processed=$(replaceVariables "${image_original}") + echo "${image_processed}" +} + +getFirstContainerComponentCommand() { + devfilePath=$1 + local _gfccc_command=() + local _gfccc_command_string=() + + IFS=" " read -r -a _gfccc_command_string <<<"$($YQ_PATH eval '[ .components[] | select(has("container")) ] | .[0].container.command[]? + " "' "$devfilePath" -r | paste -s -d '\0' -)" + if ((${#_gfccc_command_string[@]} == 0)); then + echo "" + else + for command_word in "${_gfccc_command_string[@]}"; do + _gfccc_command+=("${command_word}") + done + echo "${_gfccc_command[@]}" + fi +} + +getFirstContainerComponentArgs() { + devfilePath=$1 + local _gfcca_args=() + local _gfcca_args_string=() + + IFS=" " read -r -a _gfcca_args_string <<<"$($YQ_PATH eval '[ .components[] | select(has("container")) ] | .[0].container.args[]? + " "' "$devfilePath" -r | paste -s -d '\0' -)" + if ((${#_gfcca_args_string[@]} == 0)); then + echo "" + else + for arg in "${_gfcca_args_string[@]}"; do + _gfcca_args+=("${arg}") + done + echo "${_gfcca_args[@]}" + fi +} + +isNonTerminating() { + _int_image=$1 + _int_command=("$2") + _int_command_args=("$3") + + timeout_in_sec=240 # <== includes image pulling + + # workaround: cri-dockerd v0.2.6+ fixes a timeout issue where large images are not being pulled + # this can be removed when actions-setup-minikube updates cri-dockerd + if [ "$ENV" = "minikube" ]; then + echo " COMMAND: minikube ssh docker pull $_int_image" + minikube ssh docker pull $_int_image >/dev/null 2>&1 + fi + + echo " PARAMS: image --> $_int_image, command --> ${_int_command[*]}, args --> ${_int_command_args[*]}" + + if [ "${_int_command[*]}" == "null" ] && [ "${_int_command_args[*]}" == "null" ]; then + echo " COMMAND: \"kubectl run test-terminating -n ${TEST_NAMESPACE} --attach=false --restart=Never --image=$_int_image\"" + kubectl run test-terminating -n "${TEST_NAMESPACE}" --attach=false --restart=Never --image="$_int_image" >/dev/null 2>&1 + elif [ "${_int_command[*]}" == "null" ]; then + echo " COMMAND: \"kubectl run test-terminating -n ${TEST_NAMESPACE} --attach=false --restart=Never --image=$_int_image -- ${_int_command_args[*]}\"" + kubectl run test-terminating -n "${TEST_NAMESPACE}" --attach=false --restart=Never --image="$_int_image" -- ${_int_command_args[*]} >/dev/null 2>&1 + elif [ "${_int_command_args[*]}" == "null" ]; then + echo " COMMAND: \"kubectl run test-terminating -n ${TEST_NAMESPACE} --attach=false --restart=Never --image=$_int_image --command -- ${_int_command[*]}\"" + kubectl run test-terminating -n "${TEST_NAMESPACE}" --attach=false --restart=Never --image="$_int_image" --command=true -- ${_int_command[*]} >/dev/null 2>&1 + else + echo " COMMAND: \"kubectl run test-terminating -n ${TEST_NAMESPACE} --attach=false --restart=Never --image=$_int_image --command -- ${_int_command[*]} ${_int_command_args[*]}\"" + kubectl run test-terminating -n "${TEST_NAMESPACE}" --attach=false --restart=Never --image="$_int_image" --command=true -- ${_int_command[*]} ${_int_command_args[*]} >/dev/null 2>&1 + fi + + if kubectl wait pods -n "${TEST_NAMESPACE}" test-terminating --for condition=Ready --timeout=${timeout_in_sec}s >/dev/null 2>&1; then + echo " SUCCESS: The container started successfully and didn't terminate" + kubectl delete pod test-terminating -n "${TEST_NAMESPACE}" >/dev/null 2>&1 + + return 0 + else + echo " ERROR: Failed to reach \"Ready\" condition after $timeout_in_sec seconds" + echo " ↓↓↓↓↓↓↓↓↓ Pod description ↓↓↓↓↓↓↓↓" + echo "" + kubectl describe pod -n "${TEST_NAMESPACE}" test-terminating + echo "" + echo " ↑↑↑↑↑↑↑↑↑ Pod description ↑↑↑↑↑↑↑↑" + kubectl delete pod test-terminating -n "${TEST_NAMESPACE}" >/dev/null 2>&1 + return 1 + fi +} + +YQ_PATH=${YQ_PATH:-yq} +TEST_NAMESPACE=${TEST_NAMESPACE:-default} + +if [ -z "${ENV:-}" ]; then + ENV=minikube +fi + +if [ "$ENV" != "minikube" ] && [ "$ENV" != "openshift" ]; then + echo "ERROR:: Allowed values for ENV are either \"minikube\" (default) or \"openshift\"." + exit 1 +fi + +if [ ! -f "$NON_TERMINATING_MODULE_BIN" ]; then + echo "ERROR: Go binary not found at $NON_TERMINATING_MODULE_BIN" + echo "Please ensure the devfile/registry repository is cloned and the binary is built." + exit 1 +fi + +if [ ! -f "$DEVFILE_PATH" ]; then + echo "ERROR: Devfile not found at path $DEVFILE_PATH" + exit 1 +fi + +echo "=======================" +echo "Testing single sample: ${DEVFILE_PATH}" + +# if devfile in path has a parent flatten it +if $YQ_PATH eval 'has("parent")' "$DEVFILE_PATH" -r | grep -q "true"; then + echo "INFO:: Found parent for $DEVFILE_PATH" + "$NON_TERMINATING_MODULE_BIN" "$DEVFILE_PATH" +fi + +IFS=" " read -r -a components_num <<<"$(getContainerComponentsNum "$DEVFILE_PATH")" + +# if there are zero components of type container skip +if ((components_num == 0)); then + echo "WARNING: Devfile with no container component found (""$DEVFILE_PATH""). Skipping." + echo "=======================" + exit 0 +fi + +# if there is more than one component of type container skip (we may want to cover this case in the future) +if ((components_num > 1)); then + echo "WARNING: Devfile with more than one container component found (""$DEVFILE_PATH""). Skipping." + echo "=======================" + exit 0 +fi + +name=$(getName "$DEVFILE_PATH") +image=$(getFirstContainerComponentImage "$DEVFILE_PATH") + +declare -a command=() +IFS=" " read -r -a command <<<"$(getFirstContainerComponentCommand "$DEVFILE_PATH")" + +declare -a command_args=() +IFS=" " read -r -a command_args <<<"$(getFirstContainerComponentArgs "$DEVFILE_PATH")" + +if ((${#command[@]} > 0)); then + command_string="${command[*]}" +else + command_string="null" +fi + +if ((${#command_args[@]} > 0)); then + command_args_string="${command_args[*]}" +else + command_args_string="null" +fi + +echo "Sample: $name" +echo "Image: $image" +echo "Command: $command_string" +echo "Args: $command_args_string" + +isNonTerminating "${image}" "${command_string}" "${command_args_string}" + +# remove image to save space +if [ "$ENV" = "minikube" ]; then + echo " COMMAND: \"minikube ssh -- docker image rm ${image} --force\"" + minikube ssh -- docker image rm ${image} --force >/dev/null 2>&1 +fi + +echo "=======================" +echo "Non-terminating test completed successfully!" + +exit 0 \ No newline at end of file diff --git a/tests/check_odov3.sh b/tests/check_odov3.sh new file mode 100644 index 00000000..e14dcd3b --- /dev/null +++ b/tests/check_odov3.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -x + +SAMPLE_PATH="$(pwd)" +DEVFILE_PATH=${DEVFILE_PATH:-"$SAMPLE_PATH/devfile.yaml"} + +REGISTRY_PATH=${REGISTRY_PATH:-"../registry"} + +args="" + +if [ ! -z "${1}" ]; then + args="-odoPath ${1} ${args}" +fi + +if [ ! -f "$DEVFILE_PATH" ]; then + echo "ERROR: Devfile not found at path $DEVFILE_PATH" + exit 1 +fi + +if [ ! -d "$REGISTRY_PATH/tests/odov3" ]; then + echo "ERROR: Registry test directory not found at $REGISTRY_PATH/tests/odov3" + echo "Please ensure the devfile/registry repository is cloned." + exit 1 +fi + +SAMPLE_NAME=$(yq eval '.metadata.name' "$DEVFILE_PATH") + +cd "$REGISTRY_PATH/tests/odov3" + +ginkgo run --procs 1 \ + --timeout 3h \ + --slow-spec-threshold 120s \ + . -- -stacksPath "$SAMPLE_PATH" -stackDirs "." ${args} + +echo "=======================" +echo "ODO v3 test completed!" +echo "=======================" \ No newline at end of file diff --git a/tests/validate_devfile_schemas.sh b/tests/validate_devfile_schemas.sh new file mode 100644 index 00000000..8b862245 --- /dev/null +++ b/tests/validate_devfile_schemas.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +set -x + +# Path to the devfile in this sample repository +SAMPLE_PATH="$(pwd)" +DEVFILE_PATH=${DEVFILE_PATH:-"$SAMPLE_PATH/devfile.yaml"} + + +# Path to the devfile/registry repository (assumed to be cloned as a sibling) +REGISTRY_PATH=${REGISTRY_PATH:-"../registry"} + +POSITIONAL_ARGS=() +SAMPLES="false" +VERBOSE="false" + +while [[ $# -gt 0 ]]; do + case $1 in + -s|--samples) + SAMPLES="true" + shift # past argument + ;; + -v|--verbose) + VERBOSE="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 + +# Check if devfile exists +if [ ! -f "$DEVFILE_PATH" ]; then + echo "ERROR: Devfile not found at path $DEVFILE_PATH" + exit 1 +fi + +# Check if the devfile/registry test directory exists +if [ ! -d "$REGISTRY_PATH/tests/validate_devfile_schemas" ]; then + echo "ERROR: Registry test directory not found at $REGISTRY_PATH/tests/validate_devfile_schemas" + echo "Please ensure the devfile/registry repository is cloned." + exit 1 +fi + +echo "=======================" +echo "Validating devfile schema for single sample: ${DEVFILE_PATH}" +echo "Registry path: ${REGISTRY_PATH}" +echo "=======================" + +# Change to the registry test directory and run the validation +cd "$REGISTRY_PATH/tests/validate_devfile_schemas" + +# Run the validation test with the single sample +ginkgo run --procs 1 \ + . -- -stacksPath "$SAMPLE_PATH" -stackDirs "." + +echo "=======================" +echo "Schema validation completed!" +echo "=======================" \ No newline at end of file From 615c3ff0bd5be500e1781e8a2e6c3f48c6093cf3 Mon Sep 17 00:00:00 2001 From: Lucas Yoon Date: Mon, 28 Jul 2025 11:47:59 -0400 Subject: [PATCH 2/4] Modifying contents after changes in devfile/registry Signed-off-by: Lucas Yoon --- .github/workflows/ci.yaml | 6 +- renovate.json | 8 +- tests/README.md | 5 - tests/check_non_terminating.sh | 211 ------------------------------ tests/check_odov3.sh | 38 ------ tests/validate_devfile_schemas.sh | 67 ---------- 6 files changed, 8 insertions(+), 327 deletions(-) delete mode 100644 tests/README.md delete mode 100644 tests/check_non_terminating.sh delete mode 100644 tests/check_odov3.sh delete mode 100644 tests/validate_devfile_schemas.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3b58e61c..022e0add 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,6 +9,10 @@ on: pull_request: branches: [ "main" ] +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} + cancel-in-progress: true + jobs: build: @@ -19,7 +23,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: "go.mod" - name: Build run: go build -v ./... diff --git a/renovate.json b/renovate.json index 499b218d..a8f9ec68 100644 --- a/renovate.json +++ b/renovate.json @@ -1,6 +1,7 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "enabledManagers": ["gomod"], + "extends": ["local>devfile-samples/.github:renovate-config"], + "enabledManagers": ["gomod", "dockerfile"], "gomod": { "fileMatch": ["go\\.mod$", "go\\.sum$"] }, @@ -11,8 +12,5 @@ "groupSlug": "go-deps", "commitMessageTopic": "Go {{depName}}" } - ], - "vulnerabilityAlerts": { - "enabled": true - } + ] } \ No newline at end of file diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index 03c6e350..00000000 --- a/tests/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Test Scripts - -These test scripts are adapted from the [devfile/registry](https://github.com/devfile/registry) repository. - -Our CI workflow clones the registry repository and uses their test infrastructure, with the ability to override any test scripts by placing them in this directory. \ No newline at end of file diff --git a/tests/check_non_terminating.sh b/tests/check_non_terminating.sh deleted file mode 100644 index 161c9205..00000000 --- a/tests/check_non_terminating.sh +++ /dev/null @@ -1,211 +0,0 @@ -#!/bin/bash -set -o nounset -set -o errexit - -DEVFILE_PATH=${DEVFILE_PATH:-"$(pwd)/devfile.yaml"} - -REGISTRY_PATH=${REGISTRY_PATH:-"../registry"} - -BIN_NAME=${BIN_NAME:-"flatten-parent"} -NON_TERMINATING_MODULE_BIN="${REGISTRY_PATH}/tests/check_non_terminating/$BIN_NAME" - -replaceVariables() { - image=$1 - VAR_KEYS=(liberty-version) - VAR_VALUES=(22.0.0.1) - - for i in "${!VAR_KEYS[@]}"; do - key='{{' - key+=${VAR_KEYS[i]} - key+='}}' - value=${VAR_VALUES[i]} - image=${image/${key}/${value}} - done - echo "$image" -} - -getContainerComponentsNum() { - devfilePath=$1 - component_num=$($YQ_PATH eval '[ .components[] | select(has("container")) ] | length' "$devfilePath" -r) - echo "${component_num}" -} - -getName() { - devfilePath=$1 - name=$($YQ_PATH eval '.metadata.name' "$devfilePath" -r) - echo "${name}" -} - -getFirstContainerComponentImage() { - devfilePath=$1 - - image_original=$($YQ_PATH eval '[ .components[] | select(has("container")) ] | .[0].container.image' "$devfilePath" -r) - image_processed=$(replaceVariables "${image_original}") - echo "${image_processed}" -} - -getFirstContainerComponentCommand() { - devfilePath=$1 - local _gfccc_command=() - local _gfccc_command_string=() - - IFS=" " read -r -a _gfccc_command_string <<<"$($YQ_PATH eval '[ .components[] | select(has("container")) ] | .[0].container.command[]? + " "' "$devfilePath" -r | paste -s -d '\0' -)" - if ((${#_gfccc_command_string[@]} == 0)); then - echo "" - else - for command_word in "${_gfccc_command_string[@]}"; do - _gfccc_command+=("${command_word}") - done - echo "${_gfccc_command[@]}" - fi -} - -getFirstContainerComponentArgs() { - devfilePath=$1 - local _gfcca_args=() - local _gfcca_args_string=() - - IFS=" " read -r -a _gfcca_args_string <<<"$($YQ_PATH eval '[ .components[] | select(has("container")) ] | .[0].container.args[]? + " "' "$devfilePath" -r | paste -s -d '\0' -)" - if ((${#_gfcca_args_string[@]} == 0)); then - echo "" - else - for arg in "${_gfcca_args_string[@]}"; do - _gfcca_args+=("${arg}") - done - echo "${_gfcca_args[@]}" - fi -} - -isNonTerminating() { - _int_image=$1 - _int_command=("$2") - _int_command_args=("$3") - - timeout_in_sec=240 # <== includes image pulling - - # workaround: cri-dockerd v0.2.6+ fixes a timeout issue where large images are not being pulled - # this can be removed when actions-setup-minikube updates cri-dockerd - if [ "$ENV" = "minikube" ]; then - echo " COMMAND: minikube ssh docker pull $_int_image" - minikube ssh docker pull $_int_image >/dev/null 2>&1 - fi - - echo " PARAMS: image --> $_int_image, command --> ${_int_command[*]}, args --> ${_int_command_args[*]}" - - if [ "${_int_command[*]}" == "null" ] && [ "${_int_command_args[*]}" == "null" ]; then - echo " COMMAND: \"kubectl run test-terminating -n ${TEST_NAMESPACE} --attach=false --restart=Never --image=$_int_image\"" - kubectl run test-terminating -n "${TEST_NAMESPACE}" --attach=false --restart=Never --image="$_int_image" >/dev/null 2>&1 - elif [ "${_int_command[*]}" == "null" ]; then - echo " COMMAND: \"kubectl run test-terminating -n ${TEST_NAMESPACE} --attach=false --restart=Never --image=$_int_image -- ${_int_command_args[*]}\"" - kubectl run test-terminating -n "${TEST_NAMESPACE}" --attach=false --restart=Never --image="$_int_image" -- ${_int_command_args[*]} >/dev/null 2>&1 - elif [ "${_int_command_args[*]}" == "null" ]; then - echo " COMMAND: \"kubectl run test-terminating -n ${TEST_NAMESPACE} --attach=false --restart=Never --image=$_int_image --command -- ${_int_command[*]}\"" - kubectl run test-terminating -n "${TEST_NAMESPACE}" --attach=false --restart=Never --image="$_int_image" --command=true -- ${_int_command[*]} >/dev/null 2>&1 - else - echo " COMMAND: \"kubectl run test-terminating -n ${TEST_NAMESPACE} --attach=false --restart=Never --image=$_int_image --command -- ${_int_command[*]} ${_int_command_args[*]}\"" - kubectl run test-terminating -n "${TEST_NAMESPACE}" --attach=false --restart=Never --image="$_int_image" --command=true -- ${_int_command[*]} ${_int_command_args[*]} >/dev/null 2>&1 - fi - - if kubectl wait pods -n "${TEST_NAMESPACE}" test-terminating --for condition=Ready --timeout=${timeout_in_sec}s >/dev/null 2>&1; then - echo " SUCCESS: The container started successfully and didn't terminate" - kubectl delete pod test-terminating -n "${TEST_NAMESPACE}" >/dev/null 2>&1 - - return 0 - else - echo " ERROR: Failed to reach \"Ready\" condition after $timeout_in_sec seconds" - echo " ↓↓↓↓↓↓↓↓↓ Pod description ↓↓↓↓↓↓↓↓" - echo "" - kubectl describe pod -n "${TEST_NAMESPACE}" test-terminating - echo "" - echo " ↑↑↑↑↑↑↑↑↑ Pod description ↑↑↑↑↑↑↑↑" - kubectl delete pod test-terminating -n "${TEST_NAMESPACE}" >/dev/null 2>&1 - return 1 - fi -} - -YQ_PATH=${YQ_PATH:-yq} -TEST_NAMESPACE=${TEST_NAMESPACE:-default} - -if [ -z "${ENV:-}" ]; then - ENV=minikube -fi - -if [ "$ENV" != "minikube" ] && [ "$ENV" != "openshift" ]; then - echo "ERROR:: Allowed values for ENV are either \"minikube\" (default) or \"openshift\"." - exit 1 -fi - -if [ ! -f "$NON_TERMINATING_MODULE_BIN" ]; then - echo "ERROR: Go binary not found at $NON_TERMINATING_MODULE_BIN" - echo "Please ensure the devfile/registry repository is cloned and the binary is built." - exit 1 -fi - -if [ ! -f "$DEVFILE_PATH" ]; then - echo "ERROR: Devfile not found at path $DEVFILE_PATH" - exit 1 -fi - -echo "=======================" -echo "Testing single sample: ${DEVFILE_PATH}" - -# if devfile in path has a parent flatten it -if $YQ_PATH eval 'has("parent")' "$DEVFILE_PATH" -r | grep -q "true"; then - echo "INFO:: Found parent for $DEVFILE_PATH" - "$NON_TERMINATING_MODULE_BIN" "$DEVFILE_PATH" -fi - -IFS=" " read -r -a components_num <<<"$(getContainerComponentsNum "$DEVFILE_PATH")" - -# if there are zero components of type container skip -if ((components_num == 0)); then - echo "WARNING: Devfile with no container component found (""$DEVFILE_PATH""). Skipping." - echo "=======================" - exit 0 -fi - -# if there is more than one component of type container skip (we may want to cover this case in the future) -if ((components_num > 1)); then - echo "WARNING: Devfile with more than one container component found (""$DEVFILE_PATH""). Skipping." - echo "=======================" - exit 0 -fi - -name=$(getName "$DEVFILE_PATH") -image=$(getFirstContainerComponentImage "$DEVFILE_PATH") - -declare -a command=() -IFS=" " read -r -a command <<<"$(getFirstContainerComponentCommand "$DEVFILE_PATH")" - -declare -a command_args=() -IFS=" " read -r -a command_args <<<"$(getFirstContainerComponentArgs "$DEVFILE_PATH")" - -if ((${#command[@]} > 0)); then - command_string="${command[*]}" -else - command_string="null" -fi - -if ((${#command_args[@]} > 0)); then - command_args_string="${command_args[*]}" -else - command_args_string="null" -fi - -echo "Sample: $name" -echo "Image: $image" -echo "Command: $command_string" -echo "Args: $command_args_string" - -isNonTerminating "${image}" "${command_string}" "${command_args_string}" - -# remove image to save space -if [ "$ENV" = "minikube" ]; then - echo " COMMAND: \"minikube ssh -- docker image rm ${image} --force\"" - minikube ssh -- docker image rm ${image} --force >/dev/null 2>&1 -fi - -echo "=======================" -echo "Non-terminating test completed successfully!" - -exit 0 \ No newline at end of file diff --git a/tests/check_odov3.sh b/tests/check_odov3.sh deleted file mode 100644 index e14dcd3b..00000000 --- a/tests/check_odov3.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -set -x - -SAMPLE_PATH="$(pwd)" -DEVFILE_PATH=${DEVFILE_PATH:-"$SAMPLE_PATH/devfile.yaml"} - -REGISTRY_PATH=${REGISTRY_PATH:-"../registry"} - -args="" - -if [ ! -z "${1}" ]; then - args="-odoPath ${1} ${args}" -fi - -if [ ! -f "$DEVFILE_PATH" ]; then - echo "ERROR: Devfile not found at path $DEVFILE_PATH" - exit 1 -fi - -if [ ! -d "$REGISTRY_PATH/tests/odov3" ]; then - echo "ERROR: Registry test directory not found at $REGISTRY_PATH/tests/odov3" - echo "Please ensure the devfile/registry repository is cloned." - exit 1 -fi - -SAMPLE_NAME=$(yq eval '.metadata.name' "$DEVFILE_PATH") - -cd "$REGISTRY_PATH/tests/odov3" - -ginkgo run --procs 1 \ - --timeout 3h \ - --slow-spec-threshold 120s \ - . -- -stacksPath "$SAMPLE_PATH" -stackDirs "." ${args} - -echo "=======================" -echo "ODO v3 test completed!" -echo "=======================" \ No newline at end of file diff --git a/tests/validate_devfile_schemas.sh b/tests/validate_devfile_schemas.sh deleted file mode 100644 index 8b862245..00000000 --- a/tests/validate_devfile_schemas.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -set -x - -# Path to the devfile in this sample repository -SAMPLE_PATH="$(pwd)" -DEVFILE_PATH=${DEVFILE_PATH:-"$SAMPLE_PATH/devfile.yaml"} - - -# Path to the devfile/registry repository (assumed to be cloned as a sibling) -REGISTRY_PATH=${REGISTRY_PATH:-"../registry"} - -POSITIONAL_ARGS=() -SAMPLES="false" -VERBOSE="false" - -while [[ $# -gt 0 ]]; do - case $1 in - -s|--samples) - SAMPLES="true" - shift # past argument - ;; - -v|--verbose) - VERBOSE="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 - -# Check if devfile exists -if [ ! -f "$DEVFILE_PATH" ]; then - echo "ERROR: Devfile not found at path $DEVFILE_PATH" - exit 1 -fi - -# Check if the devfile/registry test directory exists -if [ ! -d "$REGISTRY_PATH/tests/validate_devfile_schemas" ]; then - echo "ERROR: Registry test directory not found at $REGISTRY_PATH/tests/validate_devfile_schemas" - echo "Please ensure the devfile/registry repository is cloned." - exit 1 -fi - -echo "=======================" -echo "Validating devfile schema for single sample: ${DEVFILE_PATH}" -echo "Registry path: ${REGISTRY_PATH}" -echo "=======================" - -# Change to the registry test directory and run the validation -cd "$REGISTRY_PATH/tests/validate_devfile_schemas" - -# Run the validation test with the single sample -ginkgo run --procs 1 \ - . -- -stacksPath "$SAMPLE_PATH" -stackDirs "." - -echo "=======================" -echo "Schema validation completed!" -echo "=======================" \ No newline at end of file From abadc4101088b2abf8197a59821047fac13b19fa Mon Sep 17 00:00:00 2001 From: Lucas Yoon <94267691+JslYoon@users.noreply.github.com> Date: Mon, 28 Jul 2025 13:27:12 -0400 Subject: [PATCH 3/4] Update .github/workflows/ci.yaml Co-authored-by: Michael Valdron --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 022e0add..4313f501 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: "go.mod" + go-version-file: "go.mod" - name: Build run: go build -v ./... From 6006b697430c2f882f3d69de6623f3f64921bef7 Mon Sep 17 00:00:00 2001 From: Lucas Yoon <94267691+JslYoon@users.noreply.github.com> Date: Tue, 29 Jul 2025 13:56:45 -0400 Subject: [PATCH 4/4] Update renovate.json Co-authored-by: Michael Valdron --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/renovate.json b/renovate.json index a8f9ec68..07e373cf 100644 --- a/renovate.json +++ b/renovate.json @@ -11,6 +11,12 @@ "groupName": "go dependencies", "groupSlug": "go-deps", "commitMessageTopic": "Go {{depName}}" + }, + { + "matchManagers": ["dockerfile"], + "groupName": "dockerfile dependencies", + "groupSlug": "dockerfile-deps", + "commitMessageTopic": "Dockerfile {{depName}}" } ] } \ No newline at end of file