This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
149 lines (146 loc) · 5.56 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
trigger: none
pool:
vmImage: "ubuntu-latest"
parameters:
- name: "WRITE_LOG"
type: boolean
default: false
displayName: "Write logfiles"
- name: "AZURITE_SILENT"
type: boolean
default: true
displayName: "Run Azurite in silent mode"
- name: SELECTED_PACKAGE_VERSION
type: string
displayName: 'Package Version'
default: 'not-set'
- name: "INCREASE_MAJOR"
type: boolean
default: false
displayName: "Increase Major Version"
- name: "INCREASE_MINOR"
type: boolean
default: false
displayName: "Increase Minor Version"
- name: "INCREASE_PATCH"
type: boolean
default: false
displayName: "Increase Patch Version"
variables:
BUILD_CONFIGURATION: "Release"
PACKAGE_NAME: 'JoachimDalen.AzureFunctions.Extensions'
isMaster: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
stages:
- stage: buildAndTest
displayName: "Build & Test"
jobs:
- job: "Build"
displayName: "Build job"
pool:
vmImage: "ubuntu-latest"
steps:
- task: NodeTool@0
displayName: "Install nodeJS"
inputs:
versionSpec: "13.x"
checkLatest: true
- task: Bash@3
displayName: "Install Azurite"
inputs:
targetType: inline
script: npm i -g azurite
- task: Bash@3
displayName: "Install Core Tools"
inputs:
targetType: inline
script: npm i -g azure-functions-core-tools@3
- task: DotNetCoreCLI@2
displayName: "Restore project dependencies"
inputs:
command: 'restore'
projects: '**/*.csproj'
verbosityRestore: 'Normal'
- task: DotNetCoreCLI@2
displayName: "Build the project - $(BUILD_CONFIGURATION)"
inputs:
command: "build"
arguments: "--no-restore --configuration $(BUILD_CONFIGURATION)"
projects: "**/*.csproj"
- task: DotNetCoreCLI@2
displayName: "Run Unit Tests"
inputs:
command: "test"
projects: "**/*Tests/*UnitTests.csproj"
arguments: '--configuration $(BUILD_CONFIGURATION) --collect "Code coverage"'
testRunTitle: "Unit Tests"
- task: DotNetCoreCLI@2
displayName: "Run Integration Tests"
env:
AFTU_RUN_AZURITE: true
AFTU_FUNC_APP_PATH: '../../../../Integration.FunctionApp/bin/Release/netcoreapp3.1'
AFTU_WRITE_LOG: ${{ parameters.WRITE_LOG }}
AFTU_AZURITE_SILENT: ${{ parameters.AZURITE_SILENT }}
inputs:
command: "test"
projects: "**/*Tests/*IntegrationTests.csproj"
arguments: '--configuration $(BUILD_CONFIGURATION) --collect "Code coverage"'
testRunTitle: "Integration Tests"
- task: PowerShell@2
displayName: 'Set package version'
name: SetVersion
inputs:
filePath: '$(Build.SourcesDirectory)/ci/get-updated-package-version.ps1'
arguments: '-IncreaseMajor $${{ parameters.INCREASE_MAJOR }} -IncreaseMinor $${{ parameters.INCREASE_MINOR }} -IncreasePatch $${{ parameters.INCREASE_PATCH }} -SelectedVersion ${{ parameters.SELECTED_PACKAGE_VERSION }} -PackageName $(PACKAGE_NAME)'
failOnStderr: true
showWarnings: true
pwsh: true
- task: DotNetCoreCLI@2
displayName: 'Pack Nuget - $(BUILD_CONFIGURATION)'
inputs:
command: 'pack'
packagesToPack: '$(Build.SourcesDirectory)/src/JoachimDalen.AzureFunctions.Extensions/JoachimDalen.AzureFunctions.Extensions.csproj'
configuration: '$(BUILD_CONFIGURATION)'
packDirectory: '$(Build.ArtifactStagingDirectory)/nuget'
nobuild: true
versioningScheme: 'byEnvVar'
versionEnvVar: 'SETVERSION_UPDATED_PACKAGE_VERSION'
- task: Bash@3
condition: and(always(), eq(${{ parameters.WRITE_LOG }}, true))
inputs:
targetType: "inline"
script: "cp -r /tmp/aftu $(Build.ArtifactStagingDirectory)"
- task: PublishPipelineArtifact@1
displayName: 'Publish Nuget'
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)/nuget"
artifact: "nuget-package"
publishLocation: "pipeline"
- task: PublishPipelineArtifact@1
displayName: 'Publish test logs'
condition: and(always(), eq(${{ parameters.WRITE_LOG }}, true))
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)/aftu"
artifact: "aftu-logs"
publishLocation: "pipeline"
- stage: publish_nuget
displayName: 'Publish package'
condition: eq(variables.isMaster, true)
dependsOn: 'buildAndTest'
jobs:
- deployment:
displayName: 'Publish package'
environment: 'nuget-prod'
strategy:
runOnce:
deploy:
steps:
- download: none
- download: current
artifact: 'nuget-package'
- task: DotNetCoreCLI@2
displayName: 'Push nuget package'
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/nuget-package/*.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'nuget-azure-functions'