-
Notifications
You must be signed in to change notification settings - Fork 5
/
azure-pipelines.yml
237 lines (204 loc) · 8.22 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# Lint, test and package a plugin for QGIS
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/container-phases?view=azure-devops&tabs=yaml
pr:
- master
trigger:
batch: true
branches:
include:
- master
- debug
tags:
include:
- "*"
resources:
repositories:
- repository: templates
type: github
name: isogeo/devops-templates
endpoint: isogeo
variables:
pythonVersion: "3.9"
isProd: $[contains(variables['Build.SourceBranch'], 'refs/tags')]
isQA: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), contains(variables['Build.SourceBranch'], 'refs/pull/'))]
isDebug: $[eq(variables['Build.SourceBranch'], 'refs/heads/debug')]
azureSubscription : $(AZURE_SUBSCRIPTION)
releaseDate: $[format('{0:dd}.{0:MM}.{0:yyyy}', pipeline.startTime)]
releaseDateWithHour: $[format('{0:dd}.{0:MM}.{0:yyyy}-{0:HH}.{0:mm}', pipeline.startTime)]
stages:
- stage: variables
pool:
vmImage: "ubuntu-22.04"
displayName: "Variables"
jobs:
- job: variables_values
displayName: "Set and display variables values"
steps:
- checkout : self
fetchTags: True
- bash: |
if [ "$(isProd)" = "True" ]; then
echo isProd - $(isProd)
ZIPNAME="$(NAME)-$(echo $(Build.SourceBranch) | sed 's|refs/tags/||')"
elif [ "$(isQA)" = "True" ]; then
echo isQA - $(isQA)
ZIPNAME="$(NAME)-qa-$(releaseDateWithHour)"
elif [ "$(isDebug)" = "True" ]; then
echo isDebug - $(isDebug)
TAG="$(git describe --tags $(git rev-list --tags --max-count=1))"
ZIPNAME="$(NAME)-debug-$TAG-$(releaseDate)"
else
echo isProd - $(isProd)
echo isQA - $(isQA)
echo isDebug - $(isDebug)
ZIPNAME="$(NAME)"
fi
echo $ZIPNAME
echo "##vso[task.setvariable variable=zipName;]$ZIPNAME"
echo "##vso[task.setvariable variable=zipName;isOutput=true]$ZIPNAME"
name: set_zipname_variable
- bash: |
echo "NAME - $(NAME)"
echo "Build.BuildId - $(Build.BuildId)"
echo "Build.SourceBranch - $(Build.SourceBranch)"
echo "System.DefaultWorkingDirectory - $(System.DefaultWorkingDirectory)"
echo "pythonVersion - $(pythonVersion)"
echo "isProd - $(isProd)"
echo "isQA - $(isQA)"
echo "isDebug - $(isDebug)"
echo "releaseDate - $(releaseDate)"
echo "releaseDateWithHour - $(releaseDateWithHour)"
echo "zipName - $(zipName)"
name: display_variables_values
- stage: integration
pool:
vmImage: "windows-2019"
dependsOn : variables
condition: and(succeeded(), or(eq(variables.isProd, true), eq(variables.isQA, true), eq(variables.isDebug, true)))
variables:
zipName: $[ stageDependencies.variables.variables_values.outputs['set_zipname_variable.zipName'] ]
displayName: "Integration"
jobs:
- job: format_lint_build_package
displayName: "Format & lint code, then build & package"
steps:
- checkout: self
fetchDepth: 10
- task: UsePythonVersion@0
inputs:
versionSpec: $(pythonVersion)
architecture: 'x64'
addToPath: true
displayName: "Install - Python ${{ variables.pythonVersion }}"
- script: |
python -m pip install -U pip --cache-dir ./.pipcache
python -m pip install -U -r ./requirements.txt --cache-dir ./.pipcache
displayName: "Install - Dependencies"
- script: |
python -m black --target-version=py37 .\isogeo.py
python -m black --target-version=py37 .\modules
python -m black --target-version=py37 .\ui
displayName: "Format - black code formatting"
- script: |
flake8 ./isogeo.py --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 ./modules --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 ./isogeo.py --count --exit-zero --max-complexity=10 --max-line-length=100
flake8 ./modules --count --exit-zero --max-complexity=10 --max-line-length=100
displayName: "Lint - Static code analisis"
- script: |
pylupdate5 -noobsolete -verbose isogeo_search_engine.pro
qt5-tools lrelease .\i18n\isogeo_search_engine_en.ts
qt5-tools lrelease .\i18n\isogeo_search_engine_fr.ts
qt5-tools lrelease .\i18n\isogeo_search_engine_es.ts
qt5-tools lrelease .\i18n\isogeo_search_engine_pt_BR.ts
displayName: "Build - Qt translations (i18n)"
- script: |
pyrcc5 resources.qrc -o resources_rc.py
displayName: "Build - Qt resources compilation"
- script: |
pyuic5 -x "ui\isogeo_dockwidget_base.ui" -o "ui\ui_isogeo.py"
pyuic5 -x "ui\auth\ui_authentication.ui" -o "ui\auth\ui_authentication.py"
pyuic5 -x "ui\credits\ui_credits.ui" -o "ui\credits\ui_credits.py"
pyuic5 -x "ui\db_connections\ui_db_connections.ui" -o "ui\db_connections\ui_db_connections.py"
pyuic5 -x "ui\metadata\ui_md_details.ui" -o "ui\metadata\ui_md_details.py"
pyuic5 -x "ui\quicksearch\ui_quicksearch_rename.ui" -o "ui\quicksearch\ui_quicksearch_rename.py"
pyuic5 -x "ui\quicksearch\ui_quicksearch_new.ui" -o "ui\quicksearch\ui_quicksearch_new.py"
displayName: "Build - Qt UI files compilation"
- script: python ./tools/plugin_packager.py
displayName: "Package - script ./tools/plugin_packager.py"
- task: PublishPipelineArtifact@1
displayName: "Publish - pipeline artifact"
inputs:
path: $(System.DefaultWorkingDirectory)/build/latest/isogeo_search_engine.zip
artifact: $(zipName)
- script: |
echo $(System.DefaultWorkingDirectory)\build\latest\
ls $(System.DefaultWorkingDirectory)\build\latest\
mv $(System.DefaultWorkingDirectory)\build\latest\isogeo_search_engine.zip $(System.DefaultWorkingDirectory)\build\latest\$(zipName).zip
ls $(System.DefaultWorkingDirectory)\build\latest\
displayName: "Package - rename archive to ${{ variables.zipName }}"
- task: PublishBuildArtifacts@1
displayName: "Publish - build artifact"
inputs:
PathtoPublish: $(System.DefaultWorkingDirectory)/build/latest/$(zipName).zip
ArtifactName: archive
- stage : upload_to_blob
pool:
vmImage: "ubuntu-latest"
condition: and(succeeded(), or(eq(variables.isProd, true), eq(variables.isQA, true), eq(variables.isDebug, true)))
dependsOn :
- integration
- variables
variables:
zipName: $[ stageDependencies.variables.variables_values.outputs['set_zipname_variable.zipName'] ]
displayName: "Upload to Blob"
jobs:
- template : /on-premises/upload_to_blob.yml@templates
parameters :
zipName: $(zipName).zip
artifactName : archive
- stage: versions_update
condition: and(succeeded(), eq(variables.isProd, true))
dependsOn :
- upload_to_blob
displayName: "Update versions.json"
jobs:
- template : /on-premises/update_versions.yml@templates
- stage: installer_tag
condition: and(succeeded(), eq(variables.isProd, true))
dependsOn: versions_update
displayName: "Git tag installer"
jobs :
- template : /on-premises/retrieve_github_pat.yml@templates
- template : /on-premises/installer_tag.yml@templates
- stage: publish_to_github
dependsOn:
- integration
- variables
displayName: "GitHub release"
variables:
zipName: $[ stageDependencies.variables.variables_values.outputs['set_zipname_variable.zipName'] ]
condition: and(succeeded(), eq(variables.isProd, true))
jobs:
- job: 'create_github_release'
displayName: "Create a GitHub Release"
steps:
- checkout: none
- task: DownloadPipelineArtifact@2
displayName: "Download packaged source code saved during 'integration' stage"
inputs:
buildType: "current"
artifactName: $(zipName)
targetPath: "$(System.DefaultWorkingDirectory)"
- task: GitHubRelease@1
continueOnError: true
displayName: "Publish tagged code as Github Release"
inputs:
gitHubConnection: $(GITHUB_CONNECTION)
repositoryName: '$(Build.Repository.Name)'
action: 'create'
assets: "$(System.DefaultWorkingDirectory)/*"
target: '$(Build.SourceVersion)'
tagSource: 'gitTag'
changeLogCompareToRelease: 'lastFullRelease'
changeLogType: 'commitBased'