summaryrefslogtreecommitdiff
path: root/.appveyor.yml
blob: d2c63cb5e07b88e7c367d43df9fcae3ecad5090e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#version: '3.0.1.{build}'

image:
  # linux builds disabled for now 
  # - Ubuntu
  - Visual Studio 2015
  - Visual Studio 2017

cache:
  - downloads -> appveyor.yml
  - '%LOCALAPPDATA%\pip\Cache'
  - C:\ProgramData\chocolatey\bin -> appveyor.yml
  - C:\ProgramData\chocolatey\lib -> appveyor.yml

install:
  ### WINDOWS ###
  # add python and python user-base to path for pip installs
  - cmd: "C:\\%WINPYTHON%\\python.exe --version"
  - cmd: for /F "tokens=*" %%g in ('C:\\%WINPYTHON%\\python.exe -m site --user-site') do (set PYSITEDIR=%%g)
  # use mingw 32 bit until #3291 is resolved
  - cmd: "set PATH=C:\\%WINPYTHON%;C:\\%WINPYTHON%\\Scripts;C:\\ProgramData\\chocolatey\\bin;C:\\MinGW\\bin;C:\\MinGW\\msys\\1.0\\bin;C:\\cygwin\\bin;%PATH%"
  - cmd: "C:\\%WINPYTHON%\\python.exe -m pip install -U --progress-bar off pip setuptools wheel "
  - cmd: "C:\\%WINPYTHON%\\python.exe -m pip install -U --progress-bar off pypiwin32 coverage codecov"
  - cmd: set STATIC_DEPS=true & C:\\%WINPYTHON%\\python.exe -m pip install -U --progress-bar off lxml
  # install 3rd party tools to test with
  - cmd: choco install --allow-empty-checksums dmd ldc swig vswhere xsltproc winflexbison
  - cmd: set

  ### LINUX ###
  - sh: sudo add-apt-repository -y ppa:deadsnakes/ppa
  # allow the CI to continue even if some pkg in the pkglist may not be up to date
  - sh: sudo apt-get update || true
  - sh: sudo apt-get -y install python$PYTHON
  - sh: wget https://bootstrap.pypa.io/get-pip.py
  - sh: sudo -H python$PYTHON get-pip.py
  - sh: which python$PYTHON
  - sh: python$PYTHON --version
  - sh: export PYSITEDIR=$(python$PYTHON -m site --user-site)
  - sh: python$PYTHON -m pip install --user -U --progress-bar off pip setuptools wheel 
  - sh: python$PYTHON -m pip install --user -U --progress-bar off coverage codecov
  - sh: STATIC_DEPS=true python$PYTHON -m pip install --user -U --progress-bar off lxml
  - sh: ./.travis/install.sh
  - sh: printenv

# build matrix will be number of images multiplied 
# by each '-' below, split jobs into groups of 4
# to avoid timeing out
environment:
  matrix:
    - WINPYTHON: "Python27"
      PYTHON: "2.7"
      PYVER: 27
      BUILD_JOB_NUM: 1
      COVERAGE: 1
    - WINPYTHON: "Python27"
      PYTHON: "2.7"
      PYVER: 27
      BUILD_JOB_NUM: 2
      COVERAGE: 1
    - WINPYTHON: "Python27"
      PYTHON: "2.7"
      PYVER: 27
      BUILD_JOB_NUM: 3
      COVERAGE: 1
    - WINPYTHON: "Python27"
      PYTHON: "2.7"
      PYVER: 27
      BUILD_JOB_NUM: 4
      COVERAGE: 1

    - WINPYTHON: "Python36"
      PYTHON: "3.6"
      PYVER: 36
      BUILD_JOB_NUM: 1
      COVERAGE: 1
    - WINPYTHON: "Python36"
      PYTHON: "3.6"
      PYVER: 36
      BUILD_JOB_NUM: 2
      COVERAGE: 1
    - WINPYTHON: "Python36"
      PYTHON: "3.6"
      PYVER: 36
      BUILD_JOB_NUM: 3
      COVERAGE: 1
    - WINPYTHON: "Python36"
      PYTHON: "3.6"
      PYVER: 36
      BUILD_JOB_NUM: 4
      COVERAGE: 1

    - WINPYTHON: "Python35"
      PYTHON: "3.5"
      PYVER: 35
      BUILD_JOB_NUM: 1
      COVERAGE: 0
    - WINPYTHON: "Python35"
      PYTHON: "3.5"
      PYVER: 35
      BUILD_JOB_NUM: 2
      COVERAGE: 0
    - WINPYTHON: "Python35"
      PYTHON: "3.5"
      PYVER: 35
      BUILD_JOB_NUM: 3
      COVERAGE: 0
    - WINPYTHON: "Python35"
      PYTHON: "3.5"
      PYVER: 35
      BUILD_JOB_NUM: 4
      COVERAGE: 0

    - WINPYTHON: "Python37"
      PYTHON: "3.7"
      PYVER: 37
      BUILD_JOB_NUM: 1
      COVERAGE: 0
    - WINPYTHON: "Python37"
      PYTHON: "3.7"
      PYVER: 37
      BUILD_JOB_NUM: 2
      COVERAGE: 0
    - WINPYTHON: "Python37"
      PYTHON: "3.7"
      PYVER: 37
      BUILD_JOB_NUM: 3
      COVERAGE: 0
    - WINPYTHON: "Python37"
      PYTHON: "3.7"
      PYVER: 37
      BUILD_JOB_NUM: 4
      COVERAGE: 0

