Skip to content

Commit c1e8a51

Browse files
authored
let's do this (run tests on windows) (#1889)
Run tests on Windows in Github CI
1 parent 3fdfa6d commit c1e8a51

File tree

5 files changed

+70
-20
lines changed

5 files changed

+70
-20
lines changed

.github/workflows/test.yml

+31-14
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
# Otherwise, set variable to the commit of your branch on
1111
# opentelemetry-python-contrib which is compatible with these Core repo
1212
# changes.
13-
CONTRIB_REPO_SHA: 2a92e255f7595024242e45c0050c8f3de7140b6b
13+
CONTRIB_REPO_SHA: dde62cebffe519c35875af6d06fae053b3be65ec
1414

1515
jobs:
1616
build:
@@ -20,15 +20,15 @@ jobs:
2020
py37: 3.7
2121
py38: 3.8
2222
py39: 3.9
23-
pypy3: pypy3
23+
pypy3: pypy-3.7
2424
RUN_MATRIX_COMBINATION: ${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }}
2525
runs-on: ${{ matrix.os }}
2626
strategy:
2727
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
2828
matrix:
2929
python-version: [ py36, py37, py38, py39, pypy3 ]
3030
package: ["instrumentation", "core", "exporter", "propagator"]
31-
os: [ ubuntu-latest ]
31+
os: [ ubuntu-20.04, windows-2019 ]
3232
steps:
3333
- name: Checkout Core Repo @ SHA - ${{ github.sha }}
3434
uses: actions/checkout@v2
@@ -42,14 +42,22 @@ jobs:
4242
uses: actions/setup-python@v2
4343
with:
4444
python-version: ${{ env[matrix.python-version] }}
45+
architecture: 'x64'
4546
- name: Install tox
4647
run: pip install -U tox-factor
4748
- name: Cache tox environment
4849
# Preserves .tox directory between runs for faster installs
4950
uses: actions/cache@v2
5051
with:
51-
path: .tox
52-
key: tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-core
52+
path: |
53+
.tox
54+
~/.cache/pip
55+
key: v2-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-core
56+
# tox fails on windows and Python3.6 when tox dir is reused between builds so we remove it
57+
- name: fix for windows + py3.6
58+
if: ${{ matrix.os == 'windows-2019' && matrix.python-version == 'py36' }}
59+
shell: pwsh
60+
run: Remove-Item .\.tox\ -Force -Recurse -ErrorAction Ignore
5361
- name: run tox
5462
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json
5563
- name: Find and merge benchmarks
@@ -81,7 +89,7 @@ jobs:
8189
matrix:
8290
tox-environment: [ "docker-tests", "lint", "docs", "mypy", "mypyinstalled", "tracecontext" ]
8391
name: ${{ matrix.tox-environment }}
84-
runs-on: ubuntu-latest
92+
runs-on: ubuntu-20.04
8593
steps:
8694
- name: Checkout Core Repo @ SHA - ${{ github.sha }}
8795
uses: actions/checkout@v2
@@ -95,14 +103,17 @@ jobs:
95103
uses: actions/setup-python@v2
96104
with:
97105
python-version: 3.9
106+
architecture: 'x64'
98107
- name: Install tox
99108
run: pip install -U tox
100109
- name: Cache tox environment
101110
# Preserves .tox directory between runs for faster installs
102111
uses: actions/cache@v2
103112
with:
104-
path: .tox
105-
key: tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-core
113+
path: |
114+
.tox
115+
~/.cache/pip
116+
key: v2-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-core
106117
- name: run tox
107118
run: tox -e ${{ matrix.tox-environment }}
108119
contrib-build:
@@ -119,7 +130,7 @@ jobs:
119130
matrix:
120131
python-version: [ py36, py37, py38, py39, pypy3 ]
121132
package: ["instrumentation", "exporter"]
122-
os: [ ubuntu-latest ]
133+
os: [ ubuntu-20.04]
123134
steps:
124135
- name: Checkout Contrib Repo @ SHA - ${{ env.CONTRIB_REPO_SHA }}
125136
uses: actions/checkout@v2
@@ -135,14 +146,17 @@ jobs:
135146
uses: actions/setup-python@v2
136147
with:
137148
python-version: ${{ env[matrix.python-version] }}
149+
architecture: 'x64'
138150
- name: Install tox
139151
run: pip install -U tox-factor
140152
- name: Cache tox environment
141153
# Preserves .tox directory between runs for faster installs
142154
uses: actions/cache@v2
143155
with:
144-
path: .tox
145-
key: tox-cache-${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-contrib
156+
path: |
157+
.tox
158+
~/.cache/pip
159+
key: v2-tox-cache-${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-contrib
146160
- name: run tox
147161
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }}
148162
contrib-misc:
@@ -151,7 +165,7 @@ jobs:
151165
matrix:
152166
tox-environment: [ "docker-tests"]
153167
name: ${{ matrix.tox-environment }}
154-
runs-on: ubuntu-latest
168+
runs-on: ubuntu-20.04
155169
steps:
156170
- name: Checkout Contrib Repo @ SHA - ${{ env.CONTRIB_REPO_SHA }}
157171
uses: actions/checkout@v2
@@ -167,13 +181,16 @@ jobs:
167181
uses: actions/setup-python@v2
168182
with:
169183
python-version: 3.9
184+
architecture: 'x64'
170185
- name: Install tox
171186
run: pip install -U tox
172187
- name: Cache tox environment
173188
# Preserves .tox directory between runs for faster installs
174189
uses: actions/cache@v2
175190
with:
176-
path: .tox
177-
key: tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-contrib
191+
path: |
192+
.tox
193+
~/.cache/pip
194+
key: v2-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }}-contrib
178195
- name: run tox
179196
run: tox -e ${{ matrix.tox-environment }}

