From f3ad91d2b0e4a3ec22b27060f9c6e825c5e53f9c Mon Sep 17 00:00:00 2001 From: Steven Gum <14935595+stevengum@users.noreply.github.com> Date: Thu, 23 Jan 2020 13:49:09 -0800 Subject: [PATCH 1/2] Set up CI with Azure Pipelines for Axel [skip ci] --- ci-pr-pipeline.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ci-pr-pipeline.yml diff --git a/ci-pr-pipeline.yml b/ci-pr-pipeline.yml new file mode 100644 index 000000000..7d405f9ee --- /dev/null +++ b/ci-pr-pipeline.yml @@ -0,0 +1,36 @@ +# Python package +# Create and test a Python package on multiple Python versions. +# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- master + +pool: + vmImage: 'ubuntu-latest' +strategy: + matrix: + Python27: + python.version: '2.7' + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' + Python37: + python.version: '3.7' + +steps: +- task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + displayName: 'Use Python $(python.version)' + +- script: | + python -m pip install --upgrade pip + pip install -r requirements.txt + displayName: 'Install dependencies' + +- script: | + pip install pytest pytest-azurepipelines + pytest + displayName: 'pytest' From 69ef6614fda4770ccf7e5b51eec7e312eb4dba03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Su=C3=A1rez?= Date: Thu, 23 Jan 2020 14:18:17 -0800 Subject: [PATCH 2/2] Update pipeline --- ci-pr-pipeline.yml | 129 ++++++++++++++++++++++++++++++++------------- 1 file changed, 93 insertions(+), 36 deletions(-) diff --git a/ci-pr-pipeline.yml b/ci-pr-pipeline.yml index 7d405f9ee..b97d5256f 100644 --- a/ci-pr-pipeline.yml +++ b/ci-pr-pipeline.yml @@ -1,36 +1,93 @@ -# Python package -# Create and test a Python package on multiple Python versions. -# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: -# https://docs.microsoft.com/azure/devops/pipelines/languages/python - -trigger: -- master - -pool: - vmImage: 'ubuntu-latest' -strategy: - matrix: - Python27: - python.version: '2.7' - Python35: - python.version: '3.5' - Python36: - python.version: '3.6' - Python37: - python.version: '3.7' - -steps: -- task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - displayName: 'Use Python $(python.version)' - -- script: | - python -m pip install --upgrade pip - pip install -r requirements.txt - displayName: 'Install dependencies' - -- script: | - pip install pytest pytest-azurepipelines - pytest - displayName: 'pytest' +variables: + # Container registry service connection established during pipeline creation + CI_PULL_REQUEST: $(System.PullRequest.PullRequestId) + COVERALLS_FLAG_NAME: Build \# $(Build.BuildNumber) + COVERALLS_GIT_BRANCH: $(Build.SourceBranchName) + COVERALLS_GIT_COMMIT: $(Build.SourceVersion) + COVERALLS_SERVICE_JOB_ID: $(Build.BuildId) + COVERALLS_SERVICE_NAME: python-ci + python.version: 3.7.6 + + +jobs: +# Build and publish container +- job: Build +#Multi-configuration and multi-agent job options are not exported to YAML. Configure these options using documentation guidance: https://docs.microsoft.com/vsts/pipelines/process/phases + pool: + name: Hosted Ubuntu 1604 + #Your build pipeline references the ‘python.version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 + #Your build pipeline references the ‘python.version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 + + steps: + - powershell: | + Get-ChildItem env:* | sort-object name | Format-Table -Autosize -Wrap | Out-String -Width 120 + displayName: 'Get environment vars' + + - task: UsePythonVersion@0 + displayName: 'Use Python $(python.version)' + inputs: + versionSpec: '$(python.version)' + + - script: 'sudo ln -s /opt/hostedtoolcache/Python/3.6.9/x64/lib/libpython3.6m.so.1.0 /usr/lib/libpython3.6m.so' + displayName: libpython3.6m + + - script: | + python -m pip install --upgrade pip + pip install -e ./libraries/botbuilder-schema + pip install -e ./libraries/botframework-connector + pip install -e ./libraries/botbuilder-core + pip install -e ./libraries/botbuilder-ai + pip install -e ./libraries/botbuilder-applicationinsights + pip install -e ./libraries/botbuilder-dialogs + pip install -e ./libraries/botbuilder-azure + pip install -e ./libraries/botbuilder-testing + pip install -r ./libraries/botframework-connector/tests/requirements.txt + pip install -r ./libraries/botbuilder-core/tests/requirements.txt + pip install coveralls + pip install pylint + pip install black + displayName: 'Install dependencies' + + - script: 'pip install requests_mock' + displayName: 'Install requests mock (REMOVE AFTER MERGING INSPECTION)' + enabled: false + + - script: | + pip install pytest + pip install pytest-cov + pip install coveralls + pytest --junitxml=junit/test-results.xml --cov-config=.coveragerc --cov --cov-report=xml --cov-report=html + displayName: Pytest + + - script: 'black --check libraries' + displayName: 'Check Black compliant' + + - script: 'pylint --rcfile=.pylintrc libraries' + displayName: Pylint + + - task: PublishTestResults@2 + displayName: 'Publish Test Results **/test-results.xml' + inputs: + testResultsFiles: '**/test-results.xml' + testRunTitle: 'Python $(python.version)' + + - script: 'COVERALLS_REPO_TOKEN=$(COVERALLS_TOKEN) coveralls' + displayName: 'Push test results to coveralls https://coveralls.io/github/microsoft/botbuilder-python' + continueOnError: true + + - powershell: | + Set-Location .. + Get-ChildItem -Recurse -Force + + displayName: 'Dir workspace' + condition: succeededOrFailed() + + - powershell: | + # This task copies the code coverage file created by dotnet test into a well known location. In all + # checks I've done, dotnet test ALWAYS outputs the coverage file to the temp directory. + # My attempts to override this and have it go directly to the CodeCoverage directory have + # all failed, so I'm just doing the copy here. (cmullins) + + Get-ChildItem -Path "$(Build.SourcesDirectory)" -Include "*coverage*" | Copy-Item -Destination "$(Build.ArtifactStagingDirectory)/CodeCoverage" + displayName: 'Copy .coverage Files to CodeCoverage folder' + continueOnError: true