# remove sets of build jobs based on critia below
# to fine tune the number and platforms tested
matrix:	
  exclude:	
    # test python 3.5, 3.6 on Visual Studio 2015 image
    - image: Visual Studio 2015	
      WINPYTHON: "Python37"
    - image: Visual Studio 2015	
      WINPYTHON: "Python27"

    # test python 2.7, 3.7 on Visual Studio 2015 image
    - image: Visual Studio 2017
      WINPYTHON: "Python35"
    - image: Visual Studio 2017	
      WINPYTHON: "Python36"

    # test python 3.7 on Ubuntu
    - image: Ubuntu	
      WINPYTHON: "Python27"	
    - image: Ubuntu		
      WINPYTHON: "Python35"
    - image: Ubuntu		
      WINPYTHON: "Python36"

# remove some binaries we dont to be found
before_build:
    - ps: |
        if ($isWindows) 
        {
          dir "C:\Program Files\Git\usr\bin\x*.exe"
          if (Test-Path "C:\Program Files\Git\usr\bin\xsltproc.EXE" ) {
            Remove-Item  "C:\Program Files\Git\usr\bin\xsltproc.EXE" -ErrorAction Ignore
          }
          dir "C:\Program Files\Git\usr\bin\x*.exe"
        }
  
build: off

