forked from microsoftgraph/microsoft-graph-comms-samples
-
Notifications
You must be signed in to change notification settings - Fork 1
148 lines (121 loc) · 6.09 KB
/
recording-bot-build-and-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Recording Bot Build And Test
run-name: Pull Request "${{github.event.pull_request.title}}" build and test
on:
pull_request:
branches:
- main
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: "6.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!"