Skip to content

Commit

Permalink
Merge pull request #9 from kritikos-io/feature/devops
Browse files Browse the repository at this point in the history
Feature/devops
  • Loading branch information
akritikos authored Apr 6, 2021
2 parents a0e3a61 + ff5842a commit a5375ba
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .config
195 changes: 47 additions & 148 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ resources:
checkoutOptions:
submodules: true
lfs: true
- repository: templates
type: github
name: kritikos-io/.config
endpoint: kritikos-io

trigger:
batch: true
branches:
Expand All @@ -18,156 +23,50 @@ trigger:
- azure-pipelines.yml
- src/*
- tests/*

variables:
- group: Environment
- group: DotNet
- group: ApiKeys
- name: SONAR_PROJECT
value: kritikos-io_Configuration.Persistence
jobs:
- job: Version
pool:
vmImage: ubuntu-latest
steps:
- pwsh: dotnet tool install --tool-path .. gitversion.tool
displayName: Install GitVersion
- pwsh: |
echo "##vso[task.setvariable variable=gitVersion;isOutput=true]$(../dotnet-gitversion /output json /showvariable SemVer)"
"Current version: $(../dotnet-gitversion /output json /showvariable SemVer)"
displayName: Sets SemVer
name: versioning
- job: Build
pool:
vmImage: ubuntu-latest
dependsOn:
- Version
variables:
Version: $[ dependencies.Version.outputs['versioning.gitVersion'] ]
steps:
- checkout: self
fetchDepth: 1
- task: DotNetCoreCLI@2
displayName: Build Solution
inputs:
command: 'build'
configuration: $(BuildConfiguration)
arguments: '-o $(build.artifactStagingDirectory)/build'
versioningScheme: byEnvVar
versionEnvVar: Version
verbosityRestore: Minimal
- task: PublishBuildArtifacts@1
displayName: Publish Build
inputs:
PathtoPublish: $(build.artifactStagingDirectory)/build
ArtifactName: 'drop'
publishLocation: 'Container'
- task: DotNetCoreCLI@2
displayName: Pack Nugets
inputs:
command: 'pack'
packagesToPack: 'src/*/*.csproj'
packDirectory: '$(build.artifactStagingDirectory)/nuget'
configuration: $(BuildConfiguration)
versioningScheme: byEnvVar
versionEnvVar: Version
verbosityRestore: Minimal
verbosityPack: Minimal
- task: PublishBuildArtifacts@1
displayName: Publish Nugets
inputs:
PathtoPublish: '$(build.artifactStagingDirectory)/nuget'
ArtifactName: 'nuget'
publishLocation: 'Container'
- job: Test
pool:
vmImage: ubuntu-latest
dependsOn:
- Version
variables:
Version: $[ dependencies.Version.outputs['versioning.gitVersion'] ]
GITHUB_KEY: $(GitHubApiKey)
SONAR_ORG: $(SonarCloudOrganization)
SONAR_KEY: $(SonarCloudApiKey)
SONAR_URL: $(SonarCloudHost)
CODECOV_KEY: $(CodeCovApiKey)
COVERALLS_KEY: $(CoverallsApiKey)
steps:
- checkout: self
- pwsh: |
dotnet tool install --tool-path .. dotnet-sonarscanner
dotnet tool install --tool-path .. coveralls.net
dotnet tool install --tool-path .. Codecov.Tool
displayName: Install Tools
- pwsh: |
../dotnet-sonarscanner begin /k:"$(SONAR_PROJECT)" /v:"$(Version)" /o:"$(SONAR_ORG)" /d:sonar.host.url="$(SONAR_URL)" /d:sonar.login="$(SONAR_KEY)" /d:sonar.exclusions="tests/**" /d:sonar.cs.opencover.reportsPaths="$(build.artifactStagingDirectory)/coverage/coverage.opencover.xml" /d:sonar.branch.name="$(Build.SourceBranchName)" /d:sonar.github.repository="$(Build.Repository.Name)" /d:sonar.github.oauth=$(GITHUB_KEY)
condition: ne(variables['Build.Reason'], 'PullRequest')
displayName: SonarCloud (commit)
- pwsh: |
../dotnet-sonarscanner begin /k:"$(SONAR_PROJECT)" /v:"$(Version)" /o:"$(SONAR_ORG)" /d:sonar.host.url="$(SONAR_URL)" /d:sonar.login="$(SONAR_KEY)" /d:sonar.exclusions="tests/**" /d:sonar.cs.opencover.reportsPaths="$(build.artifactStagingDirectory)/coverage/coverage.opencover.xml" /d:sonar.github.repository="$(Build.Repository.Name)" /d:sonar.github.oauth=$(GITHUB_KEY) /d:sonar.pullrequest.key="$(System.PullRequest.PullRequestNumber)" /d:sonar.pullrequest.branch="$(Build.SourceBranchName)" /d:sonar.pullrequest.provider="github"
condition: eq(variables['Build.Reason'], 'PullRequest')
displayName: SonarCloud (PR)
- task: DotNetCoreCLI@2
displayName: Test Solution
inputs:
command: 'test'
configuration: 'Debug'
arguments: '--logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=$(build.artifactStagingDirectory)/coverage/ /p:MergeWith=$(build.artifactStagingDirectory)/coverage/coverage.json'
publishTestResults: true
verbosityPack: Minimal
verbosityRestore: Minimal
testRunTitle: 'Unit Tests'
- pwsh: |
../dotnet-sonarscanner end /d:sonar.login="$(SONAR_KEY)"
displayName: Publish SonarCloud
- task: PublishBuildArtifacts@1
displayName: Publish Test Coverage
inputs:
PathtoPublish: $(build.artifactStagingDirectory)/coverage
ArtifactName: 'coverage'
publishLocation: 'Container'
- pwsh: |
../csmacnz.Coveralls --repoToken "$(COVERALLS_KEY)" --opencover -i $(build.artifactStagingDirectory)/coverage/coverage.opencover.xml --useRelativePaths --commitId "$(Build.SourceVersion)" --commitBranch "$(Build.SourceBranchName)" --commitAuthor "$(Build.RequestedFor)" --commitEmail "$(Build.RequestedForEmail)" --jobId "$(Build.BuildId)"
../codecov --token "$(CodeCovApiKey)" --file $(build.artifactStagingDirectory)/coverage/coverage.opencover.xml --branch "$(Build.SourceBranchName)" --sha "$(Build.SourceVersion)"
condition: ne(variables['Build.Reason'], 'PullRequest')
displayName: Push Coverage (commit)
- pwsh: |
../csmacnz.Coveralls --repoToken "$(COVERALLS_KEY)" --opencover -i $(build.artifactStagingDirectory)/coverage/coverage.opencover.xml --useRelativePaths --commitId "$(Build.SourceVersion)" --commitBranch "$(Build.SourceBranchName)" --commitAuthor "$(Build.RequestedFor)" --commitEmail "$(Build.RequestedForEmail)" --jobId "$(Build.BuildId)" --pullRequest "$(System.PullRequest.PullRequestNumber)"
../codecov --token "$(CodeCovApiKey)" --file $(build.artifactStagingDirectory)/coverage/coverage.opencover.xml --branch "$(Build.SourceBranchName)" --sha "$(Build.SourceVersion)" --pr "$(System.PullRequest.PullRequestNumber)"
condition: eq(variables['Build.Reason'], 'PullRequest')
displayName: Push Coverage (PR)
- job: Publish
pool:
vmImage: ubuntu-latest
dependsOn:
- Version
- Build
- Test
steps:
- checkout: none
- task: DownloadPipelineArtifact@2
displayName: Fetch nugets
inputs:
buildType: 'current'
artifactName: 'nuget'
targetPath: $(build.artifactStagingDirectory)/nuget
- task: DotNetCoreCLI@2
condition: and(ne(variables['Build.Reason'], 'PullRequest'), ne(variables['Build.SourceBranch'], 'refs/heads/master'))
displayName: Push Nugets to Private Feed
inputs:
workingDirectory: $(build.artifactStagingDirectory)/nuget
command: 'custom'
custom: 'nuget'
arguments: >
push *.nupkg
-s $(KritikosNuget)
-k $(KritikosApiKey)
- task: DotNetCoreCLI@2
condition: and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
displayName: Push Nugets to NuGet.org
inputs:
workingDirectory: $(build.artifactStagingDirectory)/nuget
command: 'custom'
custom: 'nuget'
arguments: >
push *.nupkg
-s $(NugetOrgUri)
-k $(NugetApiKey)


stages:
- template: /ci/azure-pipelines/stages/general/00. gitversion.yml@templates
parameters:
updateAssemblyInfo: true
- template: /ci/azure-pipelines/stages/dotnet/00. build.yml@templates
parameters:
useCache: true
configuration: Release
updateAssemblyInfo: true
publishWeb: false
buildOnLinux: true
buildOnWindows: true
packOnLinux: true
- template: /ci/azure-pipelines/stages/dotnet/01. test.yml@templates
parameters:
useCache: true
configuration: Debug
testOnLinux: true
testOnWindows: true
coverageOnLinux: true
sonarOnLinux: true
codecovOnLinux: true
coverallsOnLinux: true
- template: /ci/azure-pipelines/stages/dotnet/03. intellicode.yml@templates
parameters:
useCache: true
updateAssemblyInfo: true
branch: develop
- template: /ci/azure-pipelines/stages/dotnet/02. nuget-deploy.yml@templates
parameters:
packagesToPush: '*.nupkg'
artifact: nuget
environmentPullRequest: Pull Requests
jobNamePullRequest: PullRequests
feedNamePullRequest: NugetKritikos
environmentRelease: Release
jobNameRelease: Release
feedNameRelease: NugetOrgKritikos

0 comments on commit a5375ba

Please sign in to comment.