Skip to content

Commit

Permalink
[WIP]odo v3 deploy ci check
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Valdron <[email protected]>
  • Loading branch information
michael-valdron committed Dec 7, 2023
1 parent efa684d commit e2125ed
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .ci/deploy/resources/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ metadata:
name: devfile-registry
labels:
name: devfile-registry
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: "{{hostName}}"
Expand Down
64 changes: 64 additions & 0 deletions .ci/odov3_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

#
# Copyright Red Hat
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
# error on unset variables
set -u
# print each command before executing it
set -x

# Disable telemtry for odo
export ODO_DISABLE_TELEMETRY=true

# Split the registry image and image tag from the REGISTRY_IMAGE env variable
IMG="$(echo $REGISTRY_IMAGE | cut -d':' -f1)"
TAG="$(echo $REGISTRY_IMAGE | cut -d':' -f2)"

# Set namespace
NAMESPACE=${NAMESPACE:-'devfile-registry-test'}

# Fail if odo is not installed
if [ -z $(command -v odo 2> /dev/null) ]; then
echo "install odo."
exit 1
fi

# Create testing namespace if does not exist
odo create namespace ${NAMESPACE}

# Deploy devfile registry using odo v3
odo deploy --var hostName=${NAMESPACE}.$(minikube ip).nip.io \
--var hostAlias=${NAMESPACE}.$(minikube ip).nip.io \
--var indexImageName=$IMG \
--var indexImageTag=$TAG

# Wait for deployment to be ready
kubectl wait deploy/devfile-registry --for=condition=Available --timeout=600s

# Get status code, retry for 30 seconds until status code is 200 otherwise fail
STATUS_CODE=$(curl --fail --retry-max-time 30 -o /dev/null -s -w "%{http_code}\n" "http://${NAMESPACE}.$(minikube ip).nip.io/health")
if [ ${STATUS_CODE} -ne 200 ]; then
echo "unexpected status code ${STATUS_CODE}, was expecting 200"

odo delete component --name devfile-registry-community --force

exit 1
else
odo delete component --name devfile-registry-community --force
fi
43 changes: 34 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#
# Copyright 2020-2022 Red Hat, Inc.
# Copyright Red Hat
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: CI

on:
Expand Down Expand Up @@ -40,3 +41,27 @@ jobs:

- name: Check if devfile registry build is working
run: bash registry-repo/.ci/build.sh
odov3-deploy:
name: Test odo V3 deploy
runs-on: ubuntu-latest
env:
REGISTRY_IMAGE: quay.io/devfile/devfile-index:next
steps:
- name: Check out code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Install odo v3
uses: redhat-actions/openshift-tools-installer@2de9a80cf012ad0601021515481d433b91ef8fd5 # v1
with:
odo: "3.15.0"
- name: Setup Minikube
uses: manusa/actions-setup-minikube@3856c6fa039819f1c8e7e248b1fc5a8564e354c9 # v2.9.0
with:
minikube version: 'v1.31.2'
kubernetes version: 'v1.26.0'
driver: 'docker'
github token: ${{ secrets.GITHUB_TOKEN }}
start args: '--addons ingress,ingress-dns --memory 4096 --cpus 2'
- name: Check odo version
run: odo version
- name: Check deployment
run: bash .ci/odov3_deploy.sh

0 comments on commit e2125ed

Please sign in to comment.