Skip to content

Test examples

Test examples #600

Workflow file for this run

name: Test examples
run-name: "Test examples${{ inputs.pull_request_number != '' && format(' PR#{0}', inputs.pull_request_number) || '' }}${{ inputs.pytest_args != '' && format(' [{0}]', inputs.pytest_args) || '' }}"
permissions: read-all
on:
workflow_call:
inputs:
pull_request_number:
description: 'The pull request number'
type: string
default: ''
pytest_args:
description: 'Pytest arguments'
type: string
default: ''
skip_windows:
description: 'Skip tests on Windows'
type: boolean
default: false
skip_gpu:
description: 'Skip tests on GPU'
type: boolean
default: false
workflow_dispatch:
inputs:
pull_request_number:
description: 'The pull request number'
default: ''
pytest_args:
description: 'Pytest arguments'
default: ''
skip_windows:
description: 'Skip tests on Windows'
type: boolean
default: false
skip_gpu:
description: 'Skip tests on GPU'
type: boolean
default: false
concurrency:
group: test-examples-${{ github.workflow }}-${{ github.ref }}-${{ inputs.pytest_args || '' }}-${{ inputs.pull_request_number || '' }}
cancel-in-progress: false
env:
PYTEST_ARGS: ${{ inputs.pytest_args || '' }}
TQDM_DISABLE: 1
NNCF_EXTENSION_LOAD_TIMEOUT: 180
jobs:
examples-cpu:
name: Test examples CPU [${{ matrix.group }}/6]
runs-on: ubuntu-latest-16-cores
timeout-minutes: 80
strategy:
fail-fast: false
matrix:
group: [1, 2] # 3, 4, 5, 6]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
lfs: false
fetch-depth: 0 # Fetch full history to allow checking out any branch or PR
ref: ${{ inputs.pull_request_number != '' && format('refs/pull/{0}/head', inputs.pull_request_number) || github.ref }}
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.10.14
- name: cpuinfo
run: cat /proc/cpuinfo
- name: Install test requirements
run: |
pip install -r tests/cross_fw/examples/requirements.txt
- name: Print installed modules
run: pip list
- name: Run examples test scope
run: |
set +e
python -m pytest -s -ra tests/cross_fw/examples \
-m 'not cuda' \
--junit-xml=pytest-results.xml \
--durations-path=tests/cross_fw/examples/test_durations.json \
--splitting-algorithm=least_duration \
--splits 6 \
--group ${{ matrix.group }} \
${{ env.PYTEST_ARGS }};
ret=$?
(( ret == 5 )) && [[ -n "${{ env.PYTEST_ARGS }}" ]] && exit 0
exit $ret
- name: Upload test results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: examples-cpu-pytest-results-${{ matrix.group }}
path: pytest-results.xml
retention-days: 7
examples-cuda:
name: Test examples CUDA [${{ matrix.group }}/1]
runs-on: aks-linux-4-cores-28gb-gpu-tesla-t4
timeout-minutes: 40
if: ${{ !inputs.skip_gpu }}
strategy:
fail-fast: false
matrix:
group: [1]
defaults:
run:
shell: bash
env:
DEBIAN_FRONTEND: noninteractive
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get --assume-yes install build-essential ninja-build libgl1-mesa-dev libglib2.0-0 wget make
- name: Download CUDA
run: |
wget -q https://developer.download.nvidia.com/compute/cuda/12.6.3/local_installers/cuda_12.6.3_560.35.05_linux.run
sudo sh cuda_12.6.3_560.35.05_linux.run --toolkit --silent
- name: Runner info
continue-on-error: true
run: |
nvidia-smi
cat /proc/cpuinfo
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
lfs: false
fetch-depth: 0 # Fetch full history to allow checking out any branch or PR
ref: ${{ inputs.pull_request_number != '' && format('refs/pull/{0}/head', inputs.pull_request_number) || github.ref }}
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.10.14
- name: cpuinfo
run: cat /proc/cpuinfo
- name: Install test requirements
run: |
pip install -r tests/cross_fw/examples/requirements.txt
- name: Print installed modules
run: pip list
- name: Run examples test scope
run: |
set +e
python -m pytest -s -ra tests/cross_fw/examples \
-m cuda \
--junit-xml=pytest-results.xml \
--durations-path=tests/cross_fw/examples/test_durations.json \
--splitting-algorithm=least_duration \
--splits 1 \
--group ${{ matrix.group }} \
${{ env.PYTEST_ARGS }}
ret=$?
(( ret == 5 )) && [[ -n "${{ env.PYTEST_ARGS }}" ]] && exit 0
exit $ret
- name: Upload test results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: examples-cuda-pytest-results-${{ matrix.group }}
path: pytest-results.xml
retention-days: 7
examples-win-cpu:
timeout-minutes: 80
name: Test examples CPU Windows [${{ matrix.group }}/6]
runs-on: windows-2025-16-core
if: ${{ !inputs.skip_windows }}
strategy:
fail-fast: false
matrix:
group: [1, 2] # 3, 4, 5, 6]
defaults:
run:
shell: bash
env:
PYTHONIOENCODING: utf-8
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
lfs: false
fetch-depth: 0 # Fetch full history to allow checking out any branch or PR
ref: ${{ inputs.pull_request_number != '' && format('refs/pull/{0}/head', inputs.pull_request_number) || github.ref }}
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.10"
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
- name: Install NNCF and test requirements
run: |
pip install -r tests/cross_fw/examples/requirements.txt
- name: Print installed modules
run: pip list
- name: Run examples test scope
run: |
set +e
sys_lib="$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")"
prefix_lib="$(python -c "import sys; print(sys.prefix + '/libs')")"
include_dir="$(python -c "import sysconfig; print(sysconfig.get_path('include'))")"
export LIB="${LIB};${sys_lib};${prefix_lib}"
export INCLUDE="${INCLUDE};${include_dir}"
python -m pytest -s -ra tests/cross_fw/examples \
-m 'not cuda' \
--junit-xml=pytest-results.xml \
--durations-path=tests/cross_fw/examples/test_durations.json \
--splitting-algorithm=least_duration \
--splits 6 \
--group ${{ matrix.group }} \
${{ env.PYTEST_ARGS }}
ret=$?
(( ret == 5 )) && [[ -n "${{ env.PYTEST_ARGS }}" ]] && exit 0
exit $ret
- name: Upload test results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: examples-win-cpu-pytest-results-${{ matrix.group }}
path: pytest-results.xml
retention-days: 7
examples-cpu-summary:
name: Examples CPU Summary
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
needs: examples-cpu
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: .github/scripts/pytest_md_summary.py
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: examples-cpu-pytest-results-*
path: test-results
- name: Test Summary
run: |
pip install defusedxml==0.7.1
python .github/scripts/pytest_md_summary.py test-results >> "$GITHUB_STEP_SUMMARY"
examples-cuda-summary:
name: Examples CUDA Summary
runs-on: ubuntu-latest
if: ${{ !cancelled() && !inputs.skip_gpu }}
needs: examples-cuda
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: .github/scripts/pytest_md_summary.py
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: examples-cuda-pytest-results-*
path: test-results
- name: Test Summary
run: |
pip install defusedxml==0.7.1
python .github/scripts/pytest_md_summary.py test-results >> "$GITHUB_STEP_SUMMARY"
examples-win-cpu-summary:
name: Examples Windows CPU Summary
runs-on: ubuntu-latest
if: ${{ !cancelled() && !inputs.skip_windows }}
needs: examples-win-cpu
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: .github/scripts/pytest_md_summary.py
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: examples-win-cpu-pytest-results-*
path: test-results
- name: Test Summary
run: |
pip install defusedxml==0.7.1
python .github/scripts/pytest_md_summary.py test-results >> "$GITHUB_STEP_SUMMARY"