Skip to content

Pull Request "feat: add ui tests run in pipeline as part of ci" - Complete CI Pipeline #17

Pull Request "feat: add ui tests run in pipeline as part of ci" - Complete CI Pipeline

Pull Request "feat: add ui tests run in pipeline as part of ci" - Complete CI Pipeline #17

name: Recording Bot Pull Request CI
run-name: Pull Request "${{github.event.pull_request.title}}" - Complete CI Pipeline
on:
pull_request:
branches:
- main
- master
paths:
- Samples/PublicSamples/RecordingBot/**
env:
PR_NUMBER: ${{ github.event.number }}
IMAGE_TAG: pr-${{ github.event.number }}
jobs:
check-recording-bot-changes:
runs-on: ubuntu-latest
outputs:
build: ${{ steps.changes.outputs.build }}
deploy: ${{ steps.changes.outputs.deploy }}
docs: ${{ steps.changes.outputs.docs }}
scripts: ${{ steps.changes.outputs.scripts }}
src: ${{ steps.changes.outputs.src }}
steps:
- uses: actions/checkout@v4
- shell: pwsh
id: changes
run: |
# Diff latest commit with latest main commit for Recording Bot
git fetch
git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- Samples/PublicSamples/RecordingBot/
$diff = git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- Samples/PublicSamples/RecordingBot/
# Check if a file has changed (added, modified, deleted)
$BuildDiff = $diff | Where-Object { $_ -match '^Samples/PublicSamples/RecordingBot/build/' }
$DeployDiff = $diff | Where-Object { $_ -match '^Samples/PublicSamples/RecordingBot/deploy/' }
$DocsDiff = $diff | Where-Object { $_ -match '^Samples/PublicSamples/RecordingBot/docs/' -or $_ -match '.md$' }
$ScriptsDiff = $diff | Where-Object { $_ -match '^Samples/PublicSamples/RecordingBot/scripts/' }
$SrcDiff = $diff | Where-Object { $_ -match '^Samples/PublicSamples/RecordingBot/src/' }
$HasBuildDiff = $BuildDiff.Length -gt 0
$HasDeployDiff = $DeployDiff.Length -gt 0
$HasDocsDiff = $DocsDiff.Length -gt 0
$HasScriptsDiff = $ScriptsDiff.Length -gt 0
$HasSrcDiff = $SrcDiff.Length -gt 0
# Set the outputs
echo "build=$HasBuildDiff" >> $env:GITHUB_OUTPUT
echo "deploy=$HasDeployDiff" >> $env:GITHUB_OUTPUT
echo "docs=$HasDocsDiff" >> $env:GITHUB_OUTPUT
echo "scripts=$HasScriptsDiff" >> $env:GITHUB_OUTPUT
echo "src=$HasSrcDiff" >> $env:GITHUB_OUTPUT
chart-version-checks:
runs-on: ubuntu-latest
needs: check-recording-bot-changes
if: |
needs.check-recording-bot-changes.outputs.build == 'True' ||
needs.check-recording-bot-changes.outputs.deploy == 'True' ||
needs.check-recording-bot-changes.outputs.scripts == 'True' ||
needs.check-recording-bot-changes.outputs.src == 'True'
defaults:
run:
working-directory: Samples/PublicSamples/RecordingBot/deploy
outputs:
app-version-check-passed: ${{ steps.app-version-check.outcome }}
chart-version-check-passed: ${{ steps.chart-version-check.outcome }}
steps:
- uses: actions/checkout@v4
- run: |
git fetch
git branch -a
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: 'latest'
- name: Lint Helm Chart
working-directory: Samples/PublicSamples/RecordingBot/deploy/teams-recording-bot
if: needs.check-recording-bot-changes.outputs.deploy == 'True'
run: |
echo "🔍 Linting Helm chart..."
helm lint
echo "✅ Helm chart lint passed"
- name: Check App Version Change
id: app-version-check
if: |
needs.check-recording-bot-changes.outputs.build == 'True' ||
needs.check-recording-bot-changes.outputs.scripts == 'True' ||
needs.check-recording-bot-changes.outputs.src == 'True'
shell: bash
run: |
echo "🔍 Checking app version changes..."
oldVersion=$(MSYS_NO_PATHCONV=1 git show remotes/origin/$GITHUB_BASE_REF:Samples/PublicSamples/RecordingBot/deploy/teams-recording-bot/Chart.yaml | sed -n "s/^appVersion: \([0-9\.]*\)$/\1/p")
echo "Previous app Version: $oldVersion"
[ -z "$oldVersion" ] && exit 1
newVersion=$(cat teams-recording-bot/Chart.yaml | sed -n "s/^appVersion: \([0-9\.]*\)$/\1/p")
echo "New app Version: $newVersion"
[ -z "$newVersion" ] && exit 1
echo "Check if app Version was updated"
[ "$newVersion" = "$oldVersion" ] && exit 1
newerVersion=$(echo -e "$oldVersion\n$newVersion" | sort -V | tail -1)
[ "$newerVersion" = "$newVersion" ] || exit 1
echo "✅ Success app Version was updated!"
- name: Check Chart Version Change
if: needs.check-recording-bot-changes.outputs.deploy == 'True'
shell: bash
run: |
echo "🔍 Checking chart version changes..."
oldVersion=$(MSYS_NO_PATHCONV=1 git show remotes/origin/$GITHUB_BASE_REF:Samples/PublicSamples/RecordingBot/deploy/teams-recording-bot/Chart.yaml | sed -n "s/^version: \([0-9\.]*\)$/\1/p")
echo "Previous Version: $oldVersion"
[ -z "$oldVersion" ] && exit 1
newVersion=$(cat teams-recording-bot/Chart.yaml | sed -n "s/^version: \([0-9\.]*\)$/\1/p")
echo "New Version: $newVersion"
[ -z "$newVersion" ] && exit 1
echo "Check if Version was updated"
[ "$newVersion" = "$oldVersion" ] && exit 1
newerVersion=$(echo -e "$oldVersion\n$newVersion" | sort -V | tail -1)
[ "$newerVersion" = "$newVersion" ] || exit 1
echo "✅ Success Version was updated!"
start-cluster:
needs: [check-recording-bot-changes, chart-version-checks]
if: |
needs.chart-version-checks.result == 'success' &&
(
needs.check-recording-bot-changes.outputs.build == 'True' ||
needs.check-recording-bot-changes.outputs.deploy == 'True' ||
needs.check-recording-bot-changes.outputs.scripts == 'True' ||
needs.check-recording-bot-changes.outputs.src == 'True'
)
uses: ./.github/workflows/publicrecordingbot_start-cluster.yml
with:
cluster-name: ${{ vars.AKS_CLUSTER_NAME }}
resource-group: ${{ vars.AKS_RESOURCE_GROUP }}
subscription: ${{ vars.AZURE_SUBSCRIPTION_ID }}
secrets:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
build-docker-image:
needs: [check-recording-bot-changes, chart-version-checks]
if: |
needs.chart-version-checks.result == 'success' &&
(
needs.check-recording-bot-changes.outputs.build == 'True' ||
needs.check-recording-bot-changes.outputs.src == 'True' ||
needs.check-recording-bot-changes.outputs.scripts == 'True'
)
uses: ./.github/workflows/publicrecordingbot_docker-build.yml
permissions:
packages: write
with:
cr-namespace-repository: ${{ vars.CR_NAMESPACE_REPOSITORY }}
secrets: inherit
deploy-to-test-environment:
needs: [check-recording-bot-changes, chart-version-checks, start-cluster, build-docker-image]
if: |
needs.start-cluster.result == 'success' &&
(
needs.build-docker-image.result == 'success' ||
needs.check-recording-bot-changes.outputs.deploy == 'True'
)
uses: ./.github/workflows/publicrecordingbot_deploy-environment.yml
with:
environment-name: aks-sample
port: '28550'
cluster-name: ${{ vars.AKS_CLUSTER_NAME }}
resource-group: ${{ vars.AKS_RESOURCE_GROUP }}
subscription: ${{ vars.AZURE_SUBSCRIPTION_ID }}
namespace: teams-recording-bot
host: ${{ needs.start-cluster.outputs.cluster-fqdn }}
image-registry: ${{ vars.CR_REGISTRY }}
image-name: ${{ vars.CR_IMAGE_NAME }}
image-tag: ${{ needs.build-docker-image.outputs.image-tag || 'latest' }}
public-ip: ${{ needs.start-cluster.outputs.cluster-ip }}
tls-email: ${{ vars.TLS_EMAIL }}
enable-nginx: true
replica-count: '1'
secrets:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
run-tests:
needs: [check-recording-bot-changes, chart-version-checks, start-cluster, build-docker-image, deploy-to-test-environment]
if: needs.deploy-to-test-environment.result == 'success'
uses: ./.github/workflows/publicrecordingbot_dotnet-test.yml
with:
headless-mode: true
test-environment: pr-${{ github.event.number }}
github-issue-number: ${{ github.event.number }}
secrets:
USER_A_USERNAME: ${{ vars.TEST_USER_A_USERNAME }}
USER_A_PASSWORD: ${{ secrets.TEST_USER_A_PASSWORD }}
USER_A_SEED: ${{ secrets.TEST_USER_A_SEED }}
USER_B_USERNAME: ${{ vars.TEST_USER_B_USERNAME }}
USER_B_PASSWORD: ${{ secrets.TEST_USER_B_PASSWORD }}
USER_B_SEED: ${{ secrets.TEST_USER_B_SEED }}
USER_C_USERNAME: ${{ vars.TEST_USER_C_USERNAME }}
USER_C_PASSWORD: ${{ secrets.TEST_USER_C_PASSWORD }}
USER_C_SEED: ${{ secrets.TEST_USER_C_SEED }}