Skip to content

Pull Request "Fix conflict with graph comms master in gitignore" build and test #65

Pull Request "Fix conflict with graph comms master in gitignore" build and test

Pull Request "Fix conflict with graph comms master in gitignore" build and test #65

name: Recording Bot Build And Test
run-name: Pull Request "${{github.event.pull_request.title}}" build and test
on:
pull_request:
branches:
- main
- master
paths:
- Samples/PublicSamples/RecordingBot/**
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
dotnet-build-and-test:
runs-on: windows-2022
needs: check-recording-bot-changes
if: needs.check-recording-bot-changes.outputs.src == 'True'
defaults:
run:
working-directory: Samples/PublicSamples/RecordingBot/src
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
- name: Rename .env-template
run: |
Rename-Item "RecordingBot.Tests\.env-template" -NewName ".env"
Rename-Item "RecordingBot.Console\.env-template" -NewName ".env"
- name: Build project
run: dotnet build
- name: Test project
run: dotnet test
docker-build:
runs-on: windows-2022
needs: check-recording-bot-changes
if: needs.check-recording-bot-changes.outputs.build == 'True'
defaults:
run:
working-directory: Samples/PublicSamples/RecordingBot/
steps:
- uses: actions/checkout@v4
- name: Build Docker Image
shell: bash
run: docker build -f ./build/Dockerfile . -t "teams-recording-bot:${GITHUB_SHA}"
chart-build-and-test:
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
steps:
- uses: actions/checkout@v4
- run: |
git fetch
git branch -a
- name: Lint Helm Chart
working-directory: Samples/PublicSamples/RecordingBot/deploy/teams-recording-bot
if: needs.check-recording-bot-changes.outputs.deploy == 'True'
run: helm lint
- name: Check App Version Change
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: |
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 Version Change
shell: bash
run: |
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!"