-
Notifications
You must be signed in to change notification settings - Fork 46
/
azure-pipelines.yml
758 lines (640 loc) · 26.5 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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
trigger:
# run the pipeline on pushes to the following branches
- 2.1.x
- release/*
pr:
# run the pipeline on pull requests to the following branches
- 2.1.x
- release/*
pool:
vmImage: 'Ubuntu-latest'
# set the build name
name: $[ variables['branchName'] ]
schedules:
# run the pipeline every weekday night at 4am on the 2.1.x branch
- cron: "0 4 * * 1-5"
displayName: Nightly full build
branches:
include:
- 2.1.x
resources:
repositories:
- repository: pytools
type: github
endpoint: BCG-X-Official
name: BCG-X-Official/pytools
ref: 2.1.x
variables:
${{ if not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')) }}:
branchName: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ]
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
branchName: $[ replace(variables['System.PullRequest.SourceBranch'], 'refs/heads/', '') ]
source_is_release_branch: $[ startsWith(variables['branchName'], 'release/') ]
source_is_develop_branch: $[ startsWith(variables['branchName'], 'dev/') ]
is_scheduled: $[ eq(variables['Build.Reason'], 'Schedule') ]
project_name: facet
project_root: $(project_name)
package_name: gamma-facet
sshPublicKey: $(sshPublicKey_facet)
stages:
# check code quality first to fail fast (isort, flake8, black)
- stage: code_quality_checks
displayName: 'Code quality'
jobs:
- job:
displayName: 'isort'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
displayName: 'use Python 3.9'
- script: |
python -m pip install isort~=5.12
python -m isort --check --diff .
displayName: 'Run isort'
- job:
displayName: 'black'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
displayName: 'use Python 3.9'
- script: |
python -m pip install black~=23.10.1
python -m black --check .
displayName: 'Run black'
- job:
displayName: 'flake8'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
displayName: 'use Python 3.9'
- script: |
python -m pip install flake8~=5.0 flake8-comprehensions~=3.10
python -m flake8 --config tox.ini -v .
displayName: 'Run flake8'
- job:
displayName: 'mypy'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
displayName: 'use Python 3.9'
- script: |
python -m pip install mypy~=1.2.0 numpy~=1.23 gamma-pytools~=2.1 sklearndf~=2.2
python -m mypy src
displayName: 'Run mypy'
# detect whether the build config (pyproject.toml) was changed -> then we must run a build test
- stage: detect_build_config_changes
displayName: 'Pyproject.toml build config'
jobs:
- job: checkout_and_diff
displayName: 'detect changes'
steps:
- checkout: self
fetchDepth: 2
- task: Bash@3
name: diff
inputs:
targetType: 'inline'
script: |
set -eux
echo Repo: $(Build.DefinitionName)
cd $(System.DefaultWorkingDirectory)
files_changed=$(git diff $(Build.SourceVersion)^ --name-only)
echo "Files changed since last commit: ${files_changed}"
n_files_changed=$(git diff $(Build.SourceVersion)^ --name-only | grep -i -E 'meta\.yaml|pyproject\.toml|azure-pipelines\.yml|tox\.ini|make\.py' | wc -l | xargs)
if [ ${n_files_changed} -gt 0 ]
then
build_changed=1
echo "build config has been changed"
else
build_changed=0
echo "build config is unchanged";
fi
# set +x to prevent Azure from randomly appending a \' of the ## statement
set +x
echo "##vso[task.setvariable variable=conda_build_config_changed;isOutput=true]$build_changed"
- stage:
displayName: 'Unit tests'
dependsOn: 'detect_build_config_changes'
variables:
conda_build_config_changed: $[ stageDependencies.detect_build_config_changes.checkout_and_diff.outputs['diff.conda_build_config_changed'] ]
jobs:
- job:
displayName: 'pytest @ develop environment'
condition: ne(variables.source_is_release_branch, 'True')
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
displayName: 'use Python 3.9'
- checkout: self
- script: dir $(Build.SourcesDirectory)
- task: Bash@3
inputs:
targetType: 'inline'
script: |
set -eux
# install micromamba
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
export MAMBA_ROOT_PREFIX=~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
# install the develop environment
micromamba env create --yes --file environment.yml
micromamba activate $(project_name)-develop
export PYTHONPATH=$(System.DefaultWorkingDirectory)/src/
export RUN_PACKAGE_VERSION_TEST=$(project_name)
pytest \
--cov $(project_name) \
--cov-config "tox.ini" \
--cov-report=xml:coverage.xml --cov-report=html:htmlcov \
--junitxml pytest.xml \
. -s
displayName: 'pytest'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: '$(System.DefaultWorkingDirectory)/*.xml'
searchFolder: '$(System.DefaultWorkingDirectory)/'
testRunTitle: 'Publish test results'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/htmlcov'
# conda env & tox build test
# testing matrix of python & sklearn versions
# - for release branch: 9 build tests
# - otherwise: 3 build tests
- stage: conda_tox_build
displayName: 'Conda/tox build & test'
dependsOn: 'detect_build_config_changes'
variables:
conda_build_config_changed: $[ stageDependencies.detect_build_config_changes.checkout_and_diff.outputs['diff.conda_build_config_changed'] ]
jobs:
- job:
displayName: 'essential'
condition: >
and(
ne(variables.source_is_release_branch, 'True'),
ne(variables.source_is_develop_branch, 'True'),
ne(variables.is_scheduled, 'True'),
ne(stageDependencies.detect_build_config_changes.checkout_and_diff.outputs['diff.conda_build_config_changed'], '0')
)
pool:
vmImage: 'ubuntu-latest'
strategy:
matrix:
# We run three tests to cover conda/tox and maximum/minimum.
# This comprises only one minimum dependencies test for tox,
# which is usually faster than conda.
maximum_dependencies_conda:
FACET_V_PYTHON_BUILD: '=3.9'
BUILD_SYSTEM: 'conda'
PKG_DEPENDENCIES: 'max'
minimum_dependencies_tox:
FACET_V_PYTHON_BUILD: '=3.7'
BUILD_SYSTEM: 'tox'
PKG_DEPENDENCIES: 'min'
maximum_dependencies_tox:
FACET_V_PYTHON_BUILD: '=3.9'
BUILD_SYSTEM: 'tox'
PKG_DEPENDENCIES: 'max'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(FACET_V_PYTHON_BUILD)'
displayName: 'Use Python $(FACET_V_PYTHON_BUILD)'
- checkout: pytools
- checkout: self
- script: dir $(Build.SourcesDirectory)
- script: |
# install micromamba
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
export MAMBA_ROOT_PREFIX=~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
# create and activate a build environment, then install the tools we need
micromamba create -n build
micromamba activate build
micromamba install -y -c conda-forge boa~=0.14 toml~=0.10 flit~=3.6 packaging~=20.9
displayName: 'Install conda-build, flit, toml'
condition: eq(variables['BUILD_SYSTEM'], 'conda')
- script: |
python -m pip install "toml~=0.10"
python -m pip install "flit~=3.7"
flit --version
python -m pip install "tox~=3.25"
tox --version
displayName: 'Install tox, flit & toml'
condition: eq(variables['BUILD_SYSTEM'], 'tox')
- task: Bash@3
inputs:
targetType: 'inline'
script: |
set -eux
if [ "$BUILD_SYSTEM" = "conda" ] ; then
export MAMBA_ROOT_PREFIX=~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
micromamba activate build
fi
export RUN_PACKAGE_VERSION_TEST=$(project_name)
cd $(Build.SourcesDirectory)/$(project_root)
./make.py $(project_name) $(BUILD_SYSTEM) $(PKG_DEPENDENCIES)
displayName: "build & test"
- task: CopyFiles@2
inputs:
sourceFolder: $(System.DefaultWorkingDirectory)/$(project_root)/dist
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: $(BUILD_SYSTEM)_$(PKG_DEPENDENCIES)
publishLocation: Container
- job:
displayName: 'matrix'
condition: >
or(
eq(variables.source_is_develop_branch, 'True'),
eq(variables.source_is_release_branch, 'True'),
eq(variables.is_scheduled, 'True')
)
pool:
vmImage: 'ubuntu-latest'
strategy:
matrix:
default_dependencies_conda:
FACET_V_PYTHON_BUILD: '=3.8'
BUILD_SYSTEM: 'conda'
PKG_DEPENDENCIES: 'default'
minimum_dependencies_conda:
FACET_V_PYTHON_BUILD: '=3.7'
BUILD_SYSTEM: 'conda'
PKG_DEPENDENCIES: 'min'
maximum_dependencies_conda:
FACET_V_PYTHON_BUILD: '=3.9'
BUILD_SYSTEM: 'conda'
PKG_DEPENDENCIES: 'max'
default_dependencies_tox:
FACET_V_PYTHON_BUILD: '=3.8'
BUILD_SYSTEM: 'tox'
PKG_DEPENDENCIES: 'default'
minimum_dependencies_tox:
FACET_V_PYTHON_BUILD: '=3.7'
BUILD_SYSTEM: 'tox'
PKG_DEPENDENCIES: 'min'
maximum_dependencies_tox:
FACET_V_PYTHON_BUILD: '=3.9'
BUILD_SYSTEM: 'tox'
PKG_DEPENDENCIES: 'max'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(FACET_V_PYTHON_BUILD)'
displayName: 'Use Python $(FACET_V_PYTHON_BUILD)'
- checkout: pytools
- checkout: self
- script: dir $(Build.SourcesDirectory)
- script: |
# install micromamba
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
export MAMBA_ROOT_PREFIX=~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
# create and activate a build environment, then install the tools we need
micromamba create -n build
micromamba activate build
micromamba install -y -c conda-forge boa~=0.14 toml~=0.10 flit~=3.6 packaging~=20.9
displayName: 'Install conda-build, flit, toml'
condition: eq(variables['BUILD_SYSTEM'], 'conda')
- script: |
python -m pip install "toml==0.10.*"
python -m pip install "flit==3.0.*"
flit --version
python -m pip install "tox==3.20.*"
tox --version
displayName: 'Install tox, flit & toml'
condition: eq(variables['BUILD_SYSTEM'], 'tox')
- task: Bash@3
inputs:
targetType: 'inline'
script: |
set -eux
if [ "$BUILD_SYSTEM" = "conda" ] ; then
export MAMBA_ROOT_PREFIX=~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
micromamba activate build
fi
export RUN_PACKAGE_VERSION_TEST=$(project_name)
cd $(Build.SourcesDirectory)/$(project_root)
./make.py $(project_name) $(BUILD_SYSTEM) $(PKG_DEPENDENCIES)
displayName: "build & test"
- task: CopyFiles@2
inputs:
sourceFolder: $(System.DefaultWorkingDirectory)/$(project_root)/dist
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: $(BUILD_SYSTEM)_$(PKG_DEPENDENCIES)
publishLocation: Container
# apply veracode static code analysis during nightly build
- stage: veracode_check
displayName: 'Veracode check'
jobs:
- job:
displayName: 'Veracode check'
condition: eq(variables['Build.Reason'], 'Schedule')
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
set -eux
eval "$(conda shell.bash hook)"
cd $(System.DefaultWorkingDirectory)
mkdir static_scan
git archive --format=zip --output static_scan/archive.zip HEAD
- task: Veracode@3
inputs:
ConnectionDetailsSelection: 'Endpoint'
AnalysisService: 'veracode'
veracodeAppProfile: 'FACET'
version: '$(Build.BuildID)'
filepath: '$(System.DefaultWorkingDirectory)/static_scan'
sandboxName: '$(project_name)'
createSandBox: false
createProfile: false
failTheBuildIfVeracodeScanDidNotInitiate: false
scanStatusCheckInterval: '60'
importResults: false
failBuildOnPolicyFail: false
- stage: check_release
displayName: 'Check Release Version'
dependsOn: conda_tox_build
jobs:
- job:
displayName: 'Check Release'
condition: >
or(
eq(variables.source_is_release_branch, 'True'),
eq(variables.source_is_develop_branch, 'True')
)
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
displayName: 'use Python 3.9'
- checkout: pytools
- checkout: self
- task: Bash@3
env:
BRANCH_NAME: $(branchName)
inputs:
targetType: inline
condition: ne(variables.branchName, 'develop')
script: |
set -eux
python -m pip install toml~=0.10.2 packaging~=20.9
cd $(System.DefaultWorkingDirectory)/pytools
python <<EOF
from os import environ
from make import ToxBuilder
branch_env = "BRANCH_NAME"
assert branch_env in environ, f"ENV variable '{branch_env}' with git branch name missing."
branch = environ[branch_env]
print(f"Checking package version consistency with branch: {branch}")
if branch == "develop":
exit(0)
assert (branch.startswith("release/") or branch.startswith("dev/")
), "This check should only run on versioned branches – check pipeline."
branch_version = branch.split("/", maxsplit=1)[1]
package_version = ToxBuilder("$(project_name)", "default").package_version
assert (
package_version == branch_version
), f"Package version '{package_version}' does not match '{branch_version}' from branch."
print("Check passed.")
EOF
displayName: "Check version consistency"
# release on merges into release/*:
# - add release tag
# - create GitHub release with changelog
# - upload conda and pip packages as artifacts to GitHub
- stage:
displayName: 'Release'
dependsOn: check_release
variables:
- group: artifact_publication
jobs:
- job:
displayName: 'Release'
condition: >
or(
eq(variables.source_is_release_branch, 'True'),
eq(variables.source_is_develop_branch, 'True')
)
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
displayName: 'use Python 3.9'
- checkout: pytools
- checkout: self
- task: Bash@3
inputs:
targetType: inline
script: |
set -eux
echo "Getting version"
pip install packaging~=20.9
package_path=$(System.DefaultWorkingDirectory)/$(project_root)/src/$(project_name)
export PYTHONPATH=$(System.DefaultWorkingDirectory)/pytools/sphinx/base
version=$(python -c "import make_util; print(make_util.get_package_version(package_path='$package_path'))")
echo "Current version: $version"
echo "Detecting pre-release ('dev' or 'rc' in version)"
prerelease=False
[[ $version == *dev* ]] && prerelease=True && echo "Development release identified"
[[ $version == *rc* ]] && prerelease=True && echo "Pre-release identified"
# set +x to prevent Azure from randomly appending a \' of the ## statement
set +x
echo "##vso[task.setvariable variable=current_version]$version"
echo "##vso[task.setvariable variable=is_prerelease]$prerelease"
displayName: "Get package version"
- task: DownloadBuildArtifacts@0
inputs:
artifactName: tox_default
- task: DownloadBuildArtifacts@0
inputs:
artifactName: conda_default
- script: |
set -eux
cd $(System.DefaultWorkingDirectory)
eval "$(conda shell.bash hook)"
conda install -y anaconda-client
anaconda login --username "${CONDA_USERNAME}" --password "${CONDA_PASSWORD}"
anaconda upload --user BCG_Gamma --force $(System.ArtifactsDirectory)/conda_default/conda/noarch/$(package_name)-*.tar.bz2
anaconda logout
# set +x to prevent Azure from randomly appending a \' of the ## statement
set +x
echo "##vso[task.setvariable variable=conda_published]True"
displayName: 'Publish to Anaconda'
condition: eq(variables['source_is_release_branch'], 'True')
env:
CONDA_PASSWORD: $(anaconda_pw)
CONDA_USERNAME: $(anaconda_user)
- script: |
set -eux
cd $(System.DefaultWorkingDirectory)/$(project_root)
pip install flit
flit install -s
flit publish
# set +x to prevent Azure from randomly appending a \' of the ## statement
set +x
echo "##vso[task.setvariable variable=pypi_published]True"
displayName: 'Publish to PyPi'
condition: eq(variables['source_is_release_branch'], 'True')
env:
FLIT_PASSWORD: $(pypi_facet_uploads)
FLIT_USERNAME: __token__
- task: GitHubRelease@1
condition: >
and(
eq(variables['source_is_release_branch'], 'True'),
succeededOrFailed(),
or(
eq(variables['conda_published'], 'True'),
eq(variables['pypi_published'], 'True')
)
)
inputs:
gitHubConnection: github-release
repositoryName: $(Build.Repository.Name)
action: create
target: $(Build.SourceVersion)
tagSource: userSpecifiedTag
tag: $(current_version)
title: $(project_name) $(current_version)
releaseNotesSource: inline
releaseNotesInline: |
This is the $(current_version) release of $(package_name).
You can upgrade your current pip installation via
pip install --upgrade $(package_name)
Your conda package can be upgraded by running
conda install -c conda-forge -c bcg_gamma $(package_name)
isDraft: false
isPrerelease: $(is_prerelease)
assets: |
$(System.ArtifactsDirectory)/tox_default/tox/$(package_name)-*.tar.gz
$(System.ArtifactsDirectory)/conda_default/conda/noarch/$(package_name)-*.tar.bz2
# render docs and publish to GitHub Pages
- stage:
displayName: 'Docs'
variables:
- group: github_ssh
jobs:
- job:
displayName: 'Build and publish docs'
condition: >
or(
eq(variables.source_is_release_branch, 'True'),
eq(variables.source_is_develop_branch, 'True'),
eq(variables['Build.Reason'], 'Manual')
)
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
displayName: 'use Python 3.9'
- task: InstallSSHKey@0
inputs:
knownHostsEntry: $(knownHostsEntry)
sshPublicKey: $(sshPublicKey)
sshKeySecureFile: 'deploy_docs_$(project_name)'
displayName: 'Install the deploy SSH key'
- checkout: self
- script: dir $(Build.SourcesDirectory)
- task: Bash@3
inputs:
targetType: 'inline'
script: |
set -eux
cd $(System.DefaultWorkingDirectory)
echo "Checking out github-pages"
git fetch origin github-pages --depth=1
git checkout --track origin/github-pages
# make sure we have a docs directory
mkdir -p docs/docs-version
echo "Current documentation contents:"
ls docs/docs-version
# copy the current documentation versions to the staging area
cp -r docs/docs-version $(Build.ArtifactStagingDirectory)/docs-version.bak
displayName: 'Retrieve current documentation versions from github-pages'
- task: Bash@3
inputs:
targetType: 'inline'
script: |
set -eux
cd $(System.DefaultWorkingDirectory)
echo "Checking out $(branchName)"
git fetch origin $(branchName) --depth=1
git checkout $(branchName)
# install micromamba
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
export MAMBA_ROOT_PREFIX=~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
# install the develop environment
micromamba env create --yes --file environment.yml
micromamba activate $(project_name)-develop
export PYTHONPATH=$(System.DefaultWorkingDirectory)/src/
python sphinx/make.py html
displayName: 'Build latest documentation'
- task: Bash@3
inputs:
targetType: 'inline'
script: |
set -eux
export MAMBA_ROOT_PREFIX=~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
# install the tree utility
sudo apt-get install tree
cd $(System.DefaultWorkingDirectory)
echo "Restoring previous documentation to the docs directory"
mkdir -p docs
mv $(Build.ArtifactStagingDirectory)/docs-version.bak docs/docs-version
ls docs/docs-version
mkdir -p $(System.DefaultWorkingDirectory)/sphinx/build/
micromamba activate $(project_name)-develop
python sphinx/make.py prepare_docs_deployment
echo "Current docs contents:"
tree docs
mv docs $(Build.ArtifactStagingDirectory)/docs
displayName: 'Merge previous and latest docs'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)/docs
artifactName: $(project_name)_docs
publishLocation: Container
displayName: 'Publish docs artifact'
- task: Bash@3
condition: eq(variables['source_is_release_branch'], 'True')
inputs:
targetType: 'inline'
script: |
set -eux
cd $(System.DefaultWorkingDirectory)
echo "Adjusting git credentials"
git config --global user.name "Azure Pipelines"
git config --global user.email "[email protected]"
git config --global url.ssh://[email protected]/.insteadOf https://github.com/
git checkout github-pages
rm -rf docs
mv $(Build.ArtifactStagingDirectory)/docs .
git add docs
git status
git commit -m "Publish GitHub Pages [skip ci]"
git push --set-upstream origin github-pages
displayName: 'Publish docs to branch github-pages'