Skip to content

Commit

Permalink
add pytest common to common tests workflow and coverage, discover uni…
Browse files Browse the repository at this point in the history
…ttests automatically for coverage
  • Loading branch information
irenaby committed Jan 26, 2025
1 parent 1a3e384 commit 575dfd9
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 8 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/run_tests_suite_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,30 @@ jobs:
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.11'

- name: Set up Coverage
run: |
python -m pip install --upgrade pip
pip install coverage
pip install -r requirements.txt coverage pytest pytest-mock
- name: Run common tests (unittest)
run: coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" unittest discover tests/common_tests -v

- name: Run common tests (pytest)
run: coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" pytest tests_pytest/common

- name: Set up TensorFlow environment
run: |
python -m venv tf_env
source tf_env/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install tensorflow==2.13.* coverage pytest
pip install -r requirements.txt tensorflow==2.15.* coverage pytest pytest-mock
- name: Run TensorFlow testsuite
run: |
source tf_env/bin/activate
coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" unittest tests/test_suite.py -v
coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" unittest discover tests/keras_tests -v
- name: Run TensorFlow pytest
run: |
Expand All @@ -59,12 +64,12 @@ jobs:
source torch_env/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install torch==2.0.* torchvision onnx onnxruntime onnxruntime-extensions coverage pytest
pip install torch==2.5.* torchvision onnx onnxruntime onnxruntime-extensions coverage pytest pytest-mock
- name: Run torch testsuite
run: |
source torch_env/bin/activate
coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" unittest tests/test_suite.py -v
coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" unittest discover tests/pytorch_tests -v
- name: Run torch pytest
run: |
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/tests_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.txt
pip install pytest pytest-mock
pip check
- name: Run unittests
run: python -m unittest discover tests/common_tests -v

- name: Run pytest
run: pytest tests_pytest/common

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2025 Sony Semiconductor Israel, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

0 comments on commit 575dfd9

Please sign in to comment.