зеркало из https://github.com/Azure/blobxfer.git
370 строки
17 KiB
YAML
370 строки
17 KiB
YAML
name: $(SourceBranch)$(Rev:.r)
|
|
|
|
jobs:
|
|
- job: ComponentGovernance
|
|
pool:
|
|
vmImage: vs2017-win2016
|
|
condition: ne(variables['Build.Reason'], 'PullRequest')
|
|
variables:
|
|
EnableDetectorPip: true
|
|
continueOnError: true
|
|
steps:
|
|
- task: ComponentGovernanceComponentDetection@0
|
|
displayName: 'CG Component Detection'
|
|
- job: Windows
|
|
pool:
|
|
vmIamge: vs2017-win2016
|
|
strategy:
|
|
maxParallel: 1
|
|
matrix:
|
|
Python37:
|
|
python.version: '3.7'
|
|
PYENV_VERSION: '3.7.4'
|
|
PYTOX_ENV: 'py37'
|
|
VENV_VERSION: '16.2.0'
|
|
steps:
|
|
- task: InstallPython@1
|
|
inputs:
|
|
version: 'python==$(PYENV_VERSION)'
|
|
- powershell: |
|
|
gci env:* | sort-object name
|
|
python --version
|
|
python -m pip install --upgrade pip
|
|
python -m pip install --upgrade setuptools wheel
|
|
python -m pip install codecov tox
|
|
python -m pip list --format=columns --outdated
|
|
displayName: Fetch Dependencies
|
|
- powershell: |
|
|
tox -e $env:PYTOX_ENV
|
|
displayName: Unit Tests
|
|
- powershell: |
|
|
if($env:BUILD_SOURCEBRANCHNAME -eq "master")
|
|
{
|
|
echo "##vso[task.setvariable variable=DOCKER_TAG;]latest"
|
|
}
|
|
else
|
|
{
|
|
echo "##vso[task.setvariable variable=DOCKER_TAG;]$env:BUILD_SOURCEBRANCHNAME"
|
|
}
|
|
$artifactCli = "blobxfer-" + $env:BUILD_SOURCEBRANCHNAME + "-" + $env:BUILD_BUILDID + "-win-amd64.exe"
|
|
$artifactUploadPath = "builds/" + $env:BUILD_SOURCEBRANCHNAME
|
|
$buildverDotted = "0.0.0"
|
|
$bvt0,$bvt1,$bvt2 = $buildverDotted.split('.')
|
|
$buildverTuple = [string]::Format("({0}, {1}, {2}, {3})",$bvt0,$bvt1,$bvt2,$env:BUILD_BUILDID)
|
|
echo "##vso[task.setvariable variable=BUILDVER_DOTTED;]$buildverDotted"
|
|
echo "##vso[task.setvariable variable=BUILDVER_TUPLE;]$buildverTuple"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_CLI;]$artifactCli"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_UPLOAD_PATH;]$artifactUploadPath"
|
|
displayName: Pre-build Environment (Branch)
|
|
condition: >
|
|
and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual'),
|
|
in(variables['Build.SourceBranchName'], 'master', 'develop'), eq(variables['python.version'], '3.7'))
|
|
- powershell: |
|
|
git tag -l --points-at $env:BUILD_SOURCEVERSION | Tee-Object -Variable gitTag
|
|
$gitTag -match "^([\d\.])+"
|
|
$buildverDotted = $matches[0]
|
|
$artifactCli = "blobxfer-" + $gitTag + "-win-amd64.exe"
|
|
$artifactUploadPath = "releases/" + $gitTag
|
|
$bvt0,$bvt1,$bvt2 = $buildverDotted.split('.')
|
|
$buildverTuple = [string]::Format("({0}, {1}, {2}, {3})",$bvt0,$bvt1,$bvt2,$env:BUILD_BUILDID)
|
|
echo "##vso[task.setvariable variable=BUILDVER_DOTTED;]$buildverDotted"
|
|
echo "##vso[task.setvariable variable=BUILDVER_TUPLE;]$buildverTuple"
|
|
echo "##vso[task.setvariable variable=GIT_TAG;]$gitTag"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_CLI;]$artifactCli"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_UPLOAD_PATH;]$artifactUploadPath"
|
|
echo "##vso[task.setvariable variable=DOCKER_TAG;]$gitTag"
|
|
displayName: Pre-build Environment (Tagged Release)
|
|
condition: >
|
|
and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual'),
|
|
startsWith(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['python.version'], '3.7'))
|
|
- powershell: |
|
|
$artifactCliPath = "bin\\" + $env:ARTIFACT_CLI
|
|
echo "##vso[task.setvariable variable=ARTIFACT_CLI_PATH;]$artifactCliPath"
|
|
$branchGitSha1 = [string]::Format("{0}@{1}",$env:BUILD_SOURCEBRANCHNAME,$env:BUILD_SOURCEVERSION.Substring(0,7))
|
|
echo "$env:ARTIFACT_CLI $env:BUILDVER_TUPLE $branchGitSha1"
|
|
$fileverInfo = "cli\\file_version_info.txt"
|
|
(Get-Content $fileverInfo).replace('{BUILDVER_TUPLE}', $env:BUILDVER_TUPLE) | Set-Content $fileverInfo
|
|
(Get-Content $fileverInfo).replace('{BUILDVER_DOTTED}', $env:BUILDVER_DOTTED) | Set-Content $fileverInfo
|
|
(Get-Content $fileverInfo).replace('{BRANCH_GITSHA1}', $branchGitSha1) | Set-Content $fileverInfo
|
|
(Get-Content $fileverInfo).replace('{EXE}', $env:ARTIFACT_CLI) | Set-Content $fileverInfo
|
|
if(Test-Path env:VENV_VERSION)
|
|
{
|
|
python -m pip install virtualenv==$env:VENV_VERSION
|
|
}
|
|
else
|
|
{
|
|
python -m pip install virtualenv
|
|
}
|
|
python -m virtualenv pyi
|
|
displayName: Pre-build
|
|
condition: and(succeeded(), ne(variables['ARTIFACT_CLI'], ''))
|
|
- script: |
|
|
echo "ARTIFACT_CLI=%ARTIFACT_CLI% ARTIFACT_CLI_PATH=%ARTIFACT_CLI_PATH% ARTIFACT_UPLOAD_PATH=%ARTIFACT_UPLOAD_PATH%"
|
|
call pyi\\Scripts\\activate.bat
|
|
pip -V
|
|
pip install --no-cache-dir pyinstaller
|
|
pip install --no-cache-dir -e .
|
|
pyinstaller -F -n "%ARTIFACT_CLI%" -p blobxfer -p cli --additional-hooks-dir blobxfer --exclude-module future.tests --exclude-module future.backports.test --exclude-module future.moves.test --icon cli\\azure.ico --version-file cli\\file_version_info.txt --distpath bin cli\\cli.py
|
|
call pyi\\Scripts\\deactivate.bat
|
|
"%ARTIFACT_CLI_PATH%" upload --storage-account "$(blobxfer.storageAccount)" --storage-account-key "$(blobxfer.storageAccountKey)" --remote-path "%ARTIFACT_UPLOAD_PATH%" --local-path "%ARTIFACT_CLI_PATH%" --strip-components 1 --file-md5 --overwrite
|
|
displayName: Build
|
|
condition: and(succeeded(), ne(variables['ARTIFACT_CLI'], ''))
|
|
- powershell: |
|
|
$versionTag = "bin\\version_tag.txt"
|
|
$env:GIT_TAG | Out-File $versionTag -Force -NoNewline
|
|
Get-Content -Path $versionTag
|
|
copy .vsts\\populate_tag.ps1 bin\\populate_tag.ps1
|
|
dir bin
|
|
displayName: Generate Version Tag File
|
|
condition: and(succeeded(), ne(variables['GIT_TAG'], ''))
|
|
- task: PublishBuildArtifacts@1
|
|
inputs:
|
|
pathtoPublish: bin
|
|
artifactName: Blobxfer-Windows
|
|
condition: and(succeeded(), ne(variables['ARTIFACT_CLI'], ''))
|
|
- powershell: |
|
|
docker version
|
|
docker login "$(docker.servername)" -u="$(docker.username)" -p="$(docker.password)"
|
|
$cliImage = "$(docker.servername)/public/blobxfer:" + $env:DOCKER_TAG + "-windows"
|
|
echo "Building Docker image: $cliImage"
|
|
pushd docker\\win
|
|
docker build --build-arg GIT_BRANCH=$env:BUILD_SOURCEBRANCHNAME --build-arg GIT_COMMIT=$env:BUILD_SOURCEVERSION -t $cliImage .
|
|
docker push $cliImage
|
|
popd
|
|
displayName: Docker Build
|
|
condition: and(succeeded(), ne(variables['DOCKER_TAG'], ''))
|
|
|
|
- job: Linux
|
|
pool:
|
|
vmImage: ubuntu-16.04
|
|
strategy:
|
|
maxParallel: 1
|
|
matrix:
|
|
Python37:
|
|
python.version: '3.7'
|
|
PYENV_VERSION: '3.7.4'
|
|
PYTOX_ENV: 'py37'
|
|
VENV_VERSION: '16.2.0'
|
|
steps:
|
|
- task: UsePythonVersion@0
|
|
inputs:
|
|
versionSpec: $(python.version)
|
|
architecture: x64
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
env
|
|
if [[ "$PYENV_VERSION" == 3.* ]]; then
|
|
which python3
|
|
python3 --version
|
|
echo "##vso[task.setvariable variable=PYTHON;]python3"
|
|
echo "##vso[task.setvariable variable=PIP;]pip3"
|
|
else
|
|
which python
|
|
python --version
|
|
echo "##vso[task.setvariable variable=PYTHON;]python"
|
|
echo "##vso[task.setvariable variable=PIP;]pip"
|
|
fi
|
|
ls -alFR
|
|
displayName: Initialize Build
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
echo "PATH=$PATH"
|
|
echo "PYTHON=$PYTHON PIP=$PIP"
|
|
$PYTHON -m pip install --upgrade pip
|
|
$PIP install --upgrade setuptools wheel
|
|
$PIP install codecov tox
|
|
$PIP list --format=columns --outdated
|
|
displayName: Fetch Dependencies
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
tox -e $PYTOX_ENV
|
|
codecov -t $(codecov.uploadToken)
|
|
displayName: Unit Tests
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
if [ "$BUILD_SOURCEBRANCHNAME" == "master" ]; then
|
|
echo "##vso[task.setvariable variable=DOCKER_TAG;]latest"
|
|
else
|
|
echo "##vso[task.setvariable variable=DOCKER_TAG;]${BUILD_SOURCEBRANCHNAME}"
|
|
fi
|
|
ARTIFACT_CLI="blobxfer-${BUILD_SOURCEBRANCHNAME}-${BUILD_BUILDID}-linux-x86_64"
|
|
ARTIFACT_UPLOAD_PATH="builds/${BUILD_SOURCEBRANCHNAME}"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_CLI;]${ARTIFACT_CLI}"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_UPLOAD_PATH;]${ARTIFACT_UPLOAD_PATH}"
|
|
echo "ARTIFACT_CLI=$ARTIFACT_CLI ARTIFACT_UPLOAD_PATH=$ARTIFACT_UPLOAD_PATH DOCKER_TAG=$DOCKER_TAG"
|
|
displayName: Pre-build Environment (Branch)
|
|
condition: >
|
|
and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual'),
|
|
in(variables['Build.SourceBranchName'], 'master', 'develop'), eq(variables['python.version'], '3.7'))
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
GIT_TAG=$(git tag -l --points-at $BUILD_SOURCEVERSION)
|
|
ARTIFACT_CLI="blobxfer-${GIT_TAG}-linux-x86_64"
|
|
ARTIFACT_UPLOAD_PATH="releases/${GIT_TAG}"
|
|
echo "##vso[task.setvariable variable=GIT_TAG;]${GIT_TAG}"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_CLI;]${ARTIFACT_CLI}"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_UPLOAD_PATH;]${ARTIFACT_UPLOAD_PATH}"
|
|
echo "##vso[task.setvariable variable=DOCKER_TAG;]${GIT_TAG}"
|
|
echo "ARTIFACT_CLI=$ARTIFACT_CLI ARTIFACT_UPLOAD_PATH=$ARTIFACT_UPLOAD_PATH DOCKER_TAG=$DOCKER_TAG GIT_TAG=$GIT_TAG"
|
|
displayName: Pre-build Environment (Tagged Release)
|
|
condition: >
|
|
and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual'),
|
|
startsWith(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['python.version'], '3.7'))
|
|
- template: ./pyenv.yml
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
ARTIFACT_CLI_PATH="bin/${ARTIFACT_CLI}"
|
|
if [ -z "$VENV_VERSION" ]; then
|
|
$PIP install virtualenv
|
|
else
|
|
$PIP install virtualenv==${VENV_VERSION}
|
|
fi
|
|
$PYTHON -m virtualenv -p $PYTHON pyi
|
|
/bin/bash -c \
|
|
"set -e; source pyi/bin/activate; \
|
|
pip install pyinstaller; \
|
|
pip install --no-cache-dir -e .; \
|
|
pyinstaller -F -n ${ARTIFACT_CLI} -p blobxfer -p cli --additional-hooks-dir blobxfer --exclude-module future.tests --exclude-module future.backports.test --exclude-module future.moves.test --distpath bin cli/cli.py; \
|
|
deactivate"
|
|
chmod +x ${ARTIFACT_CLI_PATH}
|
|
sha256sum ${ARTIFACT_CLI_PATH} | cut -d' ' -f1 > ${ARTIFACT_CLI_PATH}.sha256
|
|
cat ${ARTIFACT_CLI_PATH}.sha256
|
|
export BLOBXFER_STORAGE_ACCOUNT=$(blobxfer.storageAccount)
|
|
export BLOBXFER_STORAGE_ACCOUNT_KEY="$(blobxfer.storageAccountKey)"
|
|
${ARTIFACT_CLI_PATH} upload --remote-path ${ARTIFACT_UPLOAD_PATH} --local-path ${ARTIFACT_CLI_PATH} --strip-components 1 --file-md5 --file-attributes --overwrite
|
|
displayName: Build
|
|
condition: and(succeeded(), ne(variables['ARTIFACT_CLI'], ''))
|
|
- task: PublishBuildArtifacts@1
|
|
inputs:
|
|
pathtoPublish: bin
|
|
artifactName: Blobxfer-Linux
|
|
condition: and(succeeded(), ne(variables['ARTIFACT_CLI'], ''))
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
docker version
|
|
docker login "$(docker.servername)" -u="$(docker.username)" -p="$(docker.password)"
|
|
cliImage="$(docker.servername)/public/blobxfer:$DOCKER_TAG"
|
|
echo "Building Docker image: $cliImage"
|
|
pushd docker/linux
|
|
docker build --build-arg GIT_BRANCH=$BUILD_SOURCEBRANCHNAME --build-arg GIT_COMMIT=$BUILD_SOURCEVERSION -t $cliImage .
|
|
docker push $cliImage
|
|
popd
|
|
displayName: Docker Build
|
|
condition: and(succeeded(), ne(variables['DOCKER_TAG'], ''))
|
|
- task: PyPIPublisher@0
|
|
inputs:
|
|
pypiConnection: PyPI
|
|
packageDirectory: .
|
|
alsoPublishWheel: true
|
|
condition: and(succeeded(), ne(variables['GIT_TAG'], ''))
|
|
|
|
- job: MacOS
|
|
pool:
|
|
vmImage: macOS-10.13
|
|
strategy:
|
|
maxParallel: 1
|
|
matrix:
|
|
Python37:
|
|
python.version: '3.7'
|
|
PYENV_VERSION: '3.7.4'
|
|
PYTOX_ENV: 'py37'
|
|
VENV_VERSION: '16.2.0'
|
|
steps:
|
|
- task: UsePythonVersion@0
|
|
inputs:
|
|
versionSpec: $(python.version)
|
|
architecture: x64
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
env
|
|
if [[ "$PYENV_VERSION" == 3.* ]]; then
|
|
which python3
|
|
python3 --version
|
|
echo "##vso[task.setvariable variable=PYTHON;]python3"
|
|
echo "##vso[task.setvariable variable=PIP;]pip3"
|
|
else
|
|
which python
|
|
python --version
|
|
echo "##vso[task.setvariable variable=PYTHON;]python"
|
|
echo "##vso[task.setvariable variable=PIP;]pip"
|
|
fi
|
|
ls -alFR
|
|
displayName: Initialize Build
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
echo "PATH=$PATH"
|
|
echo "PYTHON=$PYTHON PIP=$PIP"
|
|
$PYTHON -m pip install --upgrade pip
|
|
$PIP install --upgrade setuptools wheel
|
|
$PIP install codecov tox
|
|
$PIP list --format=columns --outdated
|
|
displayName: Fetch Dependencies
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
tox -e $PYTOX_ENV
|
|
displayName: Unit Tests
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
ARTIFACT_CLI="blobxfer-${BUILD_SOURCEBRANCHNAME}-${BUILD_BUILDID}-mac-x86_64"
|
|
ARTIFACT_UPLOAD_PATH="builds/${BUILD_SOURCEBRANCHNAME}"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_CLI;]${ARTIFACT_CLI}"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_UPLOAD_PATH;]${ARTIFACT_UPLOAD_PATH}"
|
|
echo "ARTIFACT_CLI=$ARTIFACT_CLI ARTIFACT_UPLOAD_PATH=$ARTIFACT_UPLOAD_PATH"
|
|
displayName: Pre-build Environment (Branch)
|
|
condition: >
|
|
and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual'),
|
|
in(variables['Build.SourceBranchName'], 'master', 'develop'), eq(variables['python.version'], '3.7'))
|
|
- script: |
|
|
GIT_TAG=$(git tag -l --points-at $BUILD_SOURCEVERSION)
|
|
ARTIFACT_CLI="blobxfer-${GIT_TAG}-mac-x86_64"
|
|
ARTIFACT_UPLOAD_PATH="releases/${GIT_TAG}"
|
|
echo "##vso[task.setvariable variable=GIT_TAG;]${GIT_TAG}"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_CLI;]${ARTIFACT_CLI}"
|
|
echo "##vso[task.setvariable variable=ARTIFACT_UPLOAD_PATH;]${ARTIFACT_UPLOAD_PATH}"
|
|
displayName: Pre-build Environment (Tagged Release)
|
|
condition: >
|
|
and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual'),
|
|
startsWith(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['python.version'], '3.7'))
|
|
- template: ./pyenv.yml
|
|
- script: |
|
|
set -e
|
|
set -o pipefail
|
|
echo "ARTIFACT_CLI=$ARTIFACT_CLI ARTIFACT_UPLOAD_PATH=$ARTIFACT_UPLOAD_PATH GIT_TAG=$GIT_TAG"
|
|
ARTIFACT_CLI_PATH="bin/${ARTIFACT_CLI}"
|
|
if [ -z "$VENV_VERSION" ]; then
|
|
$PIP install virtualenv
|
|
else
|
|
$PIP install virtualenv==${VENV_VERSION}
|
|
fi
|
|
$PYTHON -m virtualenv -p $PYTHON pyi
|
|
/bin/bash -c \
|
|
"set -e; source pyi/bin/activate; \
|
|
pip install pyinstaller; \
|
|
pip install --no-cache-dir -e .; \
|
|
pyinstaller -F -n ${ARTIFACT_CLI} -p blobxfer -p cli --additional-hooks-dir blobxfer --exclude-module future.tests --exclude-module future.backports.test --exclude-module future.moves.test --distpath bin cli/cli.py; \
|
|
deactivate"
|
|
chmod +x ${ARTIFACT_CLI_PATH}
|
|
shasum -a 256 ${ARTIFACT_CLI_PATH} | cut -d' ' -f1 > ${ARTIFACT_CLI_PATH}.sha256
|
|
cat ${ARTIFACT_CLI_PATH}.sha256
|
|
export BLOBXFER_STORAGE_ACCOUNT=$(blobxfer.storageAccount)
|
|
export BLOBXFER_STORAGE_ACCOUNT_KEY="$(blobxfer.storageAccountKey)"
|
|
${ARTIFACT_CLI_PATH} upload --remote-path ${ARTIFACT_UPLOAD_PATH} --local-path ${ARTIFACT_CLI_PATH} --strip-components 1 --file-md5 --file-attributes --overwrite
|
|
displayName: Build
|
|
condition: and(succeeded(), ne(variables['ARTIFACT_CLI'], ''))
|
|
- task: PublishBuildArtifacts@1
|
|
inputs:
|
|
pathtoPublish: bin
|
|
artifactName: Blobxfer-MacOS
|
|
condition: and(succeeded(), ne(variables['ARTIFACT_CLI'], ''))
|