Skip to content

Commit b920a77

Browse files
[RAPTOR-12473] Update pipeline test functional by framework (#1426)
1 parent ccff439 commit b920a77

File tree

5 files changed

+268
-24
lines changed

5 files changed

+268
-24
lines changed

.harness/env_image_publish.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pipeline:
2828
stageStatus: Success
2929
spec:
3030
connectorRef: datarobot_user_models_read_write
31-
repo: datarobotdev/datarobot-user-models
31+
repo: <+pipeline.variables.image_namespace_repo>
3232
tags:
3333
- <+pipeline.variables.image_tag>
3434
dockerfile: <+pipeline.variables.dockerfile_path>
@@ -54,6 +54,11 @@ pipeline:
5454
type: String
5555
required: true
5656
value: <+input>
57+
- name: image_namespace_repo
58+
type: String
59+
description: ""
60+
required: true
61+
value: <+input>.default(datarobotdev/datarobot-user-models)
5762
- name: image_tag
5863
type: String
5964
description: ""

.harness/reconcile_dependencies_for_all_envs_based_on_parent_folder.yaml

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,25 @@ pipeline:
1616
enabled: true
1717
execution:
1818
steps:
19+
- step:
20+
type: GitClone
21+
name: Get DR Release Version
22+
identifier: Get_DR_Release_Version
23+
spec:
24+
connectorRef: account.svc_harness_git1
25+
repoName: DataRobot
26+
sparseCheckout:
27+
- config/RELEASE_VERSION
28+
depth: 1
29+
build:
30+
type: branch
31+
spec:
32+
branch: master
1933
- step:
2034
type: Run
2135
name: reconcile_dependencies
2236
identifier: reconcile_dependencies
2337
spec:
24-
connectorRef: account.dockerhub_datarobot_read
25-
image: datarobotdev/mirror_chainguard_datarobot.com_python-fips:3.11-dev
2638
shell: Bash
2739
command: |-
2840
# Ensure Git is installed
@@ -31,13 +43,20 @@ pipeline:
3143
apt-get update && apt-get install -y git
3244
fi
3345
46+
echo "Getting current DataRobot release version"
47+
RELEASE_VERSION=$(cat DataRobot/config/RELEASE_VERSION)
48+
# if [ "$TARGET_BRANCH" != "master" ]; then
49+
# RELEASE_VERSION=$(echo $TARGET_BRANCH | sed 's|release/||')
50+
# fi
51+
echo "Current DataRobot release version: ${RELEASE_VERSION}"
52+
3453
# Configure Git
3554
git config --global user.name "svc-harness-git2"
3655
git config --global user.email "svc-harness-git2@datarobot.com"
3756
git config --global url."https://${GITHUB_ACCESS_TOKEN}@github.com/".insteadOf "https://github.com/"
3857
git config --global --add safe.directory /harness # Mark /harness as a safe directory
3958
40-
pip install bson
59+
pip install bson pyyaml
4160
4261
# Clone the datarobot-user-models repository
4362
git init
@@ -108,23 +127,44 @@ pipeline:
108127
git show HEAD:./env_info.json | grep -n 'environmentVersionId' > /tmp/new_env_version_id.txt
109128
# If env version was not updated, update
110129
if diff /tmp/old_env_version_id.txt /tmp/new_env_version_id.txt > /dev/null; then
111-
echo "Updating Environment Version ID"
130+
echo "Updating Environment Version IDi --"
112131
python3 ${ROOT_DIR}/tools/env_version_update.py --file ./env_info.json
132+
echo "DONE Updating Environment Version IDi --"
113133
fi
114134
135+
# convert env_info.json to values.yaml
136+
# echo "Updating values.yaml with info from env_info.json"
137+
# python3 ${ROOT_DIR}/tools/build_values_yaml.py from-json --json ./env_info.json --yaml ./values.yaml
138+
139+
# echo "Getting env version id from yaml"
140+
# ENV_VERSION_ID=$(yq '.environmentVersionId' ./values.yaml)
141+
# IMAGE_REPOSITORY=$(yq '.imageRepository' ./values.yaml)
142+
143+
# IMAGE_TAG="v$RELEASE_VERSION-$ENV_VERSION_ID"
144+
# TAGS="$IMAGE_TAG,v$RELEASE_VERSION-latest"
145+
# if [ "$TARGET_BRANCH" = "master" ]; then
146+
# TAGS="$TAGS,latest"
147+
# fi
148+
149+
# python3 ${ROOT_DIR}/tools/build_values_yaml.py set-values \
150+
# --yaml ./values.yaml \
151+
# tags=${TAGS} \
152+
# image=datarobotdev/${IMAGE_REPOSITORY}:${IMAGE_TAG}
153+
154+
# git add ./values.yaml
115155
116156
cd -
117157
done
118158
119159
# Commit and push changes if any
120160
if [[ -n $(git status --porcelain) ]]; then
121161
git status --porcelain
122-
git commit -a -m "Reconcile dependencies for $ENV_DIR"
162+
git commit -a -m "Reconcile dependencies, updated IDs, tags, values.yaml for $DIR"
123163
git config pull.rebase true
124164
git pull origin "$(git branch --show-current)" --rebase
125165
git push --set-upstream origin "$(git branch --show-current)"
126166
127-
echo "Reconciled dependencied commited to branch"
167+
echo "Reconciled dependencies commited to branch"
128168
exit 0
129169
else
130170
echo "No changes detected in Git."

.harness/test_functional_by_framework.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,22 @@ pipeline:
5252
. ./harness_scripts/functional_by_framework/check_env_changed_check_diff.sh
5353
5454
dockerfile_local="./<+pipeline.variables.env_folder>/<+pipeline.variables.framework>/Dockerfile.local"
55-
ls -la ${dockefile_local}
55+
56+
image_uri=${test_image_namespace}/${test_image_repository}:${test_image_tag}
5657
if [ -f "${dockerfile_local}" ]; then
5758
dockerfile_local_exists=true
58-
matrix_values="${test_image_tag},${test_image_tag}.local"
59+
matrix_values="${image_uri},datarobotdev/${test_image_repository}:${test_image_tag}.local"
5960
else
6061
dockerfile_local_exists=false
61-
matrix_values="${test_image_tag}"
62+
matrix_values="${image_uri}"
6263
fi
6364
export dockerfile_local_exists
6465
outputVariables:
6566
- name: dockerfile_local_exists
6667
- name: matrix_values
6768
- name: changed_deps
69+
- name: test_image_namespace
70+
- name: test_image_repository
6871
- name: test_image_tag
6972
caching:
7073
enabled: false
@@ -98,6 +101,9 @@ pipeline:
98101
- name: dockerfile_path
99102
type: String
100103
value: <+pipeline.variables.env_folder>/<+pipeline.variables.framework>/Dockerfile
104+
- name: image_namespace_repo
105+
type: String
106+
value: <+pipeline.stages.check_env_changed.spec.execution.steps.check_diff.output.outputVariables.test_image_namespace>/<+pipeline.stages.check_env_changed.spec.execution.steps.check_diff.output.outputVariables.test_image_repository>
101107
- name: image_tag
102108
type: String
103109
value: <+pipeline.stages.check_env_changed.spec.execution.steps.check_diff.output.outputVariables.test_image_tag>
@@ -127,6 +133,9 @@ pipeline:
127133
- name: dockerfile_path
128134
type: String
129135
value: <+pipeline.variables.env_folder>/<+pipeline.variables.framework>/Dockerfile.local
136+
- name: image_namespace_repo
137+
type: String
138+
value: <+pipeline.stages.check_env_changed.spec.execution.steps.check_diff.output.outputVariables.test_image_namespace>/<+pipeline.stages.check_env_changed.spec.execution.steps.check_diff.output.outputVariables.test_image_repository>
130139
- name: image_tag
131140
type: String
132141
value: <+pipeline.stages.check_env_changed.spec.execution.steps.check_diff.output.outputVariables.test_image_tag>.local
@@ -149,10 +158,10 @@ pipeline:
149158
identifier: Run_1
150159
strategy:
151160
matrix:
152-
image_tag: <+<+pipeline.stages.check_env_changed.spec.execution.steps.check_diff.output.outputVariables.matrix_values>.split(',')>
161+
image_uri: <+<+pipeline.stages.check_env_changed.spec.execution.steps.check_diff.output.outputVariables.matrix_values>.split(',')>
153162
spec:
154163
connectorRef: datarobot_user_models_read_write
155-
image: datarobotdev/datarobot-user-models:<+matrix.image_tag>
164+
image: <+matrix.image_uri>
156165
shell: Sh
157166
command: |-
158167
echo "Checking if test for local should run"

harness_scripts/functional_by_framework/check_env_changed_check_diff.sh

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,67 @@ git fetch origin master ${CODEBASE_BRANCH}
1616
git branch -a
1717

1818
changed_paths=$(git diff --name-only origin/master...HEAD)
19-
echo "changed_paths: $changed_paths"
19+
echo "--- changed paths ---"
20+
echo "${changed_paths}"
21+
echo "--- --- --- --- ---"
22+
23+
# by default define namespace, repo, and tag for the existing flow without changes
24+
# e.g. datarobotdev/datarobot-user-models:public_dropin_envs_python3_sklearn_latest
25+
env_info="${ENV_FOLDER}/${FRAMEWORK}/env_info.json"
26+
ENV_VERSION_ID=$(jq -r '.environmentVersionId' ${env_info})
27+
28+
test_image_namespace=datarobotdev
29+
test_image_repository=datarobot-user-models
30+
31+
test_image_tag_base=${ENV_FOLDER}_${FRAMEWORK}_${ENV_VERSION_ID}
32+
test_image_tag=${test_image_tag_base}
33+
34+
changed_deps=false;
35+
36+
37+
IMAGE_REPOSITORY=$(jq -r '.imageRepository' ${env_info})
38+
if [ "${IMAGE_REPOSITORY}" = "null" ]; then
39+
echo "Image repository is not defined in env_info.json"
40+
else
41+
# if env_info has imageRepository
42+
# point test_image_namespace to datarobot
43+
# point test_image_repository to defined repo
44+
# point tag to ENV_VERSION_ID
45+
# e.g. datarobot/env-python-sklearn:12355123abc918234
46+
echo "read ${IMAGE_REPOSITORY}"
47+
# after promotion work, change to datarobot
48+
test_image_namespace=datarobotdev
49+
test_image_repository=${IMAGE_REPOSITORY}
50+
test_image_tag_base=${ENV_VERSION_ID}
51+
test_image_tag=${ENV_VERSION_ID}
52+
fi
53+
2054

21-
test_image_tag_base=${ENV_FOLDER}_${FRAMEWORK}
2255
if echo "${changed_paths}" | grep "${ENV_FOLDER}/${FRAMEWORK}" > /dev/null; then
2356
changed_deps=true;
57+
# if env changed, means we want to push tmp image into datarobotdev
58+
test_image_namespace=datarobotdev
2459
if [ -n $TRIGGER_PR_NUMBER ] && [ "$TRIGGER_PR_NUMBER" != "null" ]; then
25-
test_image_tag=${test_image_tag_base}_${TRIGGER_PR_NUMBER};
60+
# datarobotdev/env-python-sklearn:12355123abc918234_PR_NUM
61+
# or
62+
# datarobotdev/datarobot-user-models:public_dropin_envs_python3_sklearn_PR_NUM
63+
test_image_tag=${test_image_tag_base}
2664
else
2765
test_image_tag=${test_image_tag_base}_${CODEBASE_BRANCH}
2866
# If the test_image_tag may contain a slash, replace it with an underscore (POSIX compliant)
2967
while case $test_image_tag in */*) true;; *) false;; esac; do
3068
test_image_tag=${test_image_tag%%/*}_${test_image_tag#*/}
3169
done
3270
fi
33-
else
34-
changed_deps=false;
35-
test_image_tag=${test_image_tag_base}_latest;
3671
fi
3772

38-
# If the environment variable 'USE_LOCAL_DOCKERFILE' is set to "true", than add '.local'
39-
#if [ -n $USE_LOCAL_DOCKERFILE ] && [ "$USE_LOCAL_DOCKERFILE" = "true" ]; then
40-
# test_image_tag=${test_image_tag}.local
41-
#fi
42-
4373
# Required by the Harness step
4474
export changed_deps
75+
export test_image_namespace
76+
export test_image_repository
4577
export test_image_tag
4678

47-
echo "changed_deps: $changed_deps, test_image_tag: $test_image_tag"
79+
echo "changed_deps: $changed_deps"
80+
echo "test_image_namespace: $test_image_namespace"
81+
echo "test_image_repository: $test_image_repository"
82+
echo "test_image_tag: $test_image_tag"

0 commit comments

Comments
 (0)