Skip to content

Create hello world ACI test pipeline #379

Create hello world ACI test pipeline

Create hello world ACI test pipeline #379

name: Kafka Demo Test
on:
pull_request:
branches:
- main
paths:
- .github/workflows/**
- kafka/**
- '!**/README.md'
- '!.github/workflows/release.yml'
- '!.github/workflows/ci.yml'
workflow_dispatch:
inputs:
sidecar-registry:
description: "The registry to get the image from"
required: true
type: choice
default: mcr.microsoft.com
options:
- mcr.microsoft.com
- confidentialsidecars.azurecr.io
- accsamplesmcr.azurecr.io
key-release-image:
description: "The image of the SKR sidecar to use"
required: true
default: "aci/skr:2.7"
type: string
consumer-image:
description: "Consumer Image"
default: "public/acc/samples/kafka/consumer:2.0"
required: true
type: string
producer-image:
description: "Producer Image"
default: "public/acc/samples/kafka/consumer:2.0"
required: true
type: string
merge_group:
branches:
- main
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
attestations: write
packages: write
jobs:
prepare:
name: Extract Environment Variables
runs-on: ubuntu-latest
outputs:
key-release-image: ${{ steps.extract-envs.outputs.key-release-image }}
consumer-image: ${{ steps.extract-envs.outputs.consumer-image }}
producer-image: ${{ steps.extract-envs.outputs.producer-image }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract Envs
id: extract-envs
run: |
echo "Extracting Environment Variables"
echo "Triggering event is ${{ github.event_name }}"
# uses default SKR but builds new Kafka images from source for PR
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "key-release-image=mcr.microsoft.com/aci/skr:2.7" >> $GITHUB_OUTPUT
echo "consumer-image=private/${{ github.actor }}/acc/samples/kafka/consumer:${{ github.sha }}" >> $GITHUB_OUTPUT
echo "producer-image=private/${{ github.actor }}/acc/samples/kafka/producer:${{ github.sha }}" >> $GITHUB_OUTPUT
# uses the provided SKR and Kafka images or defaults for workflow_dispatch
else
echo "key-release-image=${{ format('{0}/{1}', inputs.sidecar-registry, inputs.key-release-image) }}" >> $GITHUB_OUTPUT
echo "consumer-image=${{ inputs.consumer-image }}" >> $GITHUB_OUTPUT
echo "producer-image=${{ inputs.producer-image }}" >> $GITHUB_OUTPUT
fi
push_images:
name: Push Images to Private Registry for Testing
needs: [prepare]
uses: ./.github/workflows/_push_image.yml
if: github.event_name == 'pull_request'
secrets: inherit
strategy:
matrix:
image: ["kafka/consumer", "kafka/producer"]
with:
image: "private/${{ github.actor }}/acc/samples/${{ matrix.image }}"
tag: "${{ github.sha }}"
docker_context: ${{ '.' }}
repo_type: private
dockerfile_path: "${{ matrix.image }}"
create-aks-cluster:
name: Create AKS Cluster
needs: [prepare, push_images]
uses: ./.github/workflows/_create_aks_cluster.yml
if: always() && (needs.push_images.result == 'success' || needs.push_images.result == 'skipped')
secrets: inherit
with:
demo-name: kafka
workflow-id: ${{ github.sha }}
setup-aks-cluster:
name: Setup AKS Cluster
needs: [prepare, push_images, create-aks-cluster]
uses: ./.github/workflows/_setup_aks_cluster.yml
if: always() && (needs.push_images.result == 'success' || needs.push_images.result == 'skipped')
secrets: inherit
with:
cluster-name: ${{ needs.create-aks-cluster.outputs.cluster-name }}
deploy-kafka-test:
name: Deploy Kafka Demo Test
uses: ./.github/workflows/_deploy_kafka_test.yml
needs: [prepare, push_images, create-aks-cluster, setup-aks-cluster]
if: always() && (needs.push_images.result == 'success' || needs.push_images.result == 'skipped')
secrets: inherit
with:
cluster-name: ${{ needs.create-aks-cluster.outputs.cluster-name }}
key-release-image: ${{ needs.prepare.outputs.key-release-image }}
consumer-image: ${{ needs.prepare.outputs.consumer-image }}
producer-image: ${{ needs.prepare.outputs.producer-image }}
test-workload:
name: Test Workload
uses: ./.github/workflows/_test_workload.yml
needs: [push_images, create-aks-cluster, deploy-kafka-test]
if: always() && (needs.push_images.result == 'success' || needs.push_images.result == 'skipped')
secrets: inherit
with:
cluster-name: ${{ needs.create-aks-cluster.outputs.cluster-name }}
cleanup:
name: Clean Up
if: always() && needs.create-aks-cluster.result == 'success' && needs.push_images.result == 'success'
uses: ./.github/workflows/_cleanup.yml
needs: [push_images, create-aks-cluster, deploy-kafka-test, test-workload]
secrets: inherit
with:
cluster-name: ${{ needs.create-aks-cluster.outputs.cluster-name }}
skr-client-kid: ${{ needs.deploy-kafka-test.outputs.skr-client-kid }}