Codebase list python-procrunner / 6695ca6
Enable Azure builds for Linux, MacOS, Windows closes #47, no evidence of issues Markus Gerstel 3 years ago
7 changed file(s) with 176 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 steps:
1 - task: UsePythonVersion@0
2 inputs:
3 versionSpec: '$(PYTHON_VERSION)'
4 displayName: 'Use Python $(PYTHON_VERSION)'
5
6 - script: |
7 python -m pip install --upgrade pip
8 pip install tox
9 displayName: "Set up tox"
10
11 - script: |
12 tox -e azure
13 displayName: "Run tests"
14
15 - task: PublishTestResults@2
16 condition: succeededOrFailed()
17 inputs:
18 testResultsFiles: '**/test-*.xml'
19 testRunTitle: 'Publish test results for Python $(PYTHON_VERSION)'
0 import os
1 import subprocess
2
3 # Flake8 validation
4 failures = 0
5 try:
6 flake8 = subprocess.run(
7 [
8 "flake8",
9 "--exit-zero",
10 "--max-line-length=88",
11 "--select=E401,E711,E712,E713,E714,E721,E722,E901,F401,F402,F403,F405,F631,F632,F633,F811,F812,F821,F822,F841,F901,W191,W291,W292,W293,W602,W603,W604,W605,W606",
12 ],
13 capture_output=True,
14 check=True,
15 encoding="latin-1",
16 timeout=300,
17 )
18 except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as e:
19 print(
20 "##vso[task.logissue type=error;]flake8 validation failed with",
21 str(e.__class__.__name__),
22 )
23 print(e.stdout)
24 print(e.stderr)
25 print("##vso[task.complete result=Failed;]flake8 validation failed")
26 exit()
27 for line in flake8.stdout.split("\n"):
28 if ":" not in line:
29 continue
30 filename, lineno, column, error = line.split(":", maxsplit=3)
31 errcode, error = error.strip().split(" ", maxsplit=1)
32 filename = os.path.normpath(filename)
33 failures += 1
34 print(
35 f"##vso[task.logissue type=error;sourcepath={filename};"
36 f"linenumber={lineno};columnnumber={column};code={errcode};]" + error
37 )
38
39 if failures:
40 print(f"##vso[task.logissue type=warning]Found {failures} flake8 violation(s)")
41 print(f"##vso[task.complete result=Failed;]Found {failures} flake8 violation(s)")
0 import ast
1 import os
2 import sys
3
4 print("Python", sys.version, "\n")
5
6 failures = 0
7
8 for base, _, files in os.walk("."):
9 for f in files:
10 if not f.endswith(".py"):
11 continue
12 filename = os.path.normpath(os.path.join(base, f))
13 try:
14 with open(filename, "r") as fh:
15 ast.parse(fh.read())
16 except SyntaxError as se:
17 failures += 1
18 print(
19 f"##vso[task.logissue type=error;sourcepath={filename};"
20 f"linenumber={se.lineno};columnnumber={se.offset};]"
21 f"SyntaxError: {se.msg}"
22 )
23 print(" " + se.text + " " * se.offset + "^")
24 print(f"SyntaxError: {se.msg} in {filename} line {se.lineno}")
25 print()
26
27 if failures:
28 print(f"##vso[task.logissue type=warning]Found {failures} syntax error(s)")
29 print(f"##vso[task.complete result=Failed;]Found {failures} syntax error(s)")
0 jobs:
1 - job: checks
2 displayName: static code analysis
3 pool:
4 vmImage: ubuntu-latest
5 steps:
6 # Use Python >=3.7 for syntax validation
7 - task: UsePythonVersion@0
8 displayName: Set up python
9 inputs:
10 versionSpec: 3.7
11
12 # Run syntax validation on a shallow clone
13 - bash: |
14 python .azure-pipelines/syntax-validation.py
15 displayName: Syntax validation
16
17 # Run flake8 validation on a shallow clone
18 - bash: |
19 pip install flake8
20 python .azure-pipelines/flake8-validation.py
21 displayName: Flake8 validation
22
23 - job: linux
24 pool:
25 vmImage: ubuntu-latest
26 strategy:
27 matrix:
28 python35:
29 PYTHON_VERSION: 3.5
30 python36:
31 PYTHON_VERSION: 3.6
32 python37:
33 PYTHON_VERSION: 3.7
34 python38:
35 PYTHON_VERSION: 3.8
36
37 steps:
38 - template: .azure-pipelines/ci.yml
39
40 - job: macOS
41 pool:
42 vmImage: macOS-latest
43 strategy:
44 matrix:
45 python35:
46 PYTHON_VERSION: 3.5
47 python36:
48 PYTHON_VERSION: 3.6
49 python37:
50 PYTHON_VERSION: 3.7
51 python38:
52 PYTHON_VERSION: 3.8
53
54 steps:
55 - template: .azure-pipelines/ci.yml
56
57 - job: windows
58 pool:
59 vmImage: windows-latest
60 strategy:
61 matrix:
62 python35:
63 PYTHON_VERSION: 3.5
64 python36:
65 PYTHON_VERSION: 3.6
66 python37:
67 PYTHON_VERSION: 3.7
68 python38:
69 PYTHON_VERSION: 3.8
70
71 steps:
72 - template: .azure-pipelines/ci.yml
0 [pytest]
1 junit_family=xunit2
(New empty file)
77 3.7: py37
88 3.6: py36
99 3.5: py35
10
11 [testenv:azure]
12 basepython = python
13 deps =
14 pytest-azurepipelines
15 pytest-cov
16 -r{toxinidir}/requirements_dev.txt
17 commands =
18 pytest -ra --basetemp={envtmpdir} --cov=procrunner --cov-report=html --cov-report=xml --cov-branch
1019
1120 [testenv:flake8]
1221 basepython = python