-
Notifications
You must be signed in to change notification settings - Fork 4
242 lines (237 loc) · 9.21 KB
/
pr.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: PR build
on:
pull_request:
types:
- ready_for_review
paths:
- src/**
- reports/**
workflow_dispatch:
inputs:
force_build:
default: false
required: false
type: boolean
description: Bypass code changed check
env:
Solution_Directory: src\AnalyticsEngine\
Build_Platform: Any CPU
Build_ProcessorArchitecture: x86
ClientID: ${{ secrets.APP_CLIENTID }}
ClientSecret: ${{ secrets.APP_CLIENTSECRET }}
TenantGUID: ${{ secrets.APP_TENANTGUID }}
TenantDomain: ${{ secrets.APP_TENANTDOMAIN }}
CognitiveEndpoint: ${{ secrets.APP_COGNITIVEENDPOINT }}
CognitiveKey: ${{ secrets.APP_COGNITIVEKEY}}
CosmosDbTestContainerCurrent: stats
CosmosDbTestContainerHistory: history
CosmosDbTestDatabaseName: UnitTestDevOps
CosmosDb: ${{ secrets.APP_COSMOSDB }}
redis: ${{ secrets.CONNECTIONSTRINGS_REDIS }}
ServiceBus: ${{ secrets.CONNECTIONSTRINGS_SERVICEBUS }}
Storage: ${{ secrets.CONNECTIONSTRINGS_STORAGE }}
SoftwareDownloadURL: ${{ secrets.SOFTWAREDOWNLOADURL }}
StatsApiSecret: ${{ secrets.STATSAPISECRET }}
StatsApiUrl: ${{ secrets.STATSAPIURL }}
jobs:
setup_build:
# This step will calculate the build number with an offset
# so that build numbers will follow the ones from Azure DevOps.
# It will also check that the important folders have been updated.
runs-on: ubuntu-latest
outputs:
code_changed: ${{ inputs.force_build || steps.changes.outputs.code == 'true' }}
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Check if code has been modified so a build is needed
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
code:
- 'src/**'
- 'reports/**'
build_dotnet:
# Preparation:
# - Transform configuration files
# - Restore dependencies
# Build:
# - Build .Net projects
# Output:
# - Clean .Net builds
# - Copy PS scripts
# - Zip files
# - Publish artifacts
runs-on: windows-latest
needs: setup_build
if: needs.setup_build.outputs.code_changed == 'true'
strategy:
matrix:
configuration: [Release] # [Debug, Release]
env:
BuildId: ${{ github.run_number }}
BuildLabel: PR ${{ github.run_number }}
steps:
- name: Prepare build
id: prep
shell: bash
run: |
mkdir -p "${{ env.Zips_Folder }}"
echo "ZIPS_FOLDER=${{ env.Zips_Folder }}" >> "$GITHUB_OUTPUT"
env:
Zips_Folder: ${{ runner.temp }}/zips/
- name: Checkout source
uses: actions/checkout@v4
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Cache NuGet Packages
id: nuget-packages
uses: actions/cache@v4
env:
cache-name: nuget-package-cache
with:
path: ~\.nuget\packages
key: ${{ runner.os }}-${{ env.cache-name }}
# Configuration files
- name: Year substitution
shell: bash
run: |
year=$(date +%Y)
find ./src -name AssemblyInfo.cs | xargs sed -i "s/© __year__/© $year/"
- name: Config substitutions
uses: devops-actions/[email protected]
with:
files: '${{ env.Solution_Directory }}\*\App.Release.config, ${{ env.Solution_Directory }}\Web\Web.Release.config'
- name: Restore the application
run: msbuild ${{ env.Solution_Directory }} -t:Restore `
-p:Configuration=${{ env.Configuration }} `
-p:Platform="${{ env.Build_Platform }}" `
-p:ProcessorArchitecture=${{ env.Build_ProcessorArchitecture }}
env:
Configuration: ${{ matrix.configuration }}
# Projects building
- name: Build WebJob.AppInsightsImporter
run: msbuild ${{ env.Solution_Directory }}\WebJob.AppInsightsImporter\WebJob.AppInsightsImporter.csproj `
-p:Configuration=${{ env.Configuration }} `
-p:Platform="${{ env.Build_Platform }}" `
-p:ProcessorArchitecture=${{ env.Build_ProcessorArchitecture }} `
-p:OutDir=${{ runner.temp }}\AppInsightsImporter `
-p:OutputPath=${{ env.Configuration }} `
-p:AllowedReferenceRelatedFileExtensions=none `
-p:EmitCompilerGeneratedFiles=false
env:
Configuration: ${{ matrix.configuration }}
- name: Archive AppInsightsImporter
run: |
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue "${{ runner.temp }}\AppInsightsImporter\_PublishedWebsites"
Compress-Archive -Force -Path "${{ runner.temp }}\AppInsightsImporter" `
-DestinationPath "${{ env.folder }}\AppInsightsImporter.zip"
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}
- name: Build WebJob.Office365ActivityImporter
run: |
msbuild ${{ env.Solution_Directory }}\WebJob.Office365ActivityImporter\WebJob.Office365ActivityImporter.csproj `
-p:Configuration=${{ env.Configuration }} `
-p:Platform="${{ env.Build_Platform }}" `
-p:ProcessorArchitecture=${{ env.Build_ProcessorArchitecture }} `
-p:OutDir=${{ runner.temp }}\Office365ActivityImporter `
-p:OutputPath=${{ env.Configuration }} `
-p:AllowedReferenceRelatedFileExtensions=none `
-p:EmitCompilerGeneratedFiles=false
env:
Configuration: ${{ matrix.configuration }}
- name: Copy Automation scripts
run: |
Copy-Item -Verbose -Force -Recurse `
-Path "src/AnalyticsEngine/WebJob.Office365ActivityImporter/AutomationPS" `
-Destination "${{ runner.temp }}\Office365ActivityImporter\"
- name: Archive Office365ActivityImporter
run: |
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue `
"${{ runner.temp }}\Office365ActivityImporter\_PublishedWebsites"
Compress-Archive -Force -Path "${{ runner.temp }}\Office365ActivityImporter" `
-DestinationPath "${{ env.folder }}\Office365ActivityImporter.zip"
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}
- name: Build Website
run: msbuild ${{ env.Solution_Directory }}\Web\Web.csproj `
-p:Configuration=${{ env.Configuration }} `
-p:Platform="${{ env.Build_Platform }}" `
-p:ProcessorArchitecture=${{ env.Build_ProcessorArchitecture }} `
-p:OutDir=${{ runner.temp }}\Website `
-p:OutputPath=${{ env.Configuration }} `
-p:AllowedReferenceRelatedFileExtensions=none `
-p:EmitCompilerGeneratedFiles=false
env:
Configuration: ${{ matrix.configuration }}
- name: Archive Website
run: |
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue `
"${{ runner.temp }}\Website\_PublishedWebsites\Web\bin\Scripts"
Compress-Archive -Force -Path "${{ runner.temp }}\Website\_PublishedWebsites\Web" `
-DestinationPath "${{ env.folder }}\Website.zip"
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}
- name: Build Installer
run: |
msbuild ${{ env.Solution_Directory }}\App.ControlPanel\App.ControlPanel.WinForms.csproj `
-p:Configuration=${{ env.Configuration }} `
-p:Platform="${{ env.Build_Platform }}" `
-p:ProcessorArchitecture=${{ env.Build_ProcessorArchitecture }} `
-p:OutDir=${{ runner.temp }}\ControlPanelApp `
-p:OutputPath=${{ env.Configuration }} `
-p:AllowedReferenceRelatedFileExtensions=none `
-p:EmitCompilerGeneratedFiles=false
env:
Configuration: ${{ matrix.configuration }}
- name: Archive ControlPanelApp
run: Compress-Archive -Force -Path "${{ runner.temp }}\ControlPanelApp" `
-DestinationPath "${{ env.folder }}\ControlPanelApp.zip"
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}
- name: Archive Reports
run: |
Get-ChildItem '.\reports\Usage Analytics\*' `
-Exclude "*_base.pbit" -Include "*.pbit","Readme.txt" | Compress-Archive `
-Force -DestinationPath "${{ env.folder }}\Analytics_Reports.zip"
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}
# Wrap up
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ env.folder }}
name: drop_dotnet
if-no-files-found: error
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}
build_aitracker:
# NPM ai tracker
# Build:
# - Build AI Tracker
# Output:
# - Clean AI Tracker
# - Zip files
# - Publish artifacts
runs-on: ubuntu-latest
needs: setup_build
if: needs.setup_build.outputs.code_changed == 'true'
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Build AITracker
run: |
cd src/SPO/AITracker/TypeScript
npm ci
npm run build
cd ../..
rm -rf AITracker/TypeScript
zip -r AITrackerInstaller.zip AITracker
# Wrap up
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: src/SPO/AITrackerInstaller.zip
name: drop_aitracker
if-no-files-found: error