Skip to content

Commit c198109

Browse files
validate if codeflare-sdk version exists
1 parent 8328a14 commit c198109

File tree

2 files changed

+52
-40
lines changed

2 files changed

+52
-40
lines changed

.github/workflows/odh-notebooks-sync.yml

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -51,45 +51,61 @@ jobs:
5151
3.8
5252
3.9
5353
54-
- name: Install pipenv
55-
run: pip install pipenv
54+
- name: Install pipenv and pip-versions
55+
run: pip install pipenv pip-versions
5656

5757
- name: Update Pipfiles in accordance with Codeflare-SDK latest release
5858
run: |
59-
# list all Pipfile paths having Codeflare-SDK listed
60-
paths+=($(grep -rl 'codeflare-sdk = "~=.*"'))
61-
# Extracting only directories from file paths, excluding a `.gitworkflow` directory
62-
directories=()
63-
exclude_directories=(
64-
".git/objects/pack"
65-
".github/workflows/",
66-
)
67-
for path in "${paths[@]}"; do
68-
current_dir=$(dirname "$path")
69-
#Check if current_dir is not in exclude_directories list
70-
if [[ ! "${exclude_directories[@]}" =~ "$current_dir" ]]; then
71-
#Check if Pipfile exists in current_dir
72-
if [ -f "$current_dir/Pipfile" ];then
73-
directories+=("$current_dir")
59+
package_name=codeflare-sdk
60+
# Get the list of available versions for the package
61+
if ! versions=$(pipenv run pip-versions list $package_name);then
62+
echo "Failed to retrieve versions for $package_name"
63+
exit 1
64+
fi
65+
# Check if the desired version exists in the list
66+
if echo "$versions" | grep -q "${CODEFLARE_RELEASE_VERSION}"; then
67+
echo "Version ${CODEFLARE_RELEASE_VERSION} is available for $package_name"
68+
# list all Pipfile paths having Codeflare-SDK listed
69+
paths+=($(grep -rl "${package_name} = \"~=.*\""))
70+
# Extracting only directories from file paths, excluding a `.gitworkflow` directory
71+
directories=()
72+
exclude_directories=(
73+
".git/objects/pack"
74+
".github/workflows/",
75+
)
76+
for path in "${paths[@]}"; do
77+
current_dir=$(dirname "$path")
78+
#Check if current_dir is not in exclude_directories list
79+
if [[ ! "${exclude_directories[@]}" =~ "$current_dir" ]]; then
80+
#Check if Pipfile exists in current_dir
81+
if [ -f "$current_dir/Pipfile" ];then
82+
directories+=("$current_dir")
83+
fi
7484
fi
75-
fi
76-
done
77-
# Remove duplicates
78-
directories=($(echo "${directories[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
79-
# Print the directories for verification
80-
echo "Directories (Start updating Pipfile in these below directories in accordance with Codeflare-SDK latest release):"
81-
for dir in "${directories[@]}"; do
82-
echo "- $dir"
83-
done
84-
# iterate over the directories and update Pipfile
85-
counter=0
86-
total=${#directories[@]}
87-
for dir in "${directories[@]}"; do
88-
counter=$((counter+1))
89-
echo "--Processing directory $counter '$dir' of total $total"
90-
cd "$dir" && pipenv install codeflare-sdk~="${CODEFLARE_RELEASE_VERSION}" && pipenv --rm && cd -
91-
echo "$((total-counter)) directories remaining.."
92-
done
85+
done
86+
# Remove duplicates
87+
directories=($(echo "${directories[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
88+
# Print the directories for verification
89+
echo "Directories (Start updating Pipfile in these below directories in accordance with Codeflare-SDK latest release):"
90+
for dir in "${directories[@]}"; do
91+
echo "- $dir"
92+
done
93+
# iterate over the directories and update Pipfile
94+
counter=0
95+
total=${#directories[@]}
96+
for dir in "${directories[@]}"; do
97+
counter=$((counter+1))
98+
echo "--Processing directory $counter '$dir' of total $total"
99+
cd "$dir" && pipenv install ${package_name}~="${CODEFLARE_RELEASE_VERSION}" && pipenv --rm && cd -
100+
echo "$((total-counter)) directories remaining.."
101+
done
102+
else
103+
versions_list=$(echo "$versions" | tr '\n' ' ' | sed 's/, $//')
104+
versions="${versions_list%,}"
105+
echo "Version '${CODEFLARE_RELEASE_VERSION}' is not available for $package_name"
106+
echo "Available versions for $package_name: $versions"
107+
exit 1
108+
fi
93109
94110
- name: Push changes
95111
run: |

.github/workflows/project-codeflare-release.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ on:
3838
description: 'Owner of target community-operators-prod repository used to open a PR against'
3939
required: true
4040
default: 'redhat-openshift-ecosystem'
41-
upstream-repository-organization:
42-
description: 'Owner of target upstream notebooks repository used to open a PR against'
43-
required: false
44-
default: 'opendatahub-io'
4541

4642
jobs:
4743
release-parameters:
@@ -161,7 +157,7 @@ jobs:
161157
gh workflow run odh-notebooks-sync.yml \
162158
--repo ${{ github.event.inputs.codeflare-repository-organization }}/codeflare-operator \
163159
--ref ${{ github.ref }} \
164-
--field upstream-repository-organization=${{ github.event.inputs.upstream-repository-organization }}
160+
--field upstream-repository-organization=opendatahub-io
165161
--field codeflare-repository-organization=${{ github.event.inputs.codeflare-repository-organization }} \
166162
--field codeflare_sdk_release_version=${{ github.event.inputs.codeflare-sdk-version }}
167163
env:

0 commit comments

Comments
 (0)