Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Devops] Feature/221 add openapi linting #243

Merged
merged 21 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .github/workflows/azure-dev-build-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

permissions:
id-token: write
contents: read
contents: write
issues: write
pull-requests: write

Expand Down Expand Up @@ -43,6 +43,11 @@ jobs:
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: |
Expand All @@ -53,6 +58,30 @@ jobs:
run: |
dotnet build

- name: Create openapi.json
shell: pwsh
run: |
$fileContent = Get-Content './src/AzureOpenAIProxy.ApiApp/Constants.cs'
$API_VERSION = [regex]::Match($fileContent, 'public const string Version = "([^"]+)"').Groups[1].Value

$PROCESS = Start-Process -FilePath "dotnet" -ArgumentList "run --project src/AzureOpenAIProxy.AppHost" -PassThru

Start-Sleep -Seconds 30

Invoke-WebRequest -Uri "https://localhost:7001/swagger/$API_VERSION/swagger.json" -OutFile "openapi.json"

$PROCESS.Kill()

- name: Lint OpenAPI doc
shell: pwsh
run: |
$LINT_RESULT = spectral lint -f json -F warn -D openapi.json

if( $LINT_RESULT.Count -ge 1) {
$LINT_RESULT
exit 1
}

- name: Install playwright
shell: pwsh
run: |
Expand Down
35 changes: 34 additions & 1 deletion .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

permissions:
id-token: write
contents: read
contents: write

jobs:
build-test-deploy:
Expand Down Expand Up @@ -56,6 +56,11 @@ jobs:
$appsettings.Azure.KeyVault.VaultUri = "${{ env.AZURE_KEYVAULT_URI }}"
$appsettings.Azure.KeyVault.SecretName = "${{ env.AZURE_KEYVAULT_SECRET_NAME }}"
$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
Expand All @@ -67,6 +72,34 @@ jobs:
run: |
dotnet build -c Release

- name: Create openapi.json
shell: pwsh
run: |
$fileContent = Get-Content './src/AzureOpenAIProxy.ApiApp/Constants.cs'
$API_VERSION = [regex]::Match($fileContent, 'public const string Version = "([^"]+)"').Groups[1].Value

$PROCESS = Start-Process -FilePath "dotnet" -ArgumentList "run --project src/AzureOpenAIProxy.AppHost" -PassThru

Start-Sleep -Seconds 30

Remove-Item -Path "openapi.json" -Force

Invoke-WebRequest -Uri "https://localhost:7001/swagger/$API_VERSION/swagger.json" -OutFile "openapi.json"

$PROCESS.Kill()

- name: Lint OpenAPI doc
shell: pwsh
run: |
$LINT_RESULT = spectral lint -f json -F warn -D openapi.json

if( $LINT_RESULT.Count -ge 1) {
$LINT_RESULT
exit 1
}

- name: Test solution

- name: Install playwright
shell: pwsh
run: |
Expand Down
Loading