Skip to content

Commit b5f0d8d

Browse files
authored
Merge pull request #2726 from microsoftgraph/metadata-changes-detection
Metadata changes detection
2 parents 6696333 + 8aadcb4 commit b5f0d8d

File tree

14 files changed

+914796
-1
lines changed

14 files changed

+914796
-1
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
git submodule update --init --recursive
4343
- template: ./common-templates/install-tools.yml
4444
- template: ./common-templates/security-pre-checks.yml
45-
45+
4646
- template: ./generation-templates/authentication-module.yml
4747
parameters:
4848
Test: ${{ parameters.Test }}

.azure-pipelines/common-templates/download-openapi-docs.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@ steps:
9292
script: |
9393
. "$(System.DefaultWorkingDirectory)\tools\Versions\BumpModuleVersion.ps1" -BumpV1Module -BumpBetaModule -BumpAuthModule -Debug
9494
95+
- task: PowerShell@2
96+
name: BuildOpenApiMetadataDetectionTool
97+
displayName: Build tool for detecting metadata changes
98+
inputs:
99+
pwsh: true
100+
targetType: inline
101+
script: dotnet build --configuration Release
102+
workingDirectory: "$(System.DefaultWorkingDirectory)/tools/OpenApiInfoGenerator/OpenApiInfoGenerator"
103+
104+
- task: PowerShell@2
105+
name: GenerateOpenApiErrorAndInfoFiles
106+
displayName: Generate OpenApi error and info file for detecting unnecessary changes that would lead to a breaking change
107+
inputs:
108+
pwsh: true
109+
targetType: inline
110+
script: dotnet run
111+
workingDirectory: "$(System.DefaultWorkingDirectory)/tools/OpenApiInfoGenerator/OpenApiInfoGenerator"
112+
95113
- task: Bash@3
96114
displayName: Commit downloaded files
97115
condition: and(succeeded(), ne(variables['OpenAPIDocDiff.ModulesWithChanges'], ''))

.azure-pipelines/common-templates/install-tools.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ steps:
1212
inputs:
1313
debugMode: false
1414
version: 7.x
15+
16+
- task: UseDotNet@2
17+
displayName: Use .NET SDK
18+
inputs:
19+
debugMode: false
20+
version: 8.x
1521

1622
- task: NuGetToolInstaller@1
1723
displayName: Install Nuget
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
steps:
4+
- task: PowerShell@2
5+
displayName: Check for OpenAPI Errors
6+
inputs:
7+
targetType: inline
8+
pwsh: true
9+
script: |
10+
. $(System.DefaultWorkingDirectory)/tools/OpenApiInfoGenerator/OpenApiInfoGenerator/OpenApiChanges.ps1
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
# This is a basic workflow to help you get started with Actions
4+
5+
name: "Metadata Changes"
6+
# Controls when the action will run. Triggers the workflow on push or pull request
7+
# events but only for the master branch
8+
on:
9+
workflow_dispatch:
10+
pull_request:
11+
types: [opened, synchronize, reopened, closed]
12+
branches:
13+
- dev
14+
15+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
16+
jobs:
17+
CheckForMetadataChanges:
18+
# The type of runner that the job will run on
19+
runs-on: ubuntu-latest
20+
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action != 'closed')
21+
# Steps represent a sequence of tasks that will be executed as part of the job
22+
steps:
23+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.event.pull_request.head.sha }}
28+
29+
30+
# Check if error report exists
31+
- name: Check file existence
32+
id: check_files
33+
uses: andstor/file-existence-action@v3
34+
with:
35+
files: "docs/OpenApiInfo/v1.0/openAPIErrors.csv"
36+
37+
# If it exists then add a warning to comment section of the PR
38+
- name: File exists
39+
if: steps.check_files.outputs.files_exists == 'true'
40+
uses: actions/github-script@v7
41+
with:
42+
script: |
43+
const name = 'OpenApiChecks';
44+
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:';
45+
46+
await github.rest.issues.createComment({
47+
issue_number: context.issue.number,
48+
owner: context.repo.owner,
49+
repo: context.repo.repo,
50+
body: body
51+
})
52+
53+
# [0] https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
54+
# [1] https://hub.github.com/hub-pull-request.1.html
55+
# https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token

0 commit comments

Comments
 (0)