Skip to content

Commit b38bab3

Browse files
Merge pull request #760 from VWS-Python/windows-actions
Run mock tests on Windows
2 parents 181b15f + 3ffed8f commit b38bab3

File tree

6 files changed

+83
-15
lines changed

6 files changed

+83
-15
lines changed

.github/workflows/windows-ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
3+
name: Windows CI
4+
5+
on:
6+
push:
7+
branches: [master]
8+
pull_request:
9+
branches: [master]
10+
schedule:
11+
# * is a special character in YAML so you have to quote this string
12+
# Run at 1:00 every day
13+
- cron: '0 1 * * *'
14+
15+
jobs:
16+
build:
17+
18+
strategy:
19+
matrix:
20+
python-version: [3.8]
21+
platform: [windows-latest]
22+
23+
runs-on: ${{ matrix.platform }}
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: "Set up Python"
28+
uses: actions/setup-python@v2
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
32+
- name: "Install dependencies"
33+
run: |
34+
python -m pip install --upgrade pip setuptools wheel
35+
# We use '--ignore-installed' to avoid GitHub's cache which can cause
36+
# issues - we have seen packages from this cache be cause trouble with
37+
# pip-extra-reqs.
38+
python -m pip install --ignore-installed --upgrade --editable .[dev]
39+
40+
- name: "Set secrets file"
41+
run: |
42+
cp ./vuforia_secrets.env.example ./vuforia_secrets.env
43+
44+
- name: "Run tests"
45+
env:
46+
SKIP_REAL: 1
47+
run: |
48+
pytest -s -vvv --exitfirst --cov=src/ --cov=tests --cov-report=xml tests/mock_vws/${{ matrix.ci_pattern }}
49+
50+
- name: "Upload coverage to Codecov"
51+
uses: "codecov/[email protected]"
52+
with:
53+
fail_ci_if_error: true

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ flake8-commas==2.0.0 # Require silicon valley commas
1313
flake8-quotes==3.2.0 # Require single quotes
1414
flake8==3.8.3 # Lint
1515
freezegun==1.0.0 # Freeze time in tests
16+
func-timeout==4.3.5
1617
isort==5.5.4 # Lint imports
1718
keyring==21.4.0
1819
mypy==0.782 # Type checking
@@ -29,7 +30,6 @@ requests-mock-flask==2020.9.25.0
2930
sphinx-autodoc-typehints==1.11.0
3031
sphinx_paramlinks==0.4.2
3132
sphinxcontrib-spelling==5.4.0
32-
timeout-decorator==0.4.1 # Decorate functions to time out.
3333
twine==3.2.0
3434
vulture==2.1
3535
vws-python==2020.9.28.0

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Pillow
22
VWS-Auth-Tools
3-
backports.zoneinfo
3+
# We add ``[tzdata]`` for Windows.
4+
backports.zoneinfo[tzdata]
45
flask
56
requests-mock
67
requests

spelling_private_dict.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ mib
5656
mockvws
5757
multipart
5858
mypy
59+
nat
5960
noqa
6061
pdict
6162
plugins

tests/mock_vws/test_database_summary.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from time import sleep
1010

1111
import pytest
12-
import timeout_decorator
12+
from func_timeout import func_set_timeout
1313
from vws import VWS, CloudRecoService
1414
from vws.exceptions.vws_exceptions import Fail
1515

@@ -20,7 +20,7 @@
2020
LOGGER.setLevel(logging.DEBUG)
2121

2222

23-
@timeout_decorator.timeout(seconds=500)
23+
@func_set_timeout(timeout=500)
2424
def _wait_for_image_numbers(
2525
vws_client: VWS,
2626
active_images: int,
@@ -47,8 +47,8 @@ def _wait_for_image_numbers(
4747
processing_images: The expected number of processing images.
4848
4949
Raises:
50-
TimeoutError: The numbers of images in various categories do not match
51-
within the time limit.
50+
func_timeout.exceptions.FunctionTimedOut: The numbers of images in
51+
various categories do not match within the time limit.
5252
"""
5353
requirements = {
5454
'active_images': active_images,

tests/mock_vws/test_docker.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ def fixture_custom_bridge_network() -> Iterator[Network]:
2323
Yield a custom bridge network which containers can connect to.
2424
"""
2525
client = docker.from_env()
26-
network = client.networks.create(
27-
name='test-vws-bridge-' + uuid.uuid4().hex,
28-
driver='bridge',
29-
)
26+
try:
27+
network = client.networks.create(
28+
name='test-vws-bridge-' + uuid.uuid4().hex,
29+
driver='bridge',
30+
)
31+
except docker.errors.NotFound:
32+
# On Windows the "bridge" network driver is not available and we use
33+
# the "nat" driver instead.
34+
network = client.networks.create(
35+
name='test-vws-bridge-' + uuid.uuid4().hex,
36+
driver='nat',
37+
)
3038
try:
3139
yield network
3240
finally:
@@ -56,11 +64,16 @@ def test_build_and_run(
5664
vws_tag = 'vws-mock-vws:latest-' + random
5765
vwq_tag = 'vws-mock-vwq:latest-' + random
5866

59-
client.images.build(
60-
path=str(repository_root),
61-
dockerfile=str(base_dockerfile),
62-
tag=base_tag,
63-
)
67+
try:
68+
client.images.build(
69+
path=str(repository_root),
70+
dockerfile=str(base_dockerfile),
71+
tag=base_tag,
72+
)
73+
except docker.errors.BuildError as exc:
74+
assert 'no matching manifest for windows/amd64' in str(exc)
75+
reason = 'We do not currently support using Windows containers.'
76+
pytest.skip(reason)
6477

6578
storage_image, _ = client.images.build(
6679
path=str(repository_root),

0 commit comments

Comments
 (0)