Skip to content

Commit a89148e

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

File tree

2 files changed

+49
-40
lines changed

2 files changed

+49
-40
lines changed

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

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -51,45 +51,58 @@ 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+
versions=$(pipenv run pip-versions list $package_name)
62+
# Check if the desired version exists in the list
63+
if echo "$versions" | grep -q "${CODEFLARE_RELEASE_VERSION}"; then
64+
echo "Version ${CODEFLARE_RELEASE_VERSION} is available for $package_name"
65+
# list all Pipfile paths having Codeflare-SDK listed
66+
paths+=($(grep -rl "${package_name} = \"~=.*\""))
67+
# Extracting only directories from file paths, excluding a `.gitworkflow` directory
68+
directories=()
69+
exclude_directories=(
70+
".git/objects/pack"
71+
".github/workflows/",
72+
)
73+
for path in "${paths[@]}"; do
74+
current_dir=$(dirname "$path")
75+
#Check if current_dir is not in exclude_directories list
76+
if [[ ! "${exclude_directories[@]}" =~ "$current_dir" ]]; then
77+
#Check if Pipfile exists in current_dir
78+
if [ -f "$current_dir/Pipfile" ];then
79+
directories+=("$current_dir")
80+
fi
7481
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
82+
done
83+
# Remove duplicates
84+
directories=($(echo "${directories[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
85+
# Print the directories for verification
86+
echo "Directories (Start updating Pipfile in these below directories in accordance with Codeflare-SDK latest release):"
87+
for dir in "${directories[@]}"; do
88+
echo "- $dir"
89+
done
90+
# iterate over the directories and update Pipfile
91+
counter=0
92+
total=${#directories[@]}
93+
for dir in "${directories[@]}"; do
94+
counter=$((counter+1))
95+
echo "--Processing directory $counter '$dir' of total $total"
96+
cd "$dir" && pipenv install ${package_name}~="${CODEFLARE_RELEASE_VERSION}" && pipenv --rm && cd -
97+
echo "$((total-counter)) directories remaining.."
98+
done
99+
else
100+
versions_list=$(echo "$versions" | tr '\n' ' \, ')
101+
versions="${versions_list%,}"
102+
echo "Version '${CODEFLARE_RELEASE_VERSION}' is not available for $package_name"
103+
echo "Available versions for $package_name: $versions"
104+
exit 1
105+
fi
93106
94107
- name: Push changes
95108
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)