Skip to content

Commit df5fc1e

Browse files
committed
Merge branch 'vnext' into release/2.0.0
2 parents 76effe4 + cec201b commit df5fc1e

File tree

87 files changed

+2463
-476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2463
-476
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ stages:
3131
- job: build
3232
steps:
3333
- task: UseDotNet@2
34-
displayName: 'Use .NET 6'
34+
displayName: 'Use .NET 2' # needed for ESRP signing
3535
inputs:
36-
version: 6.x
36+
version: 2.x
37+
38+
- task: UseDotNet@2
39+
displayName: 'Use .NET 7'
40+
inputs:
41+
version: 7.x
3742

3843
- task: PoliCheck@1
3944
displayName: 'Run PoliCheck "/src"'

.github/workflows/ci-cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup .NET
1717
uses: actions/setup-dotnet@v3
1818
with:
19-
dotnet-version: 6.0.x
19+
dotnet-version: 7.0.x
2020

2121
- name: Data gatherer
2222
id: data_gatherer
@@ -49,7 +49,7 @@ jobs:
4949
- if: steps.conditionals_handler.outputs.is_default_branch == 'true'
5050
name: Bump GH tag
5151
id: tag_generator
52-
uses: mathieudutour/github-tag-action@v6.0
52+
uses: mathieudutour/github-tag-action@v6.1
5353
with:
5454
github_token: ${{ secrets.GITHUB_TOKEN }}
5555
default_bump: false

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup .NET
2020
uses: actions/setup-dotnet@v3
2121
with:
22-
dotnet-version: 6.0.x
22+
dotnet-version: 7.0.x
2323

2424
- name: Initialize CodeQL
2525
id: init_codeql

.github/workflows/docker.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
paths: ['src/Microsoft.OpenApi.Hidi/**', '.github/workflows/**']
77
env:
88
REGISTRY: msgraphprod.azurecr.io
9-
IMAGE_NAME: public/hidi
9+
IMAGE_NAME: public/openapi/hidi
1010
jobs:
1111
push_to_registry:
1212
environment:
@@ -17,7 +17,7 @@ jobs:
1717
- name: Check out the repo
1818
uses: actions/checkout@v3
1919
- name: Login to GitHub package feed
20-
uses: docker/login-action@v2.0.0
20+
uses: docker/login-action@v2.1.0
2121
with:
2222
username: ${{ secrets.ACR_USERNAME }}
2323
password: ${{ secrets.ACR_PASSWORD }}
@@ -30,13 +30,13 @@ jobs:
3030
id: getversion
3131
- name: Push to GitHub Packages - Nightly
3232
if: ${{ github.ref == 'refs/heads/vnext' }}
33-
uses: docker/build-push-action@v3.1.1
33+
uses: docker/build-push-action@v4.0.0
3434
with:
3535
push: true
3636
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
3737
- name: Push to GitHub Packages - Release
3838
if: ${{ github.ref == 'refs/heads/master' }}
39-
uses: docker/build-push-action@v3.1.1
39+
uses: docker/build-push-action@v4.0.0
4040
with:
4141
push: true
4242
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}

.github/workflows/sonarcloud.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Sonarcloud
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore: ['.vscode/**']
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
paths-ignore: ['.vscode/**']
11+
12+
env:
13+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
14+
15+
jobs:
16+
checksecret:
17+
name: check if SONAR_TOKEN is set in github secrets
18+
runs-on: ubuntu-latest
19+
outputs:
20+
is_SONAR_TOKEN_set: ${{ steps.checksecret_job.outputs.is_SONAR_TOKEN_set }}
21+
steps:
22+
- name: Check whether unity activation requests should be done
23+
id: checksecret_job
24+
run: |
25+
echo "is_SONAR_TOKEN_set=${{ env.SONAR_TOKEN != '' }}" >> $GITHUB_OUTPUT
26+
build:
27+
needs: [checksecret]
28+
if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true'
29+
name: Build
30+
runs-on: windows-latest
31+
steps:
32+
- name: Set up JDK 11
33+
uses: actions/setup-java@v3
34+
with:
35+
distribution: 'adopt'
36+
java-version: 11
37+
- name: Setup .NET 5 # At the moment the scanner requires dotnet 5 https://www.nuget.org/packages/dotnet-sonarscanner
38+
uses: actions/setup-dotnet@v3
39+
with:
40+
dotnet-version: 5.0.x
41+
- name: Setup .NET
42+
uses: actions/setup-dotnet@v3
43+
with:
44+
dotnet-version: 7.0.x
45+
- uses: actions/checkout@v3
46+
with:
47+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
48+
- name: Cache SonarCloud packages
49+
uses: actions/cache@v3
50+
with:
51+
path: ~/.sonar/cache
52+
key: ${{ runner.os }}-sonar
53+
restore-keys: ${{ runner.os }}-sonar
54+
- name: Cache SonarCloud scanner
55+
id: cache-sonar-scanner
56+
uses: actions/cache@v3
57+
with:
58+
path: ./.sonar/scanner
59+
key: ${{ runner.os }}-sonar-scanner
60+
restore-keys: ${{ runner.os }}-sonar-scanner
61+
- name: Install SonarCloud scanner
62+
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
63+
shell: pwsh
64+
run: |
65+
New-Item -Path ./.sonar/scanner -ItemType Directory
66+
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
67+
- name: Build and analyze
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
70+
CollectCoverage: true
71+
CoverletOutputFormat: 'opencover' # https://github.com/microsoft/vstest/issues/4014#issuecomment-1307913682
72+
shell: pwsh
73+
run: |
74+
./.sonar/scanner/dotnet-sonarscanner begin /k:"microsoft_OpenAPI.NET" /o:"microsoft" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="test/**/coverage.opencover.xml"
75+
dotnet workload restore
76+
dotnet build
77+
dotnet test Microsoft.OpenApi.sln --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
78+
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"request": "launch",
1111
"preLaunchTask": "build",
1212
// If you have changed target frameworks, make sure to update the program path.
13-
"program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net6.0/Microsoft.OpenApi.Hidi.dll",
13+
"program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net7.0/Microsoft.OpenApi.Hidi.dll",
1414
"args": [],
1515
"cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi",
1616
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
1+
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
22
WORKDIR /app
33

44
COPY ./src ./hidi/src
55
WORKDIR /app/hidi
66
RUN dotnet publish ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -c Release
77

8-
FROM mcr.microsoft.com/dotnet/runtime:6.0 as runtime
8+
FROM mcr.microsoft.com/dotnet/runtime:7.0 as runtime
99
WORKDIR /app
1010

11-
COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net6.0 ./
11+
COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net7.0 ./
1212

1313
VOLUME /app/output
1414
VOLUME /app/openapi.yml
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using System;
5+
using System.CommandLine;
6+
using System.CommandLine.Invocation;
7+
using System.IO;
8+
using System.Threading;
9+
using System.Threading.Tasks;
10+
using Microsoft.Extensions.Logging;
11+
12+
namespace Microsoft.OpenApi.Hidi.Handlers
13+
{
14+
internal class ShowCommandHandler : ICommandHandler
15+
{
16+
public Option<string> DescriptionOption { get; set; }
17+
public Option<FileInfo> OutputOption { get; set; }
18+
public Option<LogLevel> LogLevelOption { get; set; }
19+
public Option<string> CsdlOption { get; set; }
20+
public Option<string> CsdlFilterOption { get; set; }
21+
22+
23+
public int Invoke(InvocationContext context)
24+
{
25+
return InvokeAsync(context).GetAwaiter().GetResult();
26+
}
27+
public async Task<int> InvokeAsync(InvocationContext context)
28+
{
29+
string openapi = context.ParseResult.GetValueForOption(DescriptionOption);
30+
FileInfo output = context.ParseResult.GetValueForOption(OutputOption);
31+
LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption);
32+
string csdlFilter = context.ParseResult.GetValueForOption(CsdlFilterOption);
33+
string csdl = context.ParseResult.GetValueForOption(CsdlOption);
34+
CancellationToken cancellationToken = (CancellationToken)context.BindingContext.GetService(typeof(CancellationToken));
35+
36+
using var loggerFactory = Logger.ConfigureLogger(logLevel);
37+
var logger = loggerFactory.CreateLogger<OpenApiService>();
38+
try
39+
{
40+
await OpenApiService.ShowOpenApiDocument(openapi, csdl, csdlFilter, output, logger, cancellationToken);
41+
42+
return 0;
43+
}
44+
catch (Exception ex)
45+
{
46+
#if DEBUG
47+
logger.LogCritical(ex, ex.Message);
48+
throw; // so debug tools go straight to the source of the exception when attached
49+
#else
50+
logger.LogCritical( ex.Message);
51+
return 1;
52+
#endif
53+
}
54+
}
55+
}
56+
}

src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ internal class TransformCommandHandler : ICommandHandler
1919
public Option<FileInfo> OutputOption { get; set; }
2020
public Option<bool> CleanOutputOption { get; set; }
2121
public Option<string?> VersionOption { get; set; }
22+
public Option<string?> MetadataVersionOption { get; set; }
2223
public Option<OpenApiFormat?> FormatOption { get; set; }
2324
public Option<bool> TerseOutputOption { get; set; }
25+
public Option<string> SettingsFileOption { get; set; }
2426
public Option<LogLevel> LogLevelOption { get; set; }
2527
public Option<string> FilterByOperationIdsOption { get; set; }
2628
public Option<string> FilterByTagsOption { get; set; }
@@ -40,21 +42,24 @@ public async Task<int> InvokeAsync(InvocationContext context)
4042
FileInfo output = context.ParseResult.GetValueForOption(OutputOption);
4143
bool cleanOutput = context.ParseResult.GetValueForOption(CleanOutputOption);
4244
string? version = context.ParseResult.GetValueForOption(VersionOption);
45+
string metadataVersion = context.ParseResult.GetValueForOption(MetadataVersionOption);
4346
OpenApiFormat? format = context.ParseResult.GetValueForOption(FormatOption);
4447
bool terseOutput = context.ParseResult.GetValueForOption(TerseOutputOption);
48+
string settingsFile = context.ParseResult.GetValueForOption(SettingsFileOption);
4549
LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption);
4650
bool inlineLocal = context.ParseResult.GetValueForOption(InlineLocalOption);
4751
bool inlineExternal = context.ParseResult.GetValueForOption(InlineExternalOption);
4852
string filterbyoperationids = context.ParseResult.GetValueForOption(FilterByOperationIdsOption);
4953
string filterbytags = context.ParseResult.GetValueForOption(FilterByTagsOption);
5054
string filterbycollection = context.ParseResult.GetValueForOption(FilterByCollectionOption);
55+
5156
CancellationToken cancellationToken = (CancellationToken)context.BindingContext.GetService(typeof(CancellationToken));
5257

5358
using var loggerFactory = Logger.ConfigureLogger(logLevel);
5459
var logger = loggerFactory.CreateLogger<OpenApiService>();
5560
try
5661
{
57-
await OpenApiService.TransformOpenApiDocument(openapi, csdl, csdlFilter, output, cleanOutput, version, format, terseOutput, logLevel, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, cancellationToken);
62+
await OpenApiService.TransformOpenApiDocument(openapi, csdl, csdlFilter, output, cleanOutput, version, metadataVersion, format, terseOutput, settingsFile, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, logger, cancellationToken);
5863

5964
return 0;
6065
}

src/Microsoft.OpenApi.Hidi/Handlers/ValidateCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
3030
var logger = loggerFactory.CreateLogger<OpenApiService>();
3131
try
3232
{
33-
await OpenApiService.ValidateOpenApiDocument(openapi, logLevel, cancellationToken);
33+
await OpenApiService.ValidateOpenApiDocument(openapi, logger, cancellationToken);
3434
return 0;
3535
}
3636
catch (Exception ex)

0 commit comments

Comments
 (0)