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

Added SonarCloud setup and YAML refactoring #68

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
109 changes: 7 additions & 102 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ trigger:
batch: true
branches:
include:
- "*"

pr: none
- "master"

variables:
buildConfiguration: "release"
Expand All @@ -15,104 +13,11 @@ resources:
- repository: das-platform-building-blocks
type: github
name: SkillsFundingAgency/das-platform-building-blocks
ref: refs/tags/0.4.34
ref: refs/tags/0.4.37
endpoint: SkillsFundingAgency

jobs:
- job: 'CodeBuild'
pool:
name: 'DAS - Continuous Integration'
workspace:
clean: all
steps:
- task: gittools.gitversion.gitversion-task.GitVersion@5
displayName: GitVersion
inputs:
updateAssemblyInfo: true

- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: restore
projects: "src/**/*.csproj"
nugetConfigPath: "src/nuget.config"
feedsToUse: config

- task: DotNetCoreCLI@2
displayName: Build
inputs:
projects: "src/**/*.csproj"
arguments: "--configuration $(buildConfiguration) --no-restore"

- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
projects: "**/*Tests.csproj"
arguments: "--configuration $(buildConfiguration) --no-build"

- template: azure-pipelines-templates/build/step/dependency-check.yml@das-platform-building-blocks

- task: DotNetCoreCLI@2
displayName: "Publish API"
inputs:
command: publish
publishWebProjects: false
projects: "src/SFA.DAS.Notifications.Api/SFA.DAS.Notifications.Api.csproj"
arguments: "--configuration $(buildConfiguration) --output $(build.artifactstagingdirectory)/publish --no-restore --no-build"

- task: DotNetCoreCLI@2
displayName: "Publish Web Job"
inputs:
command: publish
publishWebProjects: false
projects: "src/SFA.DAS.Notifications.MessageHandlers/SFA.DAS.Notifications.MessageHandlers.csproj"
arguments: "--configuration $(buildConfiguration) --output $(build.artifactstagingdirectory)/publish/SFA.DAS.Notifications.MessageHandlers/App_Data/jobs/continuous/Notifications-MessageHandlers --no-restore --no-build"
zipAfterPublish: false
modifyOutputPath: false
- task: DotNetCoreCLI@2
displayName: "dotnet pack"
inputs:
command: pack
packagesToPack: >
src/SFA.DAS.Notifications.Messages/SFA.DAS.Notifications.Messages.csproj
packDirectory: "$(build.artifactstagingdirectory)/publish"
versioningScheme: byBuildNumber
buildProperties: 'Version="$(Build.BuildNumber)"'

- task: CopyFiles@2
displayName: "Copy Files to: $(build.artifactstagingdirectory)"
inputs:
contents: |
azure/**
targetFolder: "$(build.artifactstagingdirectory)/publish"

- task: PublishBuildArtifacts@1
displayName: "Publish Artifact"
inputs:
pathtoPublish: "$(build.artifactstagingdirectory)/publish"

- job: 'DACPACBuild'
pool:
vmImage: 'windows-2019'
workspace:
clean: all
steps:
- task: VSBuild@1
displayName: 'Build DACPAC'
inputs:
solution: 'src/SFA.DAS.Notifications.Database/SFA.DAS.Notifications.Database.sqlproj'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArgs: '/p:PackageLocation="$(build.artifactstagingdirectory)/publish"'
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
contents: |
src/**/*.dacpac
targetFolder: '$(build.artifactstagingdirectory)/publish'
flattenfolders: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
pathtoPublish: '$(build.artifactstagingdirectory)/publish'
stages:
- stage: Build
jobs:
- template: pipeline-templates/job/code-build.yml
- template: pipeline-templates/job/dacpac-build.yml
98 changes: 98 additions & 0 deletions pipeline-templates/job/code-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
jobs:
- job: 'CodeBuild'
pool:
name: 'DAS - Continuous Integration'
variables:
- group: BUILD Management Resources
- name: buildConfiguration
value: release
workspace:
clean: all
steps:
- task: gittools.gitversion.gitversion-task.GitVersion@5
displayName: GitVersion
inputs:
updateAssemblyInfo: true

