8000 ci: Use Azure Pipelines by tonyo · Pull Request #305 · getsentry/sentry-python · GitHub
[go: up one dir, main page]

Skip to content

ci: Use Azure Pipelines #305

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 6 commits into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ matrix:
- export TRAVIS_PYTHON_VERSION=2.7

before_script:
- psql -c 'create database travis_ci_test;' -U postgres
- psql -c 'create database test_travis_ci_test;' -U postgres
- psql -c 'create database travis_ci_test;' -U postgres
- psql -c 'create database 10000 test_travis_ci_test;' -U postgres

services:
- postgresql

install:
- pip install tox
- pip install codecov
- sh scripts/download-semaphore.sh
- bash scripts/download-semaphore.sh

script:
- coverage erase
Expand Down
79 changes: 79 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 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

pr: none

resources:
containers:
- container: postgres
image: "postgres:9.6"
ports:
- 5432:5432

jobs:
- job: run_tests
displayName: Tests
pool:
vmImage: "Ubuntu-16.04"
services:
postgres: postgres
strategy:
matrix:
Python27:
python.version: "2.7"
Python34:
python.version: "3.4"
Python35:
python.version: "3.5"
Python36:
python.version: "3.6"
Python37:
python.version: "3.7"
# Python 3.8 and PyPy will be soon added to the base VM image:
# https://github.com/Microsoft/azure-pipelines-tasks/pull/9866
Python38:
python.version: "3.8-dev"
PyPy2:
python.version: "pypy2"

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: "$(python.version)"
architecture: "x64"

- script: |
set -eux
docker ps -a
docker images -a
# FIXME: theoretically we can run psql commands from a docker container, but
# name resolution is a bit tricky here
sudo apt install -y postgresql-client
psql -c 'create database travis_ci_test;' -U postgres -h localhost
psql -c 'create database test_travis_ci_test;' -U postgres -h localhost
displayName: "Create Postgres users"

- script: |
set -eux
python --version
pip --version
pip install tox
pip install codecov
sh scripts/download-semaphore.sh
displayName: "Install dependencies"

- script: |
set -eux
coverage erase
./scripts/runtox.sh '' --cov=sentry_sdk --cov-report= --cov-branch
codecov --file .coverage*
env:
SENTRY_PYTHON_TEST_POSTGRES_USER: postgres
SENTRY_PYTHON_TEST_POSTGRES_NAME: travis_ci_test
AZURE_PYTHON_VERSION: "$(python.version)"
displayName: "Run tests"
5 changes: 3 additions & 2 deletions scripts/download-semaphore.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/bash

set -e

if [ "$TRAVIS" = true ] && [ -z "$GITHUB_API_TOKEN" ]; then
if { [ "$TRAVIS" == "true" ] || [ "$TF_BUILD" == "True" ]; } && [ -z "$GITHUB_API_TOKEN" ]; then
echo "Not running on external pull request"
exit 0;
fi
Expand All @@ -20,11 +19,13 @@ echo "$output"

output="$(echo "$output" \
| grep "$(uname -s)" \
| grep -v "\.zip" \
| grep "download" \
| cut -d : -f 2,3 \
| tr -d , \
| tr -d \")"

echo "$output"
echo "$output" | wget -i - -O $target
[ -s $target ]
chmod +x $target
10 changes: 6 additions & 4 deletions scripts/runtox.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -e
set -ex

if [ -n "$TOXPATH" ]; then
true
Expand All @@ -12,10 +12,12 @@ fi
# Usage: sh scripts/runtox.sh py3.7 <pytest-args>
# Runs all environments with substring py3.7 and the given arguments for pytest

if [ -z "$1" ] && [ -n "$TRAVIS_PYTHON_VERSION" ]; then
searchstring="$(echo py$TRAVIS_PYTHON_VERSION | sed -e 's/pypypy/pypy/g' -e 's/-dev//g')"
else
if [ -n "$1" ]; then
searchstring="$1"
elif [ -n "$TRAVIS_PYTHON_VERSION" ]; then
searchstring="$(echo py$TRAVIS_PYTHON_VERSION | sed -e 's/pypypy/pypy/g' -e 's/-dev//g')"
elif [ -n "$AZURE_PYTHON_VERSION" ]; then
searchstring="$(echo py$AZURE_PYTHON_VERSION | sed -e 's/pypypy/pypy/g' -e 's/-dev//g')"
fi

exec $TOXPATH -e $($TOXPATH -l | grep "$searchstring" | tr '\n' ',') -- "${@:2}"
2 changes: 2 additions & 0 deletions tests/integrations/django/myapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def process_response(self, request, response):
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": os.environ["SENTRY_PYTHON_TEST_POSTGRES_NAME"],
"USER": os.environ["SENTRY_PYTHON_TEST_POSTGRES_USER"],
"HOST": "localhost",
"PORT": 5432,
}
except (ImportError, KeyError):
pass
Expand Down
0