Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e5e34f6
Pipelines on a branch
egrubbs Jul 10, 2019
07a4a72
Update azure-pipelines-1.yml for Azure Pipelines
egrubbs Jul 10, 2019
5d2bf09
Run Miniconda in batch mode to eliminate prompts
egrubbs Jul 10, 2019
7307784
Fixed conda env update
egrubbs Jul 10, 2019
2908a71
No requirements.txt for pip
egrubbs Jul 10, 2019
1982b2b
activate conda env
egrubbs Jul 10, 2019
01e3ed1
Fixed conda activate and quieted wget and conda env update
egrubbs Jul 10, 2019
89cbfd8
Eliminated duplicate azure-pipelines-1.yml
egrubbs Jul 10, 2019
2249cbe
Added tests and trying to activate conda right before tests.
egrubbs Jul 10, 2019
535b7d3
Switched to pytest
egrubbs Jul 10, 2019
050e42c
Changed azure-pipelines.yml to find output xml from pytest-azurepipel…
egrubbs Jul 10, 2019
0347b84
Added pytest.ini and pytest-cov
egrubbs Jul 10, 2019
b66205c
Report code coverage even if tests fail.
egrubbs Jul 10, 2019
e531063
Changed azure-pipelines.yml code coverage tool specification.
egrubbs Jul 10, 2019
8912013
Changed pool to TradeMetrics-Build
egrubbs Jul 11, 2019
8cbebcf
Removed matrix config from azure-pipelines.yml
egrubbs Jul 11, 2019
5e5dd78
Removed versionSpec
egrubbs Jul 11, 2019
fc25283
Added back maxParallel
egrubbs Jul 11, 2019
26f0172
Removed task to check the version
egrubbs Jul 11, 2019
9b554b3
Do not use inline script to find manage.py.
egrubbs Jul 11, 2019
c97f932
sudo not installed
egrubbs Jul 11, 2019
363d8df
Added bzip2 (bunzip2) needed for Miniconda.
egrubbs Jul 11, 2019
78207c7
Clean out /root/miniconda3
egrubbs Jul 11, 2019
4706ea7
Attempt to change the bash interpreter used by the azure pipelines `s…
egrubbs Oct 8, 2019
08d23b5
Use vmImage instead of a self-hosted agent
egrubbs Oct 8, 2019
5172324
Test env vars
egrubbs Oct 8, 2019
788c67d
Fixed path
egrubbs Oct 8, 2019
30c3b13
Fixed path again
egrubbs Oct 8, 2019
1ffd93e
Try to diagnose "Arguments too long" error related to env vars
egrubbs Oct 9, 2019
28a128a
Test fakebin/bash
egrubbs Oct 9, 2019
ebb9183
Move bash GNU long options before the short options
egrubbs Oct 9, 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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.swp
*.swo
*.pyc
__pycache__
79 changes: 54 additions & 25 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,79 @@ trigger:
- master

pool:
#name: TradeMetrics-Build
vmImage: 'ubuntu-latest'


strategy:
matrix:
Python35:
PYTHON_VERSION: '3.5'
Python37:
PYTHON_VERSION: '3.7'
maxParallel: 3

variables:
DEBIAN_FRONTEND: 'noninteractive'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(PYTHON_VERSION)'
architecture: 'x64'

- task: PythonScript@0
displayName: 'Export project path'
inputs:
scriptSource: 'inline'
script: |
"""Search all subdirectories for `manage.py`."""
from glob import iglob
from os import path
# Python >= 3.5
manage_py = next(iglob(path.join('**', 'manage.py'), recursive=True), None)
if not manage_py:
raise SystemExit('Could not find a Django project')
project_location = path.dirname(path.abspath(manage_py))
print('Found Django project in', project_location)
print('##vso[task.setvariable variable=projectRoot]{}'.format(project_location))
- script: |
set -x
# The total size of the env variables must be less than ARG_MAX
# or you will get an "Argument list too long" error.
# This is normally 2097152 bytes (2,048 KB). A single env variable
# is must be no greater than 1/16 of ARG_MAX or 128 KB.
getconf ARG_MAX
env | wc -c
echo "TESTPATH=$TESTPATH"
echo "DEBIAN_FRONTEND=$DEBIAN_FRONTEND"
displayName: 'Display env'
env:
TESTPATH: '$(System.DefaultWorkingDirectory)/fakebin'

- script: |
echo "Test script"
date
ls
pwd
which env
echo "GLOB TEST:" *
env | sort
displayName: 'Test script task'
env:
PATH: '$(System.DefaultWorkingDirectory)/fakebin:/usr/share/rust/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin'

- script: |
DEBIAN_FRONTEND=noninteractive apt update
DEBIAN_FRONTEND=noninteractive apt install -y wget bzip2
wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
rm -Rf /root/miniconda3
bash Miniconda3-latest-Linux-x86_64.sh -b
source $HOME/miniconda3/bin/activate
conda env update -q -f server/environment.yml > /dev/null
source /home/vsts/miniconda3/etc/profile.d/conda.sh
conda activate
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
pip install unittest-xml-reporting
displayName: 'Install prerequisites'

- script: |
pushd '$(projectRoot)'
python manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input
pushd 'server'
source /home/vsts/miniconda3/etc/profile.d/conda.sh
conda activate
#python manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input
pytest -vv
displayName: 'Run tests'

- task: PublishTestResults@2
inputs:
testResultsFiles: "**/TEST-*.xml"
testResultsFiles: "**/test-*.xml"
testRunTitle: 'Python $(PYTHON_VERSION)'
condition: succeededOrFailed()

- task: PublishCodeCoverageResults@1
inputs:
# pytest-cov creates a coverage.xml file in the same format as Cobertura.
codeCoverageTool: Cobertura
summaryFileLocation: '**/coverage.xml'
reportDirectory: '**/htmlcov'
condition: succeededOrFailed()
29 changes: 29 additions & 0 deletions fakebin/bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -x
echo "OVERRIDE bash interpreter"
echo "ARGS: $0 $*"
echo "PWD: $PWD"
echo "PATH=$PATH"
which bash
PATH=/bin:/usr/bin
echo "new PATH=$PATH"
which bash
cd /usr
echo "Arg count: $#"
start_args=${@:1:$[ $# - 1 ]}
echo "All but last arg: $start_args"
last_arg=${@:$#:$[ $# + 1 ]}
echo "Last arg: $last_arg"

# Bash does not allow "GNU long options" such as "--norc"
# to be after short options such as "-x".
echo "Do not execute, just evaluate:"
/bin/bash $start_args -nv $last_arg

echo "Execute without GLOB support:"
/bin/bash $start_args -xf $last_arg

echo "Execute with GLOB support:"
/bin/bash $start_args -x $last_arg

10 changes: 10 additions & 0 deletions server/citrial/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@



def foo():
x = 1
return x

def bar():
y = 2
return y
15 changes: 15 additions & 0 deletions server/citrial/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from unittest import TestCase


class TestPractice(TestCase):
def testGood(self):
self.assertEqual(1, 1)

def testBad(self):
self.assertEqual(1, 0)


def test_pytest_testfinder():
from citrial.models import foo
foo()
assert 1 == 0
2 changes: 2 additions & 0 deletions server/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ dependencies:
- gunicorn
- pytest
- pytest-django
- pytest-azurepipelines
- pytest-cov
- pandas
- xlrd
- ujson
Expand Down
8 changes: 8 additions & 0 deletions server/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[pytest]
DJANGO_SETTINGS_MODULE=citrial.settings

# Use conftest.py to ignore directories or files.
# https://docs.pytest.org/en/latest/example/pythoncollection.html#customizing-test-collection
python_files = tests.py test_*.py *_tests.py
#addopts = -q -r fExXp --disable-warnings --disable-pytest-warnings --showlocals --no-migrations
addopts = --durations=0 -r fExXp --tb=line --capture=no --doctest-modules --disable-warnings --disable-pytest-warnings --showlocals --reuse-db --cov=citrial --cov-report=html