From 7458534062a4c5186f3178d75cf7e0bb5a96674e Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Thu, 21 Sep 2023 10:36:41 +0100 Subject: [PATCH] Fix idempotency test results upload --- .github/workflows/idempotency-tests.yml | 114 ++++++++++++++++++++++++ .github/workflows/integration-tests.yml | 57 +----------- .gitignore | 2 +- it/compare-generation.ps1 | 20 ++--- 4 files changed, 126 insertions(+), 67 deletions(-) create mode 100644 .github/workflows/idempotency-tests.yml diff --git a/.github/workflows/idempotency-tests.yml b/.github/workflows/idempotency-tests.yml new file mode 100644 index 0000000000..b30b99ae29 --- /dev/null +++ b/.github/workflows/idempotency-tests.yml @@ -0,0 +1,114 @@ +name: idempotency-tests + +on: + workflow_dispatch: + push: + branches: [main] + paths-ignore: + [ + "abstractions/**", + "authentication/**", + "serialization/**", + "http/**", + "**.md", + ".vscode/**", + "**.svg", + ] + pull_request: + paths-ignore: + [ + "abstractions/**", + "authentication/**", + "serialization/**", + "http/**", + "**.md", + ".vscode/**", + "**.svg", + ] + +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@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + - name: Restore dependencies + run: dotnet restore kiota.sln + - name: Build + run: dotnet publish ./src/kiota/kiota.csproj -c Release -p:PublishSingleFile=true -p:PublishReadyToRun=true -o ./publish + # -p:PublishTrimmed=true -p:PublishAot=true should be enabled to make test run faster, but there are still limitations + - uses: actions/upload-artifact@v3 + with: + name: generator + path: publish + idempotency: + runs-on: ubuntu-latest + needs: build + strategy: + fail-fast: false + matrix: + language: + - java + - csharp + - go + - typescript + - ruby + - php + - python + description: + - "./tests/Kiota.Builder.IntegrationTests/InheritingErrors.yaml" + - "./tests/Kiota.Builder.IntegrationTests/NoUnderscoresInModel.yaml" + - "oas::petstore" + - "apisguru::twitter.com:current" + - "apisguru::notion.com" + - "apisguru::stripe.com" + - "https://raw.githubusercontent.com/googlemaps/openapi-specification/main/dist/google-maps-platform-openapi3.yml" + - "apisguru::meraki.com" + - "https://developers.pipedrive.com/docs/api/v1/openapi.yaml" + - "apisguru::twilio.com:api" + - "apisguru::docusign.net" + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v3 + 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 ${{ matrix.description }} -language ${{ matrix.language }} + continue-on-error: ${{ steps.check-suppressed.outputs.IS_SUPPRESSED == 'true' }} + - id: replace_url + if: always() + run: | + ORIGINAL="${{ matrix.description }}" + REPLACED="${ORIGINAL//[-:<>|\*\?\\\/\.]/_}" + echo "ARTKEY=$REPLACED" >> $GITHUB_OUTPUT + - uses: actions/upload-artifact@v3 + 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" diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 015a8d847f..c53e44ff15 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -154,64 +154,9 @@ jobs: name: generation-results-${{ matrix.language }}-${{ steps.replace_url.outputs.ARTKEY }} path: it/${{ matrix.language }}.zip - idempotency: - runs-on: ubuntu-latest - needs: build - strategy: - fail-fast: false - matrix: - language: - - java - - csharp - - go - - typescript - - ruby - - php - - python - description: - - "./tests/Kiota.Builder.IntegrationTests/InheritingErrors.yaml" - - "./tests/Kiota.Builder.IntegrationTests/NoUnderscoresInModel.yaml" - - "oas::petstore" - - "apisguru::twitter.com:current" - - "apisguru::notion.com" - - "apisguru::stripe.com" - - "https://raw.githubusercontent.com/googlemaps/openapi-specification/main/dist/google-maps-platform-openapi3.yml" - - "apisguru::meraki.com" - - "https://developers.pipedrive.com/docs/api/v1/openapi.yaml" - - "apisguru::twilio.com:api" - - "apisguru::docusign.net" - steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v3 - 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 ${{ matrix.description }} -language ${{ matrix.language }} - continue-on-error: ${{ steps.check-suppressed.outputs.IS_SUPPRESSED == 'true' }} - - id: replace_url - if: always() - run: | - ORIGINAL="${{ matrix.description }}" - REPLACED="${ORIGINAL//[-:<>|\*\?\\\/\.]/_}" - echo "ARTKEY=$REPLACED" >> $GITHUB_OUTPUT - - uses: actions/upload-artifact@v3 - if: always() - with: - name: idempotency-${{ matrix.language }}-${{ steps.replace_url.outputs.ARTKEY }} - path: idempotency-folder*.zip - cleanup: runs-on: ubuntu-latest - needs: [integration, idempotency] + needs: integration steps: - uses: jimschubert/delete-artifacts-action@v1 with: diff --git a/.gitignore b/.gitignore index 72291e08cb..92520e189d 100644 --- a/.gitignore +++ b/.gitignore @@ -449,4 +449,4 @@ reports/ samples/ it/openapi.yaml -idempotency*.zip +idempotency-results/ diff --git a/it/compare-generation.ps1 b/it/compare-generation.ps1 index c8c40cf710..ee202140a8 100755 --- a/it/compare-generation.ps1 +++ b/it/compare-generation.ps1 @@ -95,21 +95,21 @@ if ($HashString1 -eq $HashString2) { Exit 0 } else { - Write-Error "The content of the folders is NOT identical" - $archivePath1 = Join-Path $rootPath -ChildPath "idempotency-folder1.zip" - $archivePath2 = Join-Path $rootPath -ChildPath "idempotency-folder2.zip" + Write-Host "The content of the folders is NOT identical" + $resultsFolder = Join-Path -Path $rootPath -ChildPath "idempotency-results" + $archivePath1 = Join-Path $resultsFolder -ChildPath "idempotency-folder1.zip" + $archivePath2 = Join-Path $resultsFolder -ChildPath "idempotency-folder2.zip" - if (Test-Path $archivePath1) { - Remove-Item $archivePath1 -Force -Verbose - } - if (Test-Path $archivePath2) { - Remove-Item $archivePath2 -Force -Verbose + if (Test-Path $resultsFolder) { + Remove-Item $resultsFolder -Force -Verbose -Recurse } + New-Item -ItemType Directory -Path $resultsFolder -Force if ($dev -eq $false) { Write-Host "Creating archives at location $archivePath1 and $archivePath2" - Compress-Archive -Path $tmpFolder1 -DestinationPath $archivePath1 - Compress-Archive -Path $tmpFolder1 -DestinationPath $archivePath2 + Compress-Archive -Path $tmpFolder1 -DestinationPath $archivePath1 -Force + Compress-Archive -Path $tmpFolder2 -DestinationPath $archivePath2 -Force } + Write-Error "Comparison failed as the generated code is NOT identical" Exit 1 }