Skip to content

Commit ffe6d61

Browse files
authored
Add smoke test GitHub Action workflow (#379)
1 parent f2f2268 commit ffe6d61

12 files changed

+92
-29
lines changed

.github/workflows/local-install-check.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Local Install Checks
2-
on:
2+
on:
33
push:
44
branches:
55
- main
@@ -12,6 +12,9 @@ on:
1212
# Allows you to run this workflow manually from the Actions tab
1313
workflow_dispatch:
1414

15+
env:
16+
SPARSEZOO_TEST_MODE: "true"
17+
1518
jobs:
1619
local-install-test:
1720
runs-on: ubuntu-20.04

.github/workflows/test-check.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Test Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'release/*'
8+
pull_request:
9+
branches:
10+
- main
11+
- 'release/*'
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
env:
17+
SPARSEZOO_TEST_MODE: true
18+
19+
jobs:
20+
base-tests:
21+
runs-on: ubuntu-20.04
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: ⚙️ Install dependencies
25+
run: pip3 install .[dev]
26+
- name: Run base tests
27+
run: make test
28+
cli-smoke-tests:
29+
runs-on: ubuntu-20.04
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: ⚙️ Install dependencies
33+
run: pip3 install .[dev,server]
34+
- name: Run CLI smoke tests
35+
run: PYTEST_ARGS="-m smoke" make test TARGETS=cli,nobase
36+
examples-smoke-tests:
37+
runs-on: ubuntu-20.04
38+
steps:
39+
- uses: actions/checkout@v2
40+
- name: Install dependencies
41+
run: pip3 install .[dev]
42+
- name: Run examples smoke tests
43+
run: PYTEST_ARGS="-m smoke" make test TARGETS=examples,nobase

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ MDCHECKGLOBS := 'docs/**/*.md' 'docs/**/*.rst' 'examples/**/*.md' 'scripts/**/*.
99
MDCHECKFILES := CODE_OF_CONDUCT.md CONTRIBUTING.md DEVELOPING.md README.md
1010
SPARSEZOO_TEST_MODE := "true"
1111

12-
TARGETS := "" # targets for running pytests: cli,examples
12+
TARGETS := "" # targets for running pytests: cli,examples,nobase
1313
PYTEST_ARGS ?= ""
1414
ifneq ($(findstring cli,$(TARGETS)),cli)
15-
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/test_benchmark.py \
15+
PYTEST_ARGS += --ignore tests/test_benchmark.py \
1616
--ignore tests/test_check_hardware.py \
1717
--ignore tests/test_run_inference.py \
1818
--ignore tests/test_server.py
1919
endif
2020
ifneq ($(findstring examples,$(TARGETS)),examples)
21-
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/test_examples.py
21+
PYTEST_ARGS += --ignore tests/test_examples.py
22+
endif
23+
ifeq ($(findstring nobase,$(TARGETS)),nobase)
24+
PYTEST_ARGS += --ignore tests/utils/test_data.py \
25+
--ignore tests/test_engine.py
2226
endif
2327

2428
PYTHON := python3

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
[tool.black]
22
line-length = 88
33
target-version = ['py36']
4+
5+
[tool.pytest.ini_options]
6+
markers = [
7+
"smoke: smoke tests",
8+
]

tests/deepsparse/image_classification/test_pipelines.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515

1616
import numpy
17-
from PIL import Image
18-
from torchvision import transforms
1917

2018
import pytest
2119
from deepsparse import Pipeline
@@ -27,6 +25,10 @@
2725
from sparsezoo.utils import load_numpy_list
2826

2927

28+
from PIL import Image # isort:skip
29+
from torchvision import transforms # isort:skip
30+
31+
3032
@pytest.mark.parametrize(
3133
"zoo_stub,image_size,num_samples",
3234
[
@@ -38,6 +40,7 @@
3840
)
3941
],
4042
)
43+
@pytest.mark.smoke
4144
def test_image_classification_pipeline_preprocessing(zoo_stub, image_size, num_samples):
4245
non_rand_resize_scale = 256.0 / 224.0 # standard used
4346
standard_imagenet_transforms = transforms.Compose(

tests/test_benchmark.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from helpers import predownload_stub, run_command
1919

2020

21+
@pytest.mark.smoke
2122
def test_benchmark_help():
2223
cmd = ["deepsparse.benchmark", "--help"]
2324
print(f"\n==== test_benchmark_help command ====\n{' '.join(cmd)}")
@@ -52,10 +53,11 @@ def test_benchmark_help():
5253
"bookcorpus_wikitext/base-none",
5354
["-t", "20"],
5455
),
55-
(
56+
pytest.param(
5657
"zoo:nlp/masked_language_modeling/bert-base/pytorch/huggingface/"
5758
"bookcorpus_wikitext/12layer_pruned90-none",
5859
[],
60+
marks=pytest.mark.smoke,
5961
),
6062
(
6163
"zoo:cv/classification/resnet_v1-50/pytorch/sparseml/imagenet/base-none",

tests/test_check_hardware.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import pytest
1516
from helpers import run_command
1617

1718

19+
@pytest.mark.smoke
1820
def test_check_hardware():
1921
cmd = ["deepsparse.check_hardware"]
2022
print(f"\n==== deepsparse.check_hardware command ====\n{' '.join(cmd)}")

tests/test_engine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
]
4141
),
4242
)
43+
@pytest.mark.smoke
4344
class TestEngineParametrized:
4445
def test_engine(self, model: Model, batch_size: int):
4546
"""

tests/test_examples.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@
4646
"model, batch_size",
4747
(
4848
[
49-
pytest.param(
50-
mobilenet_v1,
51-
b,
52-
)
53-
for b in [1, 8, 64]
49+
pytest.param(mobilenet_v1, 1, marks=pytest.mark.smoke),
50+
pytest.param(mobilenet_v1, 8, marks=pytest.mark.smoke),
51+
pytest.param(mobilenet_v1, 64),
5452
]
5553
),
5654
)
@@ -70,11 +68,9 @@ def test_check_correctness(model: Model, batch_size: int):
7068
"model, batch_size",
7169
(
7270
[
73-
pytest.param(
74-
mobilenet_v1,
75-
b,
76-
)
77-
for b in [1, 8, 64]
71+
pytest.param(mobilenet_v1, 1, marks=pytest.mark.smoke),
72+
pytest.param(mobilenet_v1, 8, marks=pytest.mark.smoke),
73+
pytest.param(mobilenet_v1, 64),
7874
]
7975
),
8076
)
@@ -94,11 +90,9 @@ def test_run_benchmark(model: Model, batch_size: int):
9490
"model_name, batch_size",
9591
(
9692
[
97-
pytest.param(
98-
"mobilenet_v1",
99-
b,
100-
)
101-
for b in [1, 8, 64]
93+
pytest.param("mobilenet_v1", 1, marks=pytest.mark.smoke),
94+
pytest.param("mobilenet_v1", 8, marks=pytest.mark.smoke),
95+
pytest.param("mobilenet_v1", 64),
10296
]
10397
),
10498
)
@@ -117,11 +111,9 @@ def test_classification(model_name: str, batch_size: int):
117111
"model_name, batch_size",
118112
(
119113
[
120-
pytest.param(
121-
"yolo_v3",
122-
b,
123-
)
124-
for b in [1, 8, 64]
114+
pytest.param("yolo_v3", 1, marks=pytest.mark.smoke),
115+
pytest.param("yolo_v3", 8, marks=pytest.mark.smoke),
116+
pytest.param("yolo_v3", 64),
125117
]
126118
),
127119
)

tests/test_run_inference.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from helpers import predownload_stub, run_command
2222

2323

24+
@pytest.mark.smoke
2425
def test_run_inference_help():
2526
cmd = ["deepsparse.transformers.run_inference", "--help"]
2627
print(f"\n==== test_run_inference_help command ====\n{' '.join(cmd)}")
@@ -33,6 +34,7 @@ def test_run_inference_help():
3334
assert "fail" not in res.stdout.lower()
3435

3536

37+
@pytest.mark.smoke
3638
def test_run_inference_ner(cleanup: Dict[str, List]):
3739
cmd = [
3840
"deepsparse.transformers.run_inference",
@@ -69,11 +71,12 @@ def test_run_inference_ner(cleanup: Dict[str, List]):
6971
@pytest.mark.parametrize(
7072
("input_format", "model_path", "local_model"),
7173
[
72-
(
74+
pytest.param(
7375
"csv",
7476
"zoo:nlp/question_answering/bert-base/pytorch/huggingface/squad/"
7577
"pruned_6layers-aggressive_98",
7678
True,
79+
marks=pytest.mark.smoke,
7780
),
7881
(
7982
"json",
@@ -138,11 +141,12 @@ def test_run_inference_qa(
138141
True,
139142
["--num-cores", "4", "--engine-type", "onnxruntime"],
140143
),
141-
(
144+
pytest.param(
142145
"csv",
143146
"zoo:nlp/text_classification/bert-base/pytorch/huggingface/sst2/base-none",
144147
True,
145148
[],
149+
marks=pytest.mark.smoke,
146150
),
147151
(
148152
"json",

tests/test_server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import requests
1919

20+
import pytest
2021
from helpers import predownload_stub, run_command, wait_for_server
2122

2223

@@ -25,6 +26,7 @@
2526
# TODO: Include additional opts/etc. in tests
2627

2728

29+
@pytest.mark.smoke
2830
def test_server_help():
2931
cmd = ["deepsparse.server", "--help"]
3032
print(f"\n==== test_server_help command ====\n{' '.join(cmd)}\n==== ====")
@@ -84,6 +86,7 @@ def test_server_ner(cleanup: Dict[str, List]):
8486
assert "fail" not in output.lower()
8587

8688

89+
@pytest.mark.smoke
8790
def test_server_qa(cleanup: Dict[str, List]):
8891
cmd = [
8992
"deepsparse.server",

tests/utils/test_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
[numpy.random.randint(255, size=(3, 244, 244), dtype=numpy.uint8)],
3131
),
3232
)
33+
@pytest.mark.smoke
3334
def test_arrays_bytes_conversion(arrays):
3435
serialized_arrays = arrays_to_bytes(arrays)
3536
assert isinstance(serialized_arrays, bytearray)

0 commit comments

Comments
 (0)