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

Metadata changes detection #2726

Merged
merged 18 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .azure-pipelines/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
git submodule update --init --recursive
- template: ./common-templates/install-tools.yml
- template: ./common-templates/security-pre-checks.yml

- template: ./generation-templates/authentication-module.yml
parameters:
Test: ${{ parameters.Test }}
Expand Down
18 changes: 18 additions & 0 deletions .azure-pipelines/common-templates/download-openapi-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ steps:
script: |
. "$(System.DefaultWorkingDirectory)\tools\Versions\BumpModuleVersion.ps1" -BumpV1Module -BumpBetaModule -BumpAuthModule -Debug

- task: PowerShell@2
name: BuildOpenApiMetadataDetectionTool
displayName: Build tool for detecting metadata changes
inputs:
pwsh: true
targetType: inline
script: dotnet build --configuration Release
workingDirectory: "$(System.DefaultWorkingDirectory)/tools/OpenApiInfoGenerator/OpenApiInfoGenerator"

- task: PowerShell@2
name: GenerateOpenApiErrorAndInfoFiles
displayName: Generate OpenApi error and info file for detecting unnecessary changes that would lead to a breaking change
inputs:
pwsh: true
targetType: inline
script: dotnet run
workingDirectory: "$(System.DefaultWorkingDirectory)/tools/OpenApiInfoGenerator/OpenApiInfoGenerator"

- task: Bash@3
displayName: Commit downloaded files
condition: and(succeeded(), ne(variables['OpenAPIDocDiff.ModulesWithChanges'], ''))
Expand Down
6 changes: 6 additions & 0 deletions .azure-pipelines/common-templates/install-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ steps:
inputs:
debugMode: false
version: 7.x

- task: UseDotNet@2
displayName: Use .NET SDK
inputs:
debugMode: false
version: 8.x

- task: NuGetToolInstaller@1
displayName: Install Nuget
Expand Down
10 changes: 10 additions & 0 deletions .azure-pipelines/generation-templates/check-openapi-errors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
steps:
- task: PowerShell@2
displayName: Check for OpenAPI Errors
inputs:
targetType: inline
pwsh: true
script: |
. $(System.DefaultWorkingDirectory)/tools/OpenApiInfoGenerator/OpenApiInfoGenerator/OpenApiChanges.ps1
55 changes: 55 additions & 0 deletions .github/workflows/metadatachanges.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# This is a basic workflow to help you get started with Actions

name: "Metadata Changes"
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- dev

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
CheckForMetadataChanges:
# The type of runner that the job will run on
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action != 'closed')
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}


# Check if error report exists
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@v3
with:
files: "docs/OpenApiInfo/v1.0/openAPIErrors.csv"

# If it exists then add a warning to comment section of the PR
- name: File exists
if: steps.check_files.outputs.files_exists == 'true'
uses: actions/github-script@v7
with:
script: |
const name = 'OpenApiChecks';
const body = '**Changes in metadata detected :bangbang:** :warning:\n Please have a look at the metadata changes report in `docs/OpenApiInfo/v1.0/openAPIErrors.csv`\nThis action is important before merging :pleading_face:';

await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})

# [0] https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
# [1] https://hub.github.com/hub-pull-request.1.html
# https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
Loading
Loading