Skip to content

Commit

Permalink
[OSSM-5306][OSSM-5307] Add building tests images into pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
mkralik3 committed Dec 7, 2023
1 parent d75c678 commit 8ca3dfd
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 6 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ on:
required: true
default: master
type: string
quay_repository:
description: Quay repository
quay_org:
description: Quay organization
type: string
default: quay.io/kiali/kiali
default: kiali
required: true

jobs:
Expand All @@ -24,6 +24,7 @@ jobs:
outputs:
target_branch: ${{ github.ref_name }}
quay_tag: ${{ env.quay_tag }}
quay_org: ${{ env.quay_org }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -33,22 +34,25 @@ jobs:
- name: Determine Quay tag
id: quay_tag
run: |
if [ -z ${{ github.event.inputs.quay_repository }} ];
if [ -z ${{ github.event.inputs.quay_org }} ];
then
QUAY_REPO="quay.io/kiali/kiali"
QUAY_ORG="kiali"
else
QUAY_REPO="${{ github.event.inputs.quay_repository }}"
QUAY_ORG="${{ github.event.inputs.quay_org }}"
fi
QUAY_REPO="quay.io/$QUAY_ORG/kiali"
QUAY_TAG="$QUAY_REPO:latest"
echo "quay_tag=$QUAY_TAG" >> $GITHUB_ENV
echo "quay_org=$QUAY_ORG" >> $GITHUB_ENV
- name: Log information
run: |
echo "Release type: latest"
echo "Quay tag": ${{ env.quay_tag }}
echo "Quay org": ${{ env.quay_org }}
build_backend:
name: Build backend
Expand All @@ -73,6 +77,7 @@ jobs:
needs: [initialize, build_backend, build_frontend]
env:
QUAY_TAG: ${{ needs.initialize.outputs.quay_tag }}
IMAGE_ORG: ${{ needs.initialize.outputs.quay_org }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -99,3 +104,15 @@ jobs:
docker login -u ${{ secrets.QUAY_USER }} -p ${{ secrets.QUAY_PASSWORD }} quay.io
make -e DOCKER_CLI_EXPERIMENTAL=enabled build-linux-multi-arch container-multi-arch-all-push-kiali-quay
push_test_images:
name: Build and push tests images
uses: ./.github/workflows/tests-images-creator.yml
needs: [initialize, build_backend, build_frontend]
with:
release_branch: ${{ github.event.inputs.release_branch || github.ref_name }}
images_tag: latest
quay_org: ${{ needs.initialize.outputs.quay_org }}
secrets:
QUAY_USER: ${{ secrets.QUAY_USER }}
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
69 changes: 69 additions & 0 deletions .github/workflows/release-tests-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release test suites images

on:
push:
tags:
- 'v*'
jobs:
initialize:
name: Initialize
runs-on: ubuntu-20.04
outputs:
quay_org: 'kiali'
images_tag: ${{ steps.images_tag.outputs.images_tag }}
steps:
- name: Determine Images tag without Z version
id: images_tag
run: |
major=$(echo ${{ github.ref_name }} | cut -d. -f1)
minor=$(echo ${{ github.ref_name }} | cut -d. -f2)
echo "images_tag=$major.$minor" >> $GITHUB_OUTPUT
- name: Log information
run: |
echo "Github tag": ${{ github.ref_name }}
echo "Quay main version tag": ${{ steps.images_tag.outputs.images_tag }}
push_test_images:
name: Build and push images with full tag
uses: ./.github/workflows/tests-images-creator.yml
needs: [initialize]
with:
release_branch: ${{ github.ref_name }}
images_tag: ${{ github.ref_name }}
quay_org: ${{ needs.initialize.outputs.quay_org }}
secrets:
QUAY_USER: ${{ secrets.QUAY_USER }}
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}

update_latest_test_images:
name: Update images under major.minor version tag
runs-on: ubuntu-20.04
needs: [initialize, push_test_images]
steps:
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Pull new integration test image
run: |
docker pull quay.io/${{ needs.initialize.outputs.quay_org }}/kiali-int-tests:${{ github.ref_name }}
- name: Use major.minor version tag
run: |
docker tag quay.io/${{ needs.initialize.outputs.quay_org }}/kiali-int-tests:${{ github.ref_name }} quay.io/${{ needs.initialize.outputs.quay_org }}/kiali-int-tests:${{ needs.initialize.outputs.images_tag }}
- name: Update integration test image in quay
run: |
docker push quay.io/${{ needs.initialize.outputs.quay_org }}/kiali-int-tests:${{ needs.initialize.outputs.images_tag }}
- name: Pull new cypress test image
run: |
docker pull quay.io/${{ needs.initialize.outputs.quay_org }}/kiali-cypress-tests:${{ github.ref_name }}
- name: Use major.minor version tag
run: |
docker tag quay.io/${{ needs.initialize.outputs.quay_org }}/kiali-cypress-tests:${{ github.ref_name }} quay.io/${{ needs.initialize.outputs.quay_org }}/kiali-cypress-tests:${{ needs.initialize.outputs.images_tag }}
- name: Update cypress test image in quay
run: |
docker push quay.io/${{ needs.initialize.outputs.quay_org }}/kiali-cypress-tests:${{ needs.initialize.outputs.images_tag }}
74 changes: 74 additions & 0 deletions .github/workflows/tests-images-creator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build and push test suites images

on:
workflow_dispatch:
inputs:
release_branch:
description: Branch to release
default: master
type: string
required: true
quay_org:
description: Quay organization
type: string
default: kiali
required: true
images_tag:
description: Images tag
type: string
default: dev
required: true
workflow_call:
inputs:
release_branch:
description: Branch to release
type: string
required: true
quay_org:
description: Quay organization
type: string
required: true
images_tag:
description: Images tag
type: string
required: true
secrets:
QUAY_USER:
description: 'A quay user secret passed from the caller workflow'
required: true
QUAY_PASSWORD:
description: 'A quay user password passed from the caller workflow'
required: true


jobs:
build_and_push:
name: Generate and push docker images
runs-on: ubuntu-latest
env:
# These ENVs are expected in Make file!
IMAGE_ORG: ${{ inputs.quay_org }}
INT_TESTS_CONTAINER_VERSION: ${{ inputs.images_tag }}
CYPRESS_TESTS_CONTAINER_VERSION: ${{ inputs.images_tag }}
steps:
- name: Log information
run: |
echo "Branch": ${{ inputs.release_branch }}
echo "Quay organization": ${{ inputs.quay_org }}
echo "Images tag": ${{ inputs.images_tag }}
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.release_branch }}
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: "Build integration tests image"
run: |
make container-build-int-tests container-push-int-tests-quay
- name: "Build cypress tests image"
run: |
make container-build-cypress-tests container-push-cypress-tests-quay
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ INT_TESTS_CONTAINER_VERSION ?= ${CONTAINER_VERSION}
INT_TESTS_QUAY_NAME ?= quay.io/${INT_TESTS_CONTAINER_NAME}
INT_TESTS_QUAY_TAG ?= ${INT_TESTS_QUAY_NAME}:${INT_TESTS_CONTAINER_VERSION}