build_script:
  # get all tests into a list
  - cmd: "C:\\%WINPYTHON%\\python.exe runtest.py -l -a > all_tests.txt"
  - sh: python$PYTHON runtest.py -l -a > all_tests.txt

  # setup coverage by creating the coverage config file, and adding coverage 
  # to the usercustomize so that all python processes start with coverage
  - ps: |
      if ($env:COVERAGE -eq 1){ 
        $env:COVERAGE_PROCESS_START = "$($env:APPVEYOR_BUILD_FOLDER)/.coveragerc";
        $env:PYTHONNOUSERSITE = "";
        New-Item -ItemType Directory -Force -Path "$($env:PYSITEDIR)";
        $env:COVERAGE_FILE = "$($env:APPVEYOR_BUILD_FOLDER)/.coverage";
        $usercustomizeText = "import os`r`nos.environ['COVERAGE_PROCESS_START'] = '$($env:COVERAGE_PROCESS_START)'`r`nimport coverage`r`ncoverage.process_startup()";
        $usercustomizeText|Set-Content "$($env:PYSITEDIR)/usercustomize.py";
        if ($isWindows) 
        {
          $coveragercFile = "[run]`r`nsource = $($env:APPVEYOR_BUILD_FOLDER)/src`r`nparallel = True`r`ndisable_warnings = trace-changed`r`nomit =`r`n`t*Tests.py`r`n`tsrc\test_*`r`n`tsrc\setup.py`r`n`r`n[path]`r`nsource = $($env:APPVEYOR_BUILD_FOLDER)`r`n[report]`r`nomit =`r`n`t*Tests.py`r`n`tsrc\test_*`r`n`tsrc\setup.py`r`n`r`n"
        }
        else
        {
          $coveragercFile = "[run]`nsource = $($env:APPVEYOR_BUILD_FOLDER)/src`nparallel = True`ndisable_warnings = trace-changed`nomit =`n`t*Tests.py`n`tsrc/test_*`n`tsrc/setup.py`n`n[path]`nsource = $($env:APPVEYOR_BUILD_FOLDER)`n[report]`nomit =`n`t*Tests.py`n`tsrc/test_*`n`tsrc/setup.py`n`n"
        }
        $coveragercFile|Set-Content "$($env:COVERAGE_PROCESS_START)";
      }

  # setup portion of tests for this build job (1-4)
  - ps: |
      $TOTAL_BUILD_JOBS = 4;
      $Lines = (Get-Content all_tests.txt | Measure-Object -line).Lines;
      $start = ($Lines / $TOTAL_BUILD_JOBS) * ($Env:BUILD_JOB_NUM - 1);
      $end = ($Lines / $TOTAL_BUILD_JOBS) * $Env:BUILD_JOB_NUM;
      if ( $Env:BUILD_JOB_NUM -eq $TOTAL_BUILD_JOBS){ $end = $Lines };
      if ( $start -eq 0 ){ $start = 1 };
      get-content all_tests.txt | select -first ($end - $start) -skip ($start - 1) | Out-File -Encoding ASCII build_tests.txt;

  # exclude VS 10.0 because it hangs the testing until this is resolved: 
  # https://help.appveyor.com/discussions/problems/19283-visual-studio-2010-trial-license-has-expired
  - ps: |
      New-Item -Name exclude_list.txt -ItemType File
      $workaround_image = "Visual Studio 2015"
      if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq $workaround_image){ 
        Add-Content -Path 'exclude_list.txt' -Value 'test\MSVS\vs-10.0-exec.py'
      }

  # Windows run the tests
  # NOTE: running powershell from cmd on purpose because it formats the output
  # correctly
  - cmd: powershell -Command "& { if($env:COVERAGE -eq 1) { coverage run -p --rcfile=$($env:COVERAGE_PROCESS_START) runtest.py -j 2 --exclude-list exclude_list.txt -f build_tests.txt } else { C:\\%WINPYTHON%\\python.exe runtest.py -j 2 --exclude-list exclude_list.txt -f build_tests.txt }; if($LastExitCode -eq 2 -Or $LastExitCode -eq 0) { $host.SetShouldExit(0 )} else {$host.SetShouldExit(1)}}"

  # linux run the tests
  # unset JAVA_TOOL_OPTIONS because newer java prints this to stderr
  - sh: |
      unset JAVA_TOOL_OPTIONS
      if [ "$COVERAGE" -eq "1" ]; then 
        coverage run -p --rcfile="$COVERAGE_PROCESS_START" runtest.py --exclude-list exclude_list.txt -f build_tests.txt || if [[ $? == 2 ]]; then true; else false; fi; 
      else
        python$PYTHON runtest.py -j 2 --exclude-list exclude_list.txt -f build_tests.txt || if [[ $? == 2 ]]; then true; else false; fi; 
      fi

# run converage even if there was a test failure
on_finish:
  - ps: |
      if ($env:COVERAGE -eq 1)
      { 
        & coverage combine
        & coverage report
        & coverage xml -o coverage_xml.xml
      }
  # running codecov in powershell causes an error so running in platform
  # shells
  - cmd: if %COVERAGE% equ 1 codecov -X gcov --file coverage_xml.xml
  - sh: if [ $COVERAGE -eq 1 ]; then codecov -X gcov --file coverage_xml.xml; fi
    # not using coveralls, so leaving it commented out in case we switch back
    #- cmd: "C:\\%WINPYTHON%\\python.exe -m pip install --user -U coveralls"
    #- sh: python$PYTHON -m pip install --user -U coveralls 
    #- ps: coveralls --rcfile="$($env:COVERAGE_PROCESS_START)"