Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
AjayJagan committed Apr 2, 2024
1 parent 1a884db commit 827bf6e
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .github/resources/manifest-versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "2.10.0",
"codeflare": "test1",
"kuberay": "test2",
"kueue": "test3",
"dspo": "test4",
"dashboard": "test5",
"notebooks": "test",
"notebook-controller": "test",
"kf-notebook-controller": "test",
"trustyai": "tedt",
"model-mesh": "tet",
"odh-model-controller": "tedt5",
"kserve": "release/v10",
"modelregistry": "release/test"
}
37 changes: 37 additions & 0 deletions .github/scripts/update-manifests-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

update_tags(){
MANIFEST_STR=$(cat get_all_manifests.sh | grep $1 | sed 's/ //g')
readarray -d ":" -t STR_ARR <<< "$MANIFEST_STR"
RES=""
for i in "${!STR_ARR[@]}"; do
if [ $i == 2 ]; then
RES+=$2":"
else
RES+=${STR_ARR[$i]}":"
fi
done
echo here
echo "${RES::-2}"
sed -i -r "s|.*$1.*| ${RES::-2}|" get_all_manifests.sh
}

declare -A COMPONENT_VERSION_MAP=(
["\"codeflare\""]=$1
["\"ray\""]=$2
["\"kueue\""]=$3
["\"data-science-pipelines-operator\""]=$4
["\"odh-dashboard\""]=$5
["\"kf-notebook-controller\""]=$6
["\"odh-notebook-controller\""]=$7
["\"notebooks\""]=$8
["\"trustyai\""]=$9
["\"model-mesh\""]=$10
["\"odh-model-controller\""]=$11
["\"kserve\""]=$12
["\"modelregistry\""]=$13
)

for key in ${!COMPONENT_VERSION_MAP[@]}; do
update_tags ${key} ${COMPONENT_VERSION_MAP[${key}]}
done
23 changes: 23 additions & 0 deletions .github/scripts/wait-for-checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
#
# @param $1 - PR number or URL
# wait for a bit until pr is created, otherwise it throws an error "no checks reported on the 'odh-release/e2e-test' branch"
sleep 10

while $(gh pr checks "$1" | grep -q -v 'tide' | grep -q 'pending'); do
printf ":stopwatch: PR checks still pending, retrying in 10 seconds...\n"
sleep 10
done

if $(gh pr checks "$1" | grep -q 'fail'); then
printf ":x: PR checks failed!\n"
exit 1
fi

if $(gh pr checks "$1" | grep -q 'pass'); then
printf ":white_check_mark: PR checks passed!\n"
exit 0
fi

