-
Notifications
You must be signed in to change notification settings - Fork 4
113 lines (110 loc) · 3.68 KB
/
tests.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
name: tests
on:
push:
branches:
- main
- dev
pull_request:
types:
- ready_for_review
workflow_dispatch:
inputs:
force_run:
default: false
required: false
type: boolean
description: Bypass code changed check
env:
Solution_Directory: src\AnalyticsEngine\Tests.UnitTests
Build_Platform: anycpu
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 }}
jobs:
setup_tests:
# Will check that the interesting folders have been updated.
runs-on: ubuntu-latest
outputs:
code_changed: ${{ steps.changes.outputs.code == 'true' }}
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Check if the code has been modified so tests must be run
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
code:
- 'src/**'
unit_tests:
# Tests job
# Preparation:
# - Transform configuration files
# - Restore dependencies
# Build:
# - Build .Net projects
# Test:
# - Run test suite
runs-on: windows-latest
needs: setup_tests
if: inputs.force_run || needs.setup_tests.outputs.code_changed == 'true'
strategy:
matrix:
configuration: [Release] # [Debug, Release]
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Run AI Tracker tests
run: |
cd src/SPO/AITracker/TypeScript
npm ci
npm run test
- 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 }}
- name: Config substitution - Unit tests
uses: microsoft/variable-substitution@v1
with:
files: '${{ env.Solution_Directory }}\App.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 }}
- name: Build solution
run: msbuild ${{ env.Solution_Directory }} `
-p:Configuration=${{ env.Configuration }} `
-p:Platform=${{ env.Build_Platform }} `
-p:ProcessorArchitecture=${{ env.Build_ProcessorArchitecture }}
env:
Configuration: ${{ matrix.configuration }}
- name: Execute unit tests
uses: jesusfer/vstest-action@main
with:
testAssembly: Tests.UnitTests.dll
searchFolder: ${{ env.Solution_Directory }}\bin\${{ env.Configuration }}\
runInParallel: true
vstestLocationMethod: location
vstestLocation: C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\Extensions\\TestPlatform\\vstest.console.exe
env:
Configuration: ${{ matrix.configuration }}