# Identifies the Kiali cypress tests container image that will be built
CYPRESS_TESTS_CONTAINER_NAME ?= ${IMAGE_ORG}/kiali-cypress-tests
CYPRESS_TESTS_CONTAINER_VERSION ?= ${CONTAINER_VERSION}
CYPRESS_TESTS_QUAY_NAME ?= quay.io/${CYPRESS_TESTS_CONTAINER_NAME}
CYPRESS_TESTS_QUAY_TAG ?= ${CYPRESS_TESTS_QUAY_NAME}:${CYPRESS_TESTS_CONTAINER_VERSION}

# Where the control plane is
ISTIO_NAMESPACE ?= istio-system
# Declares the namespace/project where the objects are to be deployed.
Expand Down
20 changes: 20 additions & 0 deletions make/Makefile.container.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ else
podman build --pull -t ${INT_TESTS_QUAY_TAG} -f tests/integration/Dockerfile .
endif

## container-build-cypress-tests: Build Kiali cypress tests container image
container-build-cypress-tests:
ifeq ($(DORP),docker)
@echo Building container image for Kiali cypress tests using docker
docker build --pull -t ${CYPRESS_TESTS_QUAY_TAG} -f deploy/docker/Dockerfile-cypress .
else
@echo Building container image for Kiali cypress tests using podman
podman build --pull -t ${CYPRESS_TESTS_QUAY_TAG} -f deploy/docker/Dockerfile-cypress .
endif

## container-push-kiali-quay: Pushes the Kiali image to quay.
container-push-kiali-quay:
ifeq ($(DORP),docker)
Expand Down Expand Up @@ -71,6 +81,16 @@ else
podman push ${INT_TESTS_QUAY_TAG}
endif

## container-push-cypress-tests-quay: Pushes the Kiali cypress tests image to quay.
container-push-cypress-tests-quay:
ifeq ($(DORP),docker)
@echo Pushing Kiali cypress tests image to ${CYPRESS_TESTS_QUAY_TAG} using docker
docker push ${CYPRESS_TESTS_QUAY_TAG}
else
@echo Pushing Kiali cypress tests image to ${CYPRESS_TESTS_QUAY_TAG} using podman
podman push ${CYPRESS_TESTS_QUAY_TAG}
endif

# Ensure "docker buildx" is available and enabled. For more details, see: https://github.com/docker/buildx/blob/master/README.md
# This does a few things:
# 1. Makes sure docker is in PATH
Expand Down

0 comments on commit 8ca3dfd

Please sign in to comment.