printf ":confused: An unknown error occurred!\n"
exit 1
54 changes: 54 additions & 0 deletions .github/workflows/release-update-tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Update tags in draft pr"
on:
workflow_dispatch:
jobs:
create-e2e-test-pr:
permissions: write-all
name: Create e2e test pr
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout branch
uses: actions/checkout@v4
# This step needs to be automated
- name: Read json and set env vars
run: |
echo "VERSION=$(cat .github/resources/manifest-versions.json | jq .version )" >> $GITHUB_ENV
echo "CODEFLARE_BRANCH=$(cat .github/resources/manifest-versions.json | jq .codeflare )" >> $GITHUB_ENV
echo "KUBERAY_BRANCH=$(cat .github/resources/manifest-versions.json | jq .kuberay )" >> $GITHUB_ENV
echo "KUEUE_BRANCH=$(cat .github/resources/manifest-versions.json | jq .kueue )" >> $GITHUB_ENV
echo "DSPO_BRANCH=$(cat .github/resources/manifest-versions.json | jq .dspo )" >> $GITHUB_ENV
echo "DASHBOARD_BRANCH=$(cat .github/resources/manifest-versions.json | jq .dashboard )" >> $GITHUB_ENV
echo "NB_BRANCH=$(cat .github/resources/manifest-versions.json | jq .notebooks )" >> $GITHUB_ENV
echo "NB_CONTROLLER_BRANCH=$(cat .github/resources/manifest-versions.json | jq .notebook-controller )" >> $GITHUB_ENV
echo "KF_NB_CONTROLLER_BRANCH=$(cat .github/resources/manifest-versions.json | jq .kf-notebook-controller )" >> $GITHUB_ENV
echo "TRUSTYAI_BRANCH=$(cat .github/resources/manifest-versions.json | jq .trustyai )" >> $GITHUB_ENV
echo "MODEL_MESH_BRANCH =$(cat .github/resources/manifest-versions.json | jq .model-mesh )" >> $GITHUB_ENV
echo "ODH_MODEL_CONTROLLER_BRANCH=$(cat .github/resources/manifest-versions.json | jq .odh-model-controller )" >> $GITHUB_ENV
echo "KSERVE_BRANCH=$(cat .github/resources/manifest-versions.json | jq .kserve )" >> $GITHUB_ENV
echo "MODEL_REGISTRY_BRANCH=$(cat .github/resources/manifest-versions.json | jq .modelregistry )" >> $GITHUB_ENV
- name: Update versions
run: ./.github/scripts/update-manifests-tags.sh ${{ env.CODEFLARE_BRANCH }} ${{ env.KUBERAY_BRANCH }} ${{ env.KUEUE_BRANCH }} ${{ env.DSPO_BRANCH }} ${{ env.DASHBOARD_BRANCH }} ${{ env.KF_NB_CONTROLLER_BRANCH }} ${{ env.NB_CONTROLLER_BRANCH }} ${{ env.NB_BRANCH }} ${{ env.TRUSTYAI_BRANCH }} ${{ env.MODEL_MESH_BRANCH }} ${{ env.ODH_MODEL_CONTROLLER_BRANCH }} ${{ env.KSERVE_BRANCH }} ${{ env.MODEL_REGISTRY_BRANCH }}
- name: Create test pr
id: cpr
uses: peter-evans/create-pull-request@v6
with:
commit-message: "[DO NOT MERGE] Test ${{ env.VERSION }} Release"
branch: odh-release/e2e-test
delete-branch: true
title: "[DO NOT MERGE] Test ${{ env.VERSION }} Release"
- name: Wait for checks to pass
run: ./.github/scripts/wait-for-checks.sh ${{ steps.cpr.outputs.pull-request-number }}
- name: Close PR
uses: peter-evans/close-pull@v3
with:
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
comment: Auto-closing pull request after success checks
delete-branch: true
- name: Push version tag to quay.io
run: |
# Need ODH creds
# podman login -u ajaganat -p ${{ secrets.PODMAN_PASSWORD }} quay.io/ajaganat
# podman pull quay.io/ajaganat/opendatahub-operator:pr-23
# podman push quay.io/ajaganat/opendatahub-operator:pr-23 quay.io/ajaganat/opendatahub-operator:${{ env.VERSION }}
39 changes: 39 additions & 0 deletions .github/workflows/release-update-versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Update versions"
on:
workflow_run:
workflows: ["Update tags in draft pr"]
types: [completed]
jobs:
update-versions:
permissions: write-all
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Read json and set env vars
run: echo "VERSION=$(cat .github/resources/manifest-versions.json | jq .version )" >> $GITHUB_ENV
- name: Update versions in relevant files
run: |
NEW_VERSION=${{ env.VERSION }}
CURRENT_VERSION=$(cat Makefile | grep -w "VERSION ?=" | cut -d ' ' -f 3)
sed -i -e "s/^VERSION ?=.*/VERSION ?= $NEW_VERSION/g" Makefile
sed -i -e "s|containerImage.*|containerImage: quay.io/opendatahub/opendatahub-operator:v$NEW_VERSION|g" config/manifests/bases/opendatahub-operator.clusterserviceversion.yaml
sed -i -e "s|createdAt.*|createdAt: \"$(date +"%Y-%-m-%dT00:00:00Z")\"|g" config/manifests/bases/opendatahub-operator.clusterserviceversion.yaml
sed -i -e "s|name: opendatahub-operator.v.*|name: opendatahub-operator.v$NEW_VERSION|g" config/manifests/bases/opendatahub-operator.clusterserviceversion.yaml
sed -i -e "s|version: $CURRENT_VERSION.*|version: $NEW_VERSION|g" config/manifests/bases/opendatahub-operator.clusterserviceversion.yaml
sed -i -e "s|replaces.*|replaces: opendatahub-operator.v$CURRENT_VERSION|g" config/manifests/bases/opendatahub-operator.clusterserviceversion.yaml
- name: Run make bundle
run: make bundle
- name: Clean up unwanted changes
run: |
sed -i -e "s|image: quay.io/opendatahub/opendatahub-operator:latest.*|image: REPLACE_IMAGE:latest|g" bundle/manifests/opendatahub-operator.clusterserviceversion.yaml
rm ./config/manager/kustomization.yaml
- name: Create version update pr
id: cpr
uses: peter-evans/create-pull-request@v6
with:
commit-message: "ODH Release ${{ env.VERSION }}"
branch: odh-release/version-update
delete-branch: true
title: "ODH Release ${{ env.VERSION }}: Version Update"
13 changes: 13 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Release ODH
on:
pull_request:
types:
- closed

jobs:
release-odh:
if: github.event.pull_request.merged == true && startsWith( ${{ github.event.pull_request.title }}, 'ODH Release' ) && endsWith( ${{ github.event.pull_request.title }}, 'Version Update' )
runs-on: ubuntu-latest
steps:
- run: |
echo The PR was merged and now we can trigger a release branch creation
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/k
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
$(KUSTOMIZE): $(LOCALBIN)
test -s $(KUSTOMIZE) || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | sh -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
test -s $(KUSTOMIZE) || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
Expand Down

0 comments on commit 827bf6e

Please sign in to comment.