Skip to content

Run tests suite

Run tests suite #355

name: Run tests suite
on:
# To be able to be triggered manually
workflow_dispatch:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '28 2 * * *'
permissions: read-all
env:
package-name: dpnp
channels-list: '-c dppy/label/dev -c https://software.repos.intel.com/python/conda/ -c conda-forge --override-channels'
test-env-name: test
rerun-tests-max-attempts: 2
rerun-tests-timeout: 20
jobs:
test:
name: Test
# disable scheduled workflow to be run in forks
if: github.event.repository.fork == false
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
defaults:
run:
shell: ${{ matrix.runner == 'windows-2022' && 'cmd /C CALL {0}' || 'bash -el {0}' }}
permissions:
# Needed to cancel any previous runs that are not completed for a given workflow
actions: write
strategy:
fail-fast: false
matrix:
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
runner: [ubuntu-22.04, ubuntu-24.04, windows-2022]
include:
- python: 3.9
# do not install scipy due to import issue
test-packages: "pytest"
- python: 3.10
test-packages: "pytest scipy"
- python: 3.11
test-packages: "pytest scipy"
- python: 3.12
test-packages: "pytest scipy"
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1
with:
access_token: ${{ github.token }}
- name: Find the latest tag
id: find_latest_tag
uses: oprypin/find-latest-tag@dd2729fe78b0bb55523ae2b2a310c6773a652bd1 # 1.1.2
with:
repository: IntelPython/dpnp
releases-only: false
- name: Print latest tag
run: |
echo "Latest tag is ${{ steps.find_latest_tag.outputs.tag }}"
- name: Setup miniconda
id: setup_miniconda
continue-on-error: true
uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
with:
miniforge-version: latest
use-mamba: 'true'
channels: conda-forge
conda-remove-defaults: 'true'
python-version: ${{ matrix.python }}
activate-environment: ${{ env.test-env-name }}
- name: ReSetup miniconda
if: steps.setup_miniconda.outcome == 'failure'
uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
with:
miniforge-version: latest
use-mamba: 'true'
channels: conda-forge
conda-remove-defaults: 'true'
python-version: ${{ matrix.python }}
activate-environment: ${{ env.test-env-name }}
- name: Install dpnp
id: install_dpnp
continue-on-error: true
run: |
mamba install ${{ env.package-name }}=${{ steps.find_latest_tag.outputs.tag }} ${{ matrix.test-packages }} ${{ env.channels-list }}
- name: ReInstall dpnp
if: steps.install_dpnp.outcome == 'failure'
run: |
mamba install ${{ env.package-name }}=${{ steps.find_latest_tag.outputs.tag }} ${{ matrix.test-packages }} ${{ env.channels-list }}
- name: List installed packages
run: mamba list
- name: Activate OCL CPU RT
if: matrix.runner == 'windows-2022'
shell: pwsh
run: |
$script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
if (Test-Path $script_path) {
&$script_path
} else {
Write-Warning "File $script_path was NOT found!"
}
# Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default
$cl_cfg="$env:CONDA_PREFIX\Library\bin\cl.cfg"
Get-Content -Tail 5 -Path $cl_cfg
- name: Smoke test
run: |
python -m dpctl -f
python -c "import dpnp; print(dpnp.__version__)"
- name: Run tests
id: run_tests
continue-on-error: true
run: |
python -m pytest -ra --pyargs ${{ env.package-name }}.tests
env:
SYCL_CACHE_PERSISTENT: 1
- name: ReRun tests on Linux
if: steps.run_tests.outcome == 'failure' && matrix.runner != 'windows-2022'
id: run_tests_linux
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
with:
timeout_minutes: ${{ env.rerun-tests-timeout }}
max_attempts: ${{ env.rerun-tests-max-attempts }}
retry_on: any
command: |
. $CONDA/etc/profile.d/conda.sh
. $CONDA/etc/profile.d/mamba.sh
mamba activate ${{ env.test-env-name }}
python -m pytest -ra --pyargs ${{ env.package-name }}.tests
env:
SYCL_CACHE_PERSISTENT: 1
- name: ReRun tests on Windows
if: steps.run_tests.outcome == 'failure' && matrix.runner == 'windows-2022'
id: run_tests_win
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
with:
timeout_minutes: ${{ env.rerun-tests-timeout }}
max_attempts: ${{ env.rerun-tests-max-attempts }}
retry_on: any
command: |
python -m pytest -ra --pyargs ${{ env.package-name }}.tests
env:
SYCL_CACHE_PERSISTENT: 1