Skip to content

Commit

Permalink
[WIP]odo v3 build & 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 7ec9bf3 commit a7e64cf
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 29 deletions.
22 changes: 12 additions & 10 deletions .ci/deploy/resources/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ metadata:
name: devfile-registry
labels:
name: devfile-registry
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: "{{hostName}}"
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: devfile-registry
port:
number: 8080
- host: "{{hostName}}"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: devfile-registry
port:
number: 8080
92 changes: 92 additions & 0 deletions .ci/odov3_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/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.
#

# Share docker env with Minikube
eval $(minikube docker-env)

# 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'}
# Set pull policy of REGISTRY_IMAGE
PULL_POLICY=${PULL_POLICY:-'Always'}

# 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, otherwise set to testing namespace
if [ -z $(kubectl describe namespace/${NAMESPACE} 2> /dev/null) ]; then
odo create namespace ${NAMESPACE}
else
odo set namespace ${NAMESPACE}
fi

# Wait for ingress to be ready
kubectl wait pods -l app.kubernetes.io/name=ingress-nginx,app.kubernetes.io/component=controller --namespace ingress-nginx --for=condition=Ready --timeout=600s

# 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} \
--var indexPullPolicy=${PULL_POLICY}

# Wait for deployment to be ready
kubectl wait deploy/devfile-registry --for=condition=Available --timeout=600s
if [ $? -ne 0 ]; then
# Return the logs of the 3 containers in case the condition is not met
echo "devfile-registry container logs:"
kubectl logs -l app=devfile-registry --container devfile-registry
echo "oci-registry container logs:"
kubectl logs -l app=devfile-registry --container oci-registry
echo "registry-viewer container logs:"
kubectl logs -l app=devfile-registry --container registry-viewer
# Return the description of every pod
kubectl describe pods

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

exit 1
fi

# Get status code, retry for 5 times until status code is 200 otherwise fail
STATUS_CODE=$(curl --fail --retry 5 -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
20 changes: 10 additions & 10 deletions .devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ commands:
isDefault: true
kind: deploy
# Deploy Devfile Registry to Red Hat OpenShift
- id: deploy-registry-openshift
composite:
commands:
- apply-deployment
- apply-service
- apply-configmap
- apply-service-account
- apply-route
group:
kind: deploy
# - id: deploy-registry-openshift
# composite:
# commands:
# - apply-deployment
# - apply-service
# - apply-configmap
# - apply-service-account
# - apply-route
# group:
# kind: deploy
variables:
# The number of replicas for the hosted devfile registry service
replicas: "1"
Expand Down
51 changes: 42 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,35 @@ jobs:

- name: Check if devfile registry build is working
run: bash registry-repo/.ci/build.sh
odov3-build-deploy:
name: Test devfile registry odo V3 build & deploy
runs-on: ubuntu-latest
env:
ODOV3_VERSION: "3.15.0"
REGISTRY_IMAGE: localhost/devfile-index:latest
PULL_POLICY: 'Never' # Use local built image with registry changes
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: ${{ env.ODOV3_VERSION }}
- 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 --memory 4096 --cpus 2'
- name: Check odo version
run: odo version
- name: Check if devfile registry odo v3 build is working
run: |
export IMG="$(echo $REGISTRY_IMAGE | cut -d':' -f1)"
export TAG="$(echo $REGISTRY_IMAGE | cut -d':' -f2)"
export PODMAN_CMD="" # Forces odo to use docker
odo build-images --var indexImageName=$IMG --var indexImageTag=$TAG
- name: Check if devfile registry odo v3 deploy is working
run: bash .ci/odov3_deploy.sh

0 comments on commit a7e64cf

Please sign in to comment.