surface-area-tests #927
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: surface-area-tests | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| baselineVersion: | |
| description: "Specific Microsoft.OpenApi.Kiota version to use as the baseline (defaults to latest stable release)." | |
| required: false | |
| default: "" | |
| push: | |
| branches: [main] | |
| pull_request: | |
| merge_group: | |
| concurrency: | |
| # Only run once for latest commit per ref and cancel other (previous) runs. | |
| group: ci-surface-area-tests-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 | |
| 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 | |
| - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: generator | |
| path: publish | |
| surface-diff: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| language: | |
| - csharp | |
| - java | |
| description: | |
| - "https://github.com/microsoftgraph/msgraph-metadata/raw/refs/heads/master/openapi/beta/openapi.yaml" | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 | |
| with: | |
| dotnet-version: 10.0.x | |
| - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: generator | |
| path: publish | |
| - run: chmod a+x ./publish/kiota | |
| - name: Generate baseline & current DOM exports and diff | |
| id: compare | |
| shell: pwsh | |
| timeout-minutes: 30 | |
| run: | | |
| $patchFileName = "${{ matrix.language }}-dom-export.patch" | |
| $patchPath = Join-Path -Path (Get-Location) -ChildPath $patchFileName | |
| ./it/compare-dom-export.ps1 ` | |
| -descriptionUrl "${{ matrix.description }}" ` | |
| -language "${{ matrix.language }}" ` | |
| -patchPath $patchPath ` | |
| -baselineVersion "${{ github.event.inputs.baselineVersion }}" | |
| $hasPatch = (Test-Path $patchPath) -and ((Get-Item $patchPath).Length -gt 0) | |
| # The diff tool runs as a Docker container action with the repository mounted at | |
| # /github/workspace, so it must receive a workspace-relative path. Passing the | |
| # absolute host path fails inside the container with a DirectoryNotFoundException. | |
| Write-Output "patchFilePath=$patchFileName" >> $Env:GITHUB_OUTPUT | |
| Write-Output "hasPatch=$($hasPatch.ToString().ToLowerInvariant())" >> $Env:GITHUB_OUTPUT | |
| - name: Analyze DOM export diff for breaking changes | |
| id: diff | |
| if: ${{ steps.compare.outputs.hasPatch == 'true' }} | |
| # Pinned to a commit SHA for supply-chain safety. This tool is owned by the | |
| # Microsoft Graph Developer Experience team. | |
| uses: microsoftgraph/kiota-dom-export-diff-tool/tool@e32a993776c40f03dce8c55ff7a607ed21011945 | |
| with: | |
| path: ${{ steps.compare.outputs.patchFilePath }} | |
| fail-on-removal: true | |
| - name: Comment on the pull request | |
| if: ${{ always() && steps.compare.outputs.hasPatch == 'true' && steps.diff.outputs.hasExplanations != '' && github.event_name == 'pull_request' }} | |
| continue-on-error: true | |
| uses: microsoftgraph/kiota-dom-export-diff-tool/comment@e32a993776c40f03dce8c55ff7a607ed21011945 | |
| with: | |
| comment: ${{ steps.diff.outputs.explanationsFilePath }} | |
| prNumber: ${{ github.event.pull_request.number }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload patch file as artifact | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| continue-on-error: true | |
| with: | |
| name: surface-area-patch-${{ matrix.language }} | |
| path: "*.patch" | |
| - name: Upload explanations file as artifact | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| continue-on-error: true | |
| with: | |
| name: surface-area-explanations-${{ matrix.language }} | |
| path: "explanations.txt" | |
| cleanup: | |
| runs-on: ubuntu-latest | |
| needs: surface-diff | |
| if: always() | |
| steps: | |
| - uses: jimschubert/delete-artifacts-action@f5cb1978980f2e189a2b3484d430f8810860ba38 # v1.0.4 | |
| with: | |
| artifact_name: "generator" | |
| min_bytes: "0" | |
| # Aggregates result of the surface area tests for use in branch policy | |
| check-surface-area-tests: | |
| runs-on: ubuntu-latest | |
| needs: surface-diff | |
| 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 |