- task: SonarCloudPrepare@1
displayName: Prepare SonarCloud analysis configuration
condition: and(succeeded(), or(in(variables['Build.SourceBranch'], 'refs/heads/master', 'refs/heads/main'), eq(variables['Build.Reason'], 'PullRequest')))
inputs:
SonarCloud: ESFA - SonarCloud
organization: $(SonarCloudOrganisationKey)
scannerMode: MSBuild
projectName: "$(Build.DefinitionName)"
projectKey: SkillsFundingAgency_das-referencedata

- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: restore
projects: "src/**/*.csproj"
nugetConfigPath: "src/nuget.config"
feedsToUse: config

- task: DotNetCoreCLI@2
displayName: Build
inputs:
projects: "src/**/*.csproj"
arguments: "--configuration $(buildConfiguration) --no-restore"

- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
projects: "**/*Tests.csproj"
arguments: "--configuration $(buildConfiguration) --no-build"

- template: azure-pipelines-templates/build/step/dependency-check.yml@das-platform-building-blocks

- task: DotNetCoreCLI@2
displayName: "Publish API"
inputs:
command: publish
publishWebProjects: false
projects: "src/SFA.DAS.Notifications.Api/SFA.DAS.Notifications.Api.csproj"
arguments: "--configuration $(buildConfiguration) --output $(build.artifactstagingdirectory)/publish --no-restore --no-build"

- task: DotNetCoreCLI@2
displayName: "Publish Web Job"
inputs:
command: publish
publishWebProjects: false
projects: "src/SFA.DAS.Notifications.MessageHandlers/SFA.DAS.Notifications.MessageHandlers.csproj"
arguments: "--configuration $(buildConfiguration) --output $(build.artifactstagingdirectory)/publish/SFA.DAS.Notifications.MessageHandlers/App_Data/jobs/continuous/Notifications-MessageHandlers --no-restore --no-build"
zipAfterPublish: false
modifyOutputPath: false

- task: DotNetCoreCLI@2
displayName: "dotnet pack"
inputs:
command: pack
packagesToPack: >
src/SFA.DAS.Notifications.Messages/SFA.DAS.Notifications.Messages.csproj
packDirectory: "$(build.artifactstagingdirectory)/publish"
versioningScheme: byBuildNumber
buildProperties: 'Version="$(Build.BuildNumber)"'

- task: SonarCloudAnalyze@1
displayName: Run SonarCloud analysis
condition: and(succeeded(), or(in(variables['Build.SourceBranch'], 'refs/heads/master', 'refs/heads/main'), eq(variables['Build.Reason'], 'PullRequest')))

- task: SonarCloudPublish@1
displayName: Publish SonarCloud analysis results on build summary
condition: and(succeeded(), or(in(variables['Build.SourceBranch'], 'refs/heads/master', 'refs/heads/main'), eq(variables['Build.Reason'], 'PullRequest')))
inputs:
pollingTimeoutSec: '300'

- task: CopyFiles@2
displayName: "Copy Files to: $(build.artifactstagingdirectory)"
inputs:
contents: |
azure/**
targetFolder: "$(build.artifactstagingdirectory)/publish"

- task: PublishBuildArtifacts@1
displayName: "Publish Artifact"
inputs:
pathtoPublish: "$(build.artifactstagingdirectory)/publish"
25 changes: 25 additions & 0 deletions pipeline-templates/job/dacpac-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
jobs:
- job: 'DACPACBuild'
pool:
vmImage: 'windows-2019'
workspace:
clean: all
steps:
- task: VSBuild@1
displayName: 'Build DACPAC'
inputs:
solution: 'src/SFA.DAS.Notifications.Database/SFA.DAS.Notifications.Database.sqlproj'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArgs: '/p:PackageLocation="$(build.artifactstagingdirectory)/publish"'
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
contents: |
src/**/*.dacpac
targetFolder: '$(build.artifactstagingdirectory)/publish'
flattenfolders: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
pathtoPublish: '$(build.artifactstagingdirectory)/publish'