forked from aliencube/azure-openai-sdk-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (110 loc) · 3.89 KB
/
azure-dev-build-only.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
name: Azure Dev - Build Only
on:
push:
branches:
- 'feature/*'
paths-ignore:
- '.github/**'
# pull_request_target:
pull_request:
branches:
- main
permissions:
id-token: write
contents: read
issues: write
pull-requests: write
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install local certs
shell: pwsh
run: |
dotnet tool update -g linux-dev-certs
dotnet linux-dev-certs install
- name: Install Aspire workload
shell: pwsh
run: |
dotnet workload update
dotnet workload install aspire
- name: Install Spectral Cli
shell: bash
run: |
curl -L https://raw.github.com/stoplightio/spectral/master/scripts/install.sh | sh
- name: Restore NuGet packages
shell: bash
run: |
dotnet restore
- name: Build solution
shell: bash
run: |
dotnet build
- name: Install playwright
shell: pwsh
run: |
$playwright = Get-ChildItem -File Microsoft.Playwright.dll -Path . -Recurse
$installer = "$($playwright[0].Directory.FullName)/playwright.ps1"
& "$installer" install
- name: Run unit tests
shell: bash
run: |
dotnet test ./test/AzureOpenAIProxy.AppHost.Tests --no-build --logger "trx" --collect:"XPlat Code Coverage"
dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests --no-build --logger "trx" --collect:"XPlat Code Coverage"
- name: Run integration tests
shell: bash
run: |
dotnet run --project ./src/AzureOpenAIProxy.AppHost &
sleep 30
dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests --no-build --logger "trx" --collect:"XPlat Code Coverage"
- name: Create openapi.json
shell: pwsh
run: |
$API_VERSION = $(Get-Content ./src/AzureOpenAIProxy.ApiApp/appsettings.json | ConvertFrom-Json).OpenApi.DocVersion
Invoke-WebRequest -Uri "https://localhost:7001/swagger/$API_VERSION/swagger.json" -OutFile "openapi.json"
- name: Lint OpenAPI doc
shell: pwsh
run: |
$LINT_RESULT = spectral lint -f json -F warn -D -q openapi.json | ConvertFrom-Json
if( $LINT_RESULT.Count -gt 0) {
$LINT_RESULT | ForEach-Object {
Write-Host ("code: " + $_.code)
Write-Host ("message: " + $_.message)
Write-Host ("path: " + $($_.path -join "."))
Write-Host "`n"
}
exit 1
}
- name: Publish test results
if: ${{ !cancelled() }}
id: test-report
uses: bibipkins/dotnet-test-reporter@main
with:
github-token: ${{ secrets.GH_PAT_GRAINED }}
results-path: ./**/TestResults/**/*.trx
# coverage-path: ./**/TestResults/**/*.xml
# coverage-type: cobertura
# coverage-threshold: 0
# coverage-threshold: 80
allow-failed-tests: true
post-new-comment: true
comment-title: "Test Results"
# - name: Comment to issue
# if: ${{ !cancelled() && (github.event_name == 'pull_request_target' || github.event_name == 'pull_request') }}
# uses: actions-cool/issues-helper@v3
# with:
# actions: "create-comment"
# token: ${{ secrets.GH_PAT_GRAINED }}
# issue-number: ${{ github.event.pull_request.number }}
# body: |
# ## Test Results
# ### Tests
# | :clipboard: Total | :heavy_check_mark: Passed | :x: Failed | :warning: Skipped |
# |-------------------|---------------------------|------------|-------------------|
# | ${{ steps.test-report.outputs.tests-total }} | ${{ steps.test-report.outputs.tests-passed }} | ${{ steps.test-report.outputs.tests-failed }} | ${{ steps.test-report.outputs.tests-skipped }} |