-
Notifications
You must be signed in to change notification settings - Fork 17
151 lines (124 loc) · 4.75 KB
/
azure-dev.yml
File metadata and controls
151 lines (124 loc) · 4.75 KB
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
name: Azure Dev
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- '.github/**'
permissions:
id-token: write
contents: read
jobs:
build-test-deploy:
runs-on: ubuntu-latest
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
AZURE_OPENAI_KEYS: ${{ secrets.AZURE_OPENAI_KEYS }}
AZURE_KEYVAULT_URI: ${{ secrets.AZURE_KEYVAULT_URI }}
AZURE_KEYVAULT_SECRET_NAME_OPENAI: ${{ vars.AZURE_KEYVAULT_SECRET_NAME_OPENAI }}
AZURE_KEYVAULT_SECRET_NAME_STORAGE: ${{ vars.AZURE_KEYVAULT_SECRET_NAME_STORAGE }}
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: Update appsettings.json for API app
shell: pwsh
run: |
$appsettings = Get-Content -Path "./src/AzureOpenAIProxy.ApiApp/appsettings.json" -Raw | ConvertFrom-Json
$appsettings.Azure.OpenAI.Instances = @()
$appsettings.Azure.KeyVault.VaultUri = "${{ env.AZURE_KEYVAULT_URI }}"
$appsettings.Azure.KeyVault.SecretNames.OpenAI = "${{ env.AZURE_KEYVAULT_SECRET_NAME_OPENAI }}"
$appsettings.Azure.KeyVault.SecretNames.Storage = "${{ env.AZURE_KEYVAULT_SECRET_NAME_STORAGE }}"
$appsettings | ConvertTo-Json -Depth 100 | Set-Content -Path "./src/AzureOpenAIProxy.ApiApp/appsettings.json" -Encoding UTF8 -Force
- 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 -c Release
- 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 -c Release --no-build --logger "trx" --collect:"XPlat Code Coverage"
dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests -c Release --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 -c Release --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
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: false
- name: Install azd
uses: Azure/setup-azd@v1.0.0
- name: Log in with Azure (Federated Credentials)
if: env.AZURE_CLIENT_ID != ''
run: |
azd auth login `
--client-id "$Env:AZURE_CLIENT_ID" `
--federated-credential-provider "github" `
--tenant-id "$Env:AZURE_TENANT_ID"
shell: pwsh
- name: Provision Infrastructure
run: azd provision --no-prompt
env:
AZD_INITIAL_ENVIRONMENT_CONFIG: ${{ secrets.AZD_INITIAL_ENVIRONMENT_CONFIG }}
- name: Deploy Application
run: azd deploy --no-prompt