docs/getting_started/flask_example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ def hello():
4444
return "hello"
4545

4646

47-
app.run(debug=True, port=5000)
47+
app.run(port=5000)

shim/opentelemetry-opentracing-shim/tests/testbed/test_common_request_handler/test_asyncio.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ async def do_task():
129129
spans = self.tracer.finished_spans()
130130
self.assertEqual(len(spans), 3)
131131

132-
spans = sorted(spans, key=lambda x: x.start_time)
133132
parent_span = get_one_by_operation_name(spans, "parent")
134133
self.assertIsNotNone(parent_span)
135134

136-
self.assertIsChildOf(spans[1], parent_span)
137-
self.assertIsNotChildOf(spans[2], parent_span)
135+
spans = [span for span in spans if span != parent_span]
136+
self.assertIsChildOf(spans[0], parent_span)
137+
self.assertIsNotChildOf(spans[1], parent_span)

shim/opentelemetry-opentracing-shim/tests/testbed/test_common_request_handler/test_threads.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,7 @@ def test_bad_solution_to_set_parent(self):
115115
parent_span = get_one_by_operation_name(spans, "parent")
116116
self.assertIsNotNone(parent_span)
117117

118-
self.assertIsChildOf(spans[1], parent_span)
119-
self.assertIsChildOf(spans[2], parent_span)
118+
spans = [s for s in spans if s != parent_span]
119+
self.assertEqual(len(spans), 2)
120+
for span in spans:
121+
self.assertIsChildOf(span, parent_span)

tests/util/src/opentelemetry/test/test_base.py

+31
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ def tearDownClass(cls):
4646
def setUp(self):
4747
self.memory_exporter.clear()
4848

49+
def get_finished_spans(self):
50+
return FinishedTestSpans(
51+
self, self.memory_exporter.get_finished_spans()
52+
)
53+
4954
def assertEqualSpanInstrumentationInfo(self, span, module):
5055
self.assertEqual(span.instrumentation_info.name, module.__name__)
5156
self.assertEqual(span.instrumentation_info.version, module.__version__)
@@ -56,6 +61,12 @@ def assertSpanHasAttributes(self, span, attributes):
5661
self.assertEqual(val, span.attributes[key])
5762

5863
def sorted_spans(self, spans): # pylint: disable=R0201
64+
"""
65+
Sorts spans by span creation time.
66+
67+
Note: This method should not be used to sort spans in a deterministic way as the
68+
order depends on timing precision provided by the platform.
69+
"""
5970
return sorted(
6071
spans,
6172
key=lambda s: s._start_time, # pylint: disable=W0212
@@ -91,3 +102,23 @@ def disable_logging(highest_level=logging.CRITICAL):
91102
yield
92103
finally:
93104
logging.disable(logging.NOTSET)
105+
106+
107+
class FinishedTestSpans(list):
108+
def __init__(self, test, spans):
109+
super().__init__(spans)
110+
self.test = test
111+
112+
def by_name(self, name):
113+
for span in self:
114+
if span.name == name:
115+
return span
116+
self.test.fail("Did not find span with name {}".format(name))
117+
return None
118+
119+
def by_attr(self, key, value):
120+
for span in self:
121+
if span.attributes.get(key) == value:
122+
return span
123+
self.test.fail("Did not find span with attrs {}={}".format(key, value))
124+
return None

0 commit comments

Comments
 (0)