Skip to content

Run tests suite

Run tests suite #647

name: Run tests suite
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '28 2 * * *'
workflow_dispatch:
permissions: read-all
env:
MODULE_NAME: dpctl
TEST_ENV_NAME: test_dpctl
INTEL_CHANNEL: "https://software.repos.intel.com/python/conda/"
jobs:
test_linux:
# disable scheduled workflow to be run in forks
if: github.event.repository.fork == false
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
matrix:
dependencies: [conda-forge, intel]
python_spec: ['3.10', '3.11', '3.12', '3.13', '3.14.* *_cp314', '3.14.* *_cp314t']
runner: [ubuntu-22.04, ubuntu-24.04]
steps:
- name: Construct channels line
run: |
if [ "${{ matrix.dependencies }}" = "intel" ]; then
echo "CHANNELS=-c dppy/label/dev -c ${{ env.INTEL_CHANNEL }} -c conda-forge --override-channels" >> "$GITHUB_ENV"
else
echo "CHANNELS=-c dppy/label/dev -c conda-forge --override-channels" >> "$GITHUB_ENV"
fi
- name: Set pkgs_dirs
run: |
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
- name: Install dpctl
run: |
# shellcheck disable=SC2086
conda create -n "${{ env.TEST_ENV_NAME }}" ${{ env.CHANNELS }} dpctl pytest cython setuptools c-compiler cxx-compiler python="${{ matrix.python_spec }}"
- name: Report content of test environment
run: |
conda list -n "${{ env.TEST_ENV_NAME }}"
- name: Smoke test
run: |
. "$CONDA/etc/profile.d/conda.sh"
conda activate "${{ env.TEST_ENV_NAME }}"
python -m dpctl -f
- name: Create test temp dir
# create temporary empty folder to runs tests from
# https://github.com/pytest-dev/pytest/issues/11904
run: mkdir -p "${GITHUB_WORKSPACE}/test_tmp"
- name: Run tests
working-directory: ${{ github.workspace }}/test_tmp
env:
SYCL_CACHE_PERSISTENT: 1
run: |
. "$CONDA/etc/profile.d/conda.sh"
conda activate "${{ env.TEST_ENV_NAME }}"
python -m pytest -v --pyargs "${{ env.MODULE_NAME }}"
test_windows:
# disable scheduled workflow to be run in forks
if: github.event.repository.fork == false
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
defaults:
run:
shell: cmd /C CALL {0}
strategy:
matrix:
# see the comment on the dependencies of test_linux
dependencies: [conda-forge, intel]
python_spec: ['3.10', '3.11', '3.12', '3.13', '3.14.* *_cp314', '3.14.* *_cp314t']
runner: [windows-latest]
env:
workdir: '${{ github.workspace }}'
steps:
- name: Construct channels line
shell: pwsh
run: |
if ("${{ matrix.dependencies }}" -eq "intel") {
echo "CHANNELS=-c dppy/label/dev -c ${{ env.INTEL_CHANNEL }} -c conda-forge --override-channels" >> $env:GITHUB_ENV
} else {
echo "CHANNELS=-c dppy/label/dev -c conda-forge --override-channels" >> $env:GITHUB_ENV
}
- uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
with:
miniforge-version: latest
channels: conda-forge
conda-remove-defaults: true
activate-environment: ${{ env.TEST_ENV_NAME }}
- name: Install dpctl
run: |
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.CHANNELS }} dpctl pytest cython setuptools c-compiler cxx-compiler python="${{ matrix.python_spec }}"
- name: Report content of test environment
run: |
conda list -n ${{ env.TEST_ENV_NAME }}
- name: Register the OpenCL CPU driver with the ICD loader
shell: pwsh
run: |
$vendors = "HKLM:\SOFTWARE\Khronos\OpenCL\Vendors"
$script = "$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
if (Test-Path $script) {
& $script
} else {
$drivers = @(Get-ChildItem -Recurse -ErrorAction SilentlyContinue -Filter intelocl64.dll -Path "$env:CONDA_PREFIX\Library\bin")
if ($drivers.Count -eq 0) { throw "intel-opencl-rt installed no OpenCL CPU driver under $env:CONDA_PREFIX" }
if (-not (Test-Path $vendors)) { New-Item -Path $vendors -Force | Out-Null }
foreach ($driver in $drivers) {
New-ItemProperty -Path $vendors -Name $driver.FullName -Value 0 -PropertyType DWord -Force | Out-Null
}
}
Get-ItemProperty -Path $vendors
- name: Smoke test
shell: cmd /C CALL {0}
run: >-
conda activate ${{ env.TEST_ENV_NAME }} && python -m dpctl -f
- name: Create test temp dir
# create temporary empty folder to runs tests from
# https://github.com/pytest-dev/pytest/issues/11904
run: mkdir "${{ github.workspace }}\test_tmp"
- name: Run tests
shell: cmd /C CALL {0}
env:
SYCL_CACHE_PERSISTENT: 1
working-directory: ${{ github.workspace }}\test_tmp
run: |
conda activate ${{ env.TEST_ENV_NAME }} && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }}