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

pipelines alignment #184

Merged
merged 15 commits into from
Feb 25, 2022
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
238 changes: 238 additions & 0 deletions .azure-pipelines/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)

trigger:
branches:
include:
- master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenAPI.NET uses vnext branch as a default branch before master. We may want to have this flow in this repo as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if we aligned all of them on main like the other repos we have at a later date if you don't mind?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as is will mean all merges to master will do a release. And this is the main branch for this repo.

pr: none

pool:
name: Azure Pipelines
vmImage: windows-latest
demands:
- msbuild
- vstest

variables:
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
ProductBinPath: '$(Build.SourcesDirectory)\bin\$(BuildConfiguration)'


stages:

- stage: build
jobs:
- job: build
steps:

- task: UseDotNet@2
displayName: 'Use .NET 6'
inputs:
version: 6.x

- task: PoliCheck@1
displayName: 'Run PoliCheck "/src"'
inputs:
inputType: CmdLine
cmdLineArgs: '/F:$(Build.SourcesDirectory)/src /T:9 /Sev:"1|2" /PE:2 /O:poli_result_src.xml'

- task: PoliCheck@1
displayName: 'Run PoliCheck "/test"'
inputs:
inputType: CmdLine
cmdLineArgs: '/F:$(Build.SourcesDirectory)/test /T:9 /Sev:"1|2" /PE:2 /O:poli_result_test.xml'

- task: PoliCheck@1
displayName: 'PoliCheck for /tool'
inputs:
inputType: CmdLine
cmdLineArgs: '/F:$(Build.SourcesDirectory)/tool /T:9 /Sev:"1|2" /PE:2 /O:poli_result_tool.xml'

# Install the nuget tool.
- task: NuGetToolInstaller@0
displayName: 'Use NuGet >=5.2.0'
inputs:
versionSpec: '>=5.2.0'
checkLatest: true

# Build the Product project
- task: DotNetCoreCLI@2
displayName: 'build'
inputs:
projects: '$(Build.SourcesDirectory)\Microsoft.OpenApi.OData.sln'
arguments: '--configuration $(BuildConfiguration) --no-incremental'

# Run the Unit test
- task: DotNetCoreCLI@2
displayName: 'test'
inputs:
command: test
projects: '$(Build.SourcesDirectory)\Microsoft.OpenApi.OData.sln'
arguments: '--configuration $(BuildConfiguration) --no-build'

# CredScan
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
displayName: 'Run CredScan - Src'
inputs:
toolMajorVersion: 'V2'
scanFolder: '$(Build.SourcesDirectory)\src'
debugMode: false

- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
displayName: 'Run CredScan - Test'
inputs:
toolMajorVersion: 'V2'
scanFolder: '$(Build.SourcesDirectory)\test'
debugMode: false

- task: AntiMalware@3
displayName: 'Run MpCmdRun.exe - ProductBinPath'
inputs:
FileDirPath: '$(ProductBinPath)'
enabled: false

- task: BinSkim@3
displayName: 'Run BinSkim - Product Binaries'
inputs:
InputType: Basic
AnalyzeTarget: '$(ProductBinPath)\**\Microsoft.OpenApi.OData.Reader.dll'
AnalyzeSymPath: '$(ProductBinPath)'
AnalyzeVerbose: true
AnalyzeHashes: true
AnalyzeEnvironment: true

- task: PublishSecurityAnalysisLogs@2
displayName: 'Publish Security Analysis Logs'
inputs:
ArtifactName: SecurityLogs

- task: PostAnalysis@1
displayName: 'Post Analysis'
inputs:
BinSkim: true
CredScan: true
PoliCheck: true

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: 'ESRP CodeSigning'
inputs:
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
FolderPath: src
signConfigType: inlineSignParams
inlineOperation: |
[
{
"keyCode": "CP-230012",
"operationSetCode": "SigntoolSign",
"parameters": [
{
"parameterName": "OpusName",
"parameterValue": "Microsoft"
},
{
"parameterName": "OpusInfo",
"parameterValue": "http://www.microsoft.com"
},
{
"parameterName": "FileDigest",
"parameterValue": "/fd \"SHA256\""
},
{
"parameterName": "PageHash",
"parameterValue": "/NPH"
},
{
"parameterName": "TimeStamp",
"parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
}
],
"toolName": "sign",
"toolVersion": "1.0"
},
{
"keyCode": "CP-230012",
"operationSetCode": "SigntoolVerify",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
}
]
SessionTimeout: 20

# Pack
- task: DotNetCoreCLI@2
displayName: 'pack'
inputs:
command: pack
projects: src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj
arguments: '-o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg'

- task: PowerShell@2
displayName: 'Validate project version has been incremented'
condition: and(contains(variables['build.sourceBranch'], 'refs/heads/master'), succeeded())
inputs:
targetType: 'filePath'
filePath: $(System.DefaultWorkingDirectory)\scripts\ValidateProjectVersionUpdated.ps1
arguments: '-projectVersion "$(VersionFullSemantic)"'

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: 'ESRP CodeSigning Nuget Packages'
inputs:
ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
FolderPath: '$(Build.ArtifactStagingDirectory)'
Pattern: '*.nupkg'
signConfigType: inlineSignParams
inlineOperation: |
[
{
"keyCode": "CP-401405",
"operationSetCode": "NuGetSign",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
},
{
"keyCode": "CP-401405",
"operationSetCode": "NuGetVerify",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
}
]
SessionTimeout: 20

- task: PublishPipelineArtifact@1
displayName: 'Upload Artifact: Nugets'
inputs:
artifactName: Nugets
targetPath: $(Build.ArtifactStagingDirectory)

- stage: deploy
condition: and(contains(variables['build.sourceBranch'], 'refs/heads/master'), succeeded())
dependsOn: build
jobs:
- deployment: deploy
environment: nuget-org
strategy:
runOnce:
deploy:
pool:
vmImage: ubuntu-latest
steps:
- task: DownloadPipelineArtifact@2
displayName: Download nupkg from artifacts
inputs:
artifact: Nugets
source: current
- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: push
packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.OData.*.nupkg'
nuGetFeedType: external
publishFeedCredentials: 'OpenAPI Nuget Connection'

Loading