Skip to content

Commit

Permalink
Azure Pipeline: add azure pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-douglass committed Apr 3, 2020
1 parent 9b63083 commit 72f8a3c
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 3 deletions.
92 changes: 92 additions & 0 deletions pipelines/azure-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: build

trigger:
tags:
include: ["v*"]

pool:
vmImage: 'ubuntu-18.04'

stages:
- stage: build
jobs:
- job: build_package
displayName: Build Package
steps:
- task: UsePythonVersion@0
displayName: Set python version
inputs: {versionSpec: 3.8}
- script: |
sudo env "PATH=$PATH" python -m pip install --no-cache-dir -U wheel cython pip
python setup.py bdist_wheel
- publish: $(System.DefaultWorkingDirectory)/dist/
artifact: dist
- publish: $(System.DefaultWorkingDirectory)/pipelines/
artifact: pipelines
- publish: $(System.DefaultWorkingDirectory)/test/
artifact: test
#- stage: test
# jobs:
# - job: run_test
# strategy:
# matrix:
# python3_7:
# python.version: '3.7'
# Python3_8:
# python.version: '3.8'
# timeoutInMinutes: 10
# steps:
# - checkout: none
# - task: UsePythonVersion@0
# displayName: Set python version
# inputs:
# versionSpec: '$(python.version)'
# - download: current
# artifact: dist
# - download: current
# artifact: pipelines
# - download: current
# artifact: test
# - script: |
# set -x # Echo commands before they are run
# sudo apt-get update
# sudo apt-get install -y build-essential libffi-dev libfuzzy-dev python3-dev
# export VERSION=${BUILD_SOURCEBRANCH#"refs/tags/v"}
# sudo -E env "PATH=$PATH" python -m pip install --no-cache-dir -f $(Pipeline.Workspace)/dist/ "assemblyline-service-client==${VERSION}" -r $(Pipeline.Workspace)/test/requirements.txt
# sudo mkdir -p /etc/assemblyline/
# sudo mkdir -p /var/cache/assemblyline/
# sudo chmod a+rw /var/cache/assemblyline/
# sudo cp $(Pipeline.Workspace)/pipelines/config.yml /etc/assemblyline
# displayName: Install package
# - script: pytest -rsx -vv
# workingDirectory: $(Pipeline.Workspace)/test
# displayName: Test
- stage: deploy
jobs:
- job: deploy
displayName: Deploy packages and containers
variables:
- group: deployment-information
steps:
- download: current
artifact: dist
- script: |
set -xv # Echo commands before they are run
sudo env "PATH=$PATH" python -m pip install --no-cache-dir twine
ls dist
twine upload --skip-existing --repository-url $TEST_REPOSITORY_URL dist/*
workingDirectory: $(Pipeline.Workspace)
displayName: Deploy to Test PyPI
env:
TWINE_USERNAME: $(twineUsername)
TWINE_PASSWORD: $(twinePassword)
- script: |
set -xv # Echo commands before they are run
sudo env "PATH=$PATH" python -m pip install --no-cache-dir twine
ls dist
twine upload --skip-existing dist/*
workingDirectory: $(Pipeline.Workspace)
displayName: Deploy to PyPI
env:
TWINE_USERNAME: $(twineUsername)
TWINE_PASSWORD: $(twinePassword)
37 changes: 37 additions & 0 deletions pipelines/azure-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: tests

trigger: ["*"]
pr: ["*"]

pool:
vmImage: 'ubuntu-18.04'

jobs:
- job: run_test
strategy:
matrix:
python3_7:
python.version: '3.7'
Python3_8:
python.version: '3.8'

timeoutInMinutes: 10

steps:
- task: UsePythonVersion@0
displayName: Set python version
inputs:
versionSpec: '$(python.version)'
- script: |
sudo mkdir -p /etc/assemblyline/
sudo mkdir -p /var/cache/assemblyline/
sudo cp pipelines/config.yml /etc/assemblyline
sudo chmod a+rw /var/cache/assemblyline/
sudo apt-get update
sudo apt-get install -y build-essential libffi-dev libfuzzy-dev python3-dev
sudo env "PATH=$PATH" python -m pip install --no-cache-dir -U pip cython setuptools
sudo env "PATH=$PATH" python -m pip install --no-cache-dir -e .
sudo env "PATH=$PATH" python -m pip install --no-cache-dir -r test/requirements.txt
displayName: Setup environment
- script: python -m pytest -rsx -vv
displayName: Test
4 changes: 4 additions & 0 deletions pipelines/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
logging:
log_to_console: false
log_to_file: false
log_to_syslog: false
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
# For development and local builds use this version number, but for real builds replace it
# with the tag found in the environment
package_version = "4.0.0.dev0"
for variable_name in ['BITBUCKET_TAG']:
package_version = os.environ.get(variable_name, package_version)
package_version = package_version.lstrip('v')
if 'BITBUCKET_TAG' in os.environ:
package_version = os.environ['BITBUCKET_TAG'].lstrip('v')
elif 'BUILD_SOURCEBRANCH' in os.environ:
full_tag_prefix = 'refs/tags/v'
package_version = os.environ['BUILD_SOURCEBRANCH'][len(full_tag_prefix):]


setup(
Expand Down

0 comments on commit 72f8a3c

Please sign in to comment.