Skip to content

Azure pipeline #262

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

Merged
merged 44 commits into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b30ac22
Azure pipeline
Jun 26, 2019
658bae8
Changes from PR review #262
Jun 27, 2019
5377dd9
Cannot provide variables without a stage definition
Jun 27, 2019
cd28a47
A world of new possibilities
Jun 27, 2019
5942dd6
Try with templates.
Jun 27, 2019
da8c55c
May work!!!
Jun 27, 2019
a5f381c
Test
Jun 27, 2019
4d98086
Rename the template file.
Jun 27, 2019
2fd38ba
Another test for displayNames to be pretty
Jun 27, 2019
a17e3da
Forgot some quotes.
Jun 27, 2019
54534d3
I may be loosing my mind slowly
Jun 27, 2019
9bb3535
Another test
Jun 27, 2019
bd08e8f
Last ty
Jun 27, 2019
a639ff5
Should work but not super pretty
Jun 27, 2019
0cdfd74
Instead of running step on condition, do not add it on condition.
Jun 27, 2019
f35d489
forgot a $
Jun 27, 2019
d0170c0
revert the changes which were not working, but kept some docs.
Jun 27, 2019
322abe9
Triggered only for PRs, not every branch for every commit.
Jun 28, 2019
4c13fb4
Remove publishing steps from the `whole build`. Instead, copy the cre…
Jun 28, 2019
9f16bf4
Publish all the created artifacts if succeeded.
Jun 28, 2019
7f5dd9f
Trigger on tags starting with the letter v
Jun 28, 2019
625a973
Why is it building master???
Jun 28, 2019
68a3614
Is it the PR?
Jun 28, 2019
e6eebd9
Stage to have the publishing one depending on the building one.
Jun 28, 2019
e11c639
Need to publish artifacts per job.
Jun 28, 2019
6ddecc8
Update back the publish artifact step
Jun 28, 2019
65651f0
Let's try the release pipelines.
Jun 28, 2019
f477e86
Add some documentation.
Jun 28, 2019
f511546
ignore folders `vnv`.
Jun 28, 2019
b8d7e99
Publish test results even if tests failed.
Jul 1, 2019
f47fe0c
Build every tag
Jul 1, 2019
687a107
Version v0.13.1-b2
Jul 1, 2019
24cd5ec
Version 0.13.1-b3
Jul 1, 2019
f91870e
Forgot a star
Jul 1, 2019
fc34b07
Was the space really important? And version beta up
Jul 1, 2019
ddcb2b2
Build is `Automated` for every tag, not only the one starting with `v`.
Jul 1, 2019
15ab9f2
Add a MANIFEST.in file to include the read me and the license files i…
Jul 1, 2019
e0e04b2
Bump beta version for final test
Jul 1, 2019
7ac1925
Update some docs.
Jul 1, 2019
a14e8a0
MANIFEST is not the issue.
Jul 1, 2019
f7241df
It seems building a wheel from a windows machine is complicated with …
Jul 1, 2019
5c3adb9
The published packaged version seems to include the readme.
Jul 1, 2019
7ba0bc2
Should be the final version bump for test.
Jul 1, 2019
0c97b1c
Merge branch 'master' of github.com:data61/clkhash into feature-azure…
Jul 3, 2019
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
88 changes: 88 additions & 0 deletions .azurePipeline/wholeBuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
parameters:
pythonVersions: []
operatingSystems: []
architectures: []

jobs:
- job: 'test_and_publish'
strategy:
matrix:
${{ each py in parameters.pythonVersions }}:
${{ each os in parameters.operatingSystems }}:
${{ each architecture in parameters.architectures }}:
${{ format('{0}_Python_{1}_{2}', os, py, architecture) }}:
pythonVersion: ${{ py }}
operatingSystem: ${{ os }}
architecture: ${{ architecture }}

pool:
vmImage: $(operatingSystem)

displayName: 'Test and publish for '

steps:
# I would not have found on my own such a step. Thanks https://dvlup.com/2019/01/03/using-powershell-to-installing-msi-in-a-devops-build/
# The solution I found was not working: it hanged forevever, using "msiexec /i"
# These steps are required because of at least the bitarray dependency (but maybe more). See issue #153 tracking if bitarray is still used.
- powershell: Invoke-WebRequest -Uri https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi -OutFile VCForPython27.msi
displayName: 'Download Microsoft Visual C++ 9.0 from https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi'
condition: eq(variables['pythonVersion'], 2.7)
- powershell: Start-Process VCForPython27.msi -ArgumentList "/q" -Wait
displayName: 'Install Microsoft Visual C++ 9.0.'
condition: and(eq(variables['operatingSystem'], 'vs2017-win2016'), eq(variables['pythonVersion'], 2.7))

- task: UsePythonVersion@0
inputs:
versionSpec: '$(pythonVersion)'
architecture: '$(architecture)'

- script: |
python -m pip install -U pip
python -m pip install -U wheel setuptools codecov
python -m pip install -U -r requirements.txt
displayName: 'Install requirements'

- script: python setup.py sdist bdist_wheel
displayName: 'Package'

- script: python -m pytest --cov=clkhash --junitxml=testResults.xml --cov-report=xml:coverageReport.xml --cov-report=html:htmlcov
displayName: 'Test with pytest'
env:
INCLUDE_CLI: 1

- task: PublishTestResults@2
displayName: 'Publish test results in Azure'
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'testResults.xml'
testRunTitle: 'Test results on a vm $(operatingSystem) ($(architecture)) for Python $(pythonVersion)'
failTaskOnFailedTests: true

- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage in Azure'
# If the previous stage fail, we still want to run this one as the previous stage may fail because of a failing test.
condition: succeededOrFailed()
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: 'coverageReport.xml'
# Seems to create warning as this step is already creating its own html pages.
# reportDirectory: 'htmlcov'
failIfCoverageEmpty: true

- script: python -m codecov --token $(CODECOV_TOKEN) --file coverageReport.xml
displayName: 'Send coverage to codecov'
condition: succeededOrFailed()

- script: |
pyinstaller cli.spec
.\dist\clkutil.exe --version
displayName: 'Build clkutil.exe'
condition: and(eq(variables['operatingSystem'], 'vs2017-win2016'), eq(variables['pythonVersion'], '3.7'), eq(variables['architecture'], 'x86'))

- task: PublishPipelineArtifact@0
displayName: 'Publish artifacts'
condition: and(eq(variables['pythonVersion'], '3.7'), eq(variables['architecture'], 'x86'))
inputs:
artifactName: Artifacts
targetPath: 'dist/'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ lib64/
parts/
sdist/
var/
venv/
*.egg-info/
.installed.cfg

Expand Down
27 changes: 27 additions & 0 deletions azurePipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
trigger:
branches:
include:
- master
exclude:
- '*'
tags:
include:
- '*'
pr:
branches:
include:
- '*'

jobs:
- template: .azurePipeline/wholeBuild.yml # Template reference
parameters:
pythonVersions: ['3.7', '3.6', '3.5', '2.7']
# operatingSystems: ['ubuntu-16.04', 'macos-10.13', 'vs2017-win2016']
operatingSystems: ['vs2017-win2016']
architectures: ['x64', 'x86']

- job:
steps:
# In this step, if this build is triggered by a tag, it will add a tag 'Automated' to the current build.
- script: echo "##vso[build.addbuildtag]Automated"
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
60 changes: 60 additions & 0 deletions docs/devops.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Devops
===========


.. toctree::
:maxdepth: 2

clkhash

Azure Pipeline
--------------

``clkhash`` is automatically built and tested using Azure Pipeline
for Windows environment, in the project `Anonlink <https://dev.azure.com/data61/Anonlink>`

Two pipelines are available:
- `Build pipeline <https://dev.azure.com/data61/Anonlink/_build?definitionId=2>`,
- `Release pipeline <https://dev.azure.com/data61/Anonlink/_release?definitionId=1>`.

The build pipeline is described by the script `azurePipeline.yml`
which is using resources from the folder `.azurePipeline`.
Mainly, a number of builds and tests are started for different
version of python and system architecture.
Only the packages created with ``Python 3.7`` and the ``x86``
architecture are then published (in Azure).

The build pipeline is triggered for every pushes on the master branch,
for every tagged commit, and for every pushes part of a pull
request. We are not building on every push and
pull requests not to build twice the same code. For every tagged commit,
the build pipeline will also add the Azure tag `Automated` which will trigger
automatically the release pipeline.

The build pipeline does:
- install the requirements,
- package ``clkhash``,
- run `pytest`,
- publish the test results,
- publish the code coverage (on Azure and codecov),
- publish the artifacts from the build using ``Python 3.7``
with a ``x86`` architecture (i.e. a whl, a tar.gz and an exe).

The build pipeline requires one environment variable provided by Azure environment:
- `CODECOV_TOKEN` which is used to publish the coverage to codecov.


The release pipeline can either be triggered manually, or automatically from
a successful build on master where the build is tagged `Automated`
(i.e. if the commit is tagged, cf previous paragraph).

The release pipeline consists of two steps:
- asking for a manual confirmation that the artifacts from the
triggering build should be released,
- uses ``twine`` to publish the artifacts.

The release pipeline requires two environment variables provided by Azure environment:
- `PYPI_LOGIN`: login to push an artifact to ``clkhash`` ``Pypi`` repository,
- `PYPI_PASSWORD`: password to push an artifact to ``clkhash`` ``Pypi`` repository
for the user `PYPI_LOGIN`.

1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Table of Contents
cli
schema
development
devops
rest_client
references

Expand Down
20 changes: 15 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from setuptools import setup, find_packages
import codecs
import sys
if sys.version_info[0] < 3:
import codecs


requirements = [
"bitarray>=0.8",
Expand All @@ -16,13 +19,20 @@
"typing>=3.6; python_version < '3.5'", # Backport from Py3.5
"bashplotlib>=0.6.5"
]

with codecs.open('README.md', 'r', 'utf-8') as f:
readme = f.read()
if sys.version_info[0] < 3:
# Python 2.7 does not accept the parameter `encoding` to open a file
with codecs.open('README.md', 'r', 'utf-8') as f:
readme = f.read()
else:
# But on Windows, something wrong happens when creating the package
# and using codecs.open. related issues are https://github.com/di/markdown-description-example/issues/4
# But this is not exactly the same either...
with open('README.md', 'r', encoding='utf-8') as f:
readme = f.read()

setup(
name="clkhash",
version='0.13.1b1',
version='0.13.1-b6',
description='Encoding utility to create Cryptographic Linkage Keys',
long_description=readme,
long_description_content_type='text/markdown',
Expand Down