Skip to content

Add OpenAPI webhook model generation #10719

Add OpenAPI webhook model generation

Add OpenAPI webhook model generation #10719

name: idempotency-tests
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
merge_group:
concurrency:
# Only run once for latest commit per ref and cancel other (previous) runs.
group: ci-idempotency-tests-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- name: Restore dependencies
run: dotnet restore kiota.slnx
- name: Build
run: dotnet publish ./src/kiota/kiota.csproj -c Release -p:PublishSingleFile=true -p:PublishReadyToRun=true -o ./publish -f net10.0
# -p:PublishTrimmed=true -p:PublishAot=true should be enabled to make test run faster, but there are still limitations
- uses: actions/upload-artifact@v7
with:
name: generator
path: publish
download-openapi-specs:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
description:
- "oas::petstore"
- "https://api.twitter.com/2/openapi.json"
- "https://developers.notion.com/openapi.json"
- "https://raw.githubusercontent.com/stripe/openapi/refs/heads/master/latest/openapi.spec3.json"
- "https://raw.githubusercontent.com/googlemaps/openapi-specification/refs/tags/v1.22.5/dist/google-maps-platform-openapi3.yml"
- "https://raw.githubusercontent.com/meraki/openapi/refs/heads/master/openapi/spec3.json"
- "https://developers.pipedrive.com/docs/api/v1/openapi.yaml"
- "https://raw.githubusercontent.com/twilio/twilio-oai/refs/heads/main/spec/yaml/twilio_api_v2010.yaml"
- "https://raw.githubusercontent.com/docusign/OpenAPI-Specifications/refs/heads/master/esignature.rest.swagger-v2.1.json"
- "https://raw.githubusercontent.com/github/rest-api-description/refs/heads/main/descriptions/api.github.com/api.github.com.json"
- "apisguru::apis.guru"
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: generator
path: publish
- run: chmod a+x ./publish/kiota
- name: Download OpenAPI specs
run: ./it/download-openapi-specs.ps1 -descriptionUrl ${{ matrix.description }}
shell: pwsh
- id: replace_url
run: ./it/get-description-artifact-key.ps1 -descriptionUrl ${{ matrix.description }}
shell: pwsh
- uses: actions/upload-artifact@v7
with:
name: description-${{ steps.replace_url.outputs.ARTKEY }}
# Output is either openapi.json or openapi.yml. Try to upload the one that is found.
path: |
it/openapi.yaml
it/openapi.json
idempotency:
runs-on: ubuntu-latest
needs: download-openapi-specs
strategy:
fail-fast: false
matrix:
language:
- java
- csharp
- go
- typescript
- ruby
- php
- python
- dart
description:
- "./tests/Kiota.Builder.IntegrationTests/InheritingErrors.yaml"
- "./tests/Kiota.Builder.IntegrationTests/NoUnderscoresInModel.yaml"
- "oas::petstore"
- "https://api.twitter.com/2/openapi.json"
- "https://developers.notion.com/openapi.json"
- "https://raw.githubusercontent.com/stripe/openapi/refs/heads/master/latest/openapi.spec3.json"
- "https://raw.githubusercontent.com/googlemaps/openapi-specification/refs/tags/v1.22.5/dist/google-maps-platform-openapi3.yml"
- "https://raw.githubusercontent.com/meraki/openapi/refs/heads/master/openapi/spec3.json"
- "https://developers.pipedrive.com/docs/api/v1/openapi.yaml"
- "https://raw.githubusercontent.com/twilio/twilio-oai/refs/heads/main/spec/yaml/twilio_api_v2010.yaml"
- "https://raw.githubusercontent.com/docusign/OpenAPI-Specifications/refs/heads/master/esignature.rest.swagger-v2.1.json"
- "https://raw.githubusercontent.com/github/rest-api-description/refs/heads/main/descriptions/api.github.com/api.github.com.json"
- "apisguru::apis.guru"
steps:
- uses: actions/checkout@v7
- id: replace_url
run: ./it/get-description-artifact-key.ps1 -descriptionUrl ${{ matrix.description }}
shell: pwsh
- uses: actions/download-artifact@v8
if: startsWith(matrix.description, './') != true
with:
name: description-${{ steps.replace_url.outputs.ARTKEY }}
path: description
- uses: actions/download-artifact@v8
with:
name: generator
path: publish
- run: chmod a+x ./publish/kiota
- name: Check if test is suppressed
id: check-suppressed
run: |
$isSuppressed = . ./it/get-is-suppressed.ps1 -descriptionUrl ${{ matrix.description }} -language ${{ matrix.language }} -kind idempotency
Write-Output "IS_SUPPRESSED=$($isSuppressed.ToString().ToLowerInvariant())" >> $Env:GITHUB_OUTPUT
shell: pwsh
- name: Verify idempotency
shell: pwsh
run: ./it/compare-generation.ps1 -descriptionUrl "${{ steps.replace_url.outputs.DESCRIPTION_PATH }}" -descriptionKey ${{ matrix.description }} -language "${{ matrix.language }}"
continue-on-error: ${{ steps.check-suppressed.outputs.IS_SUPPRESSED == 'true' }}
- uses: actions/upload-artifact@v7
if: always()
with:
name: idempotency-${{ matrix.language }}-${{ steps.replace_url.outputs.ARTKEY }}
path: idempotency-results/*.zip
cleanup:
runs-on: ubuntu-latest
needs: idempotency
steps:
- uses: jimschubert/delete-artifacts-action@v1
with:
artifact_name: "generator"
min_bytes: "0"
# Aggregates result of the idempotency tests for use in branch policy
check-idempotency-tests:
runs-on: ubuntu-latest
needs: idempotency
if: always()
steps:
- name: All build matrix options are successful
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: One or more build matrix options failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1