[MAINT] Add additional pre-commit hooks
#6224
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Conda package | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| permissions: read-all | |
| env: | |
| PACKAGE_NAME: dpctl | |
| MODULE_NAME: dpctl | |
| TEST_ENV_NAME: test_dpctl | |
| VER_SCRIPT1: "import json; f = open('ver.json', 'r'); j = json.load(f); f.close(); d = j['dpctl'][0];" | |
| VER_SCRIPT2: "print('='.join((d[s] for s in ('version', 'build'))))" | |
| VER_SCRIPT3: "print(' '.join(map(lambda s: chr(34) + s + chr(34), [comp for comp in d['depends'] if 'dpcpp' in comp][1:])))" | |
| INTEL_CHANNEL: "https://software.repos.intel.com/python/conda/" | |
| jobs: | |
| build_linux: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 90 | |
| strategy: | |
| matrix: | |
| python: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - name: Cancel Previous Runs | |
| uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1 | |
| with: | |
| access_token: ${{ github.token }} | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set pkgs_dirs | |
| run: | | |
| echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc | |
| - name: Cache conda packages | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| env: | |
| CACHE_NUMBER: 3 # Increase to reset cache | |
| with: | |
| path: ~/.conda/pkgs | |
| key: | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- | |
| - name: Add conda to system path | |
| run: echo "$CONDA/bin" >> "$GITHUB_PATH" | |
| - name: Install conda-build | |
| run: conda install conda-build -c conda-forge --override-channels | |
| - name: Store conda paths as envs | |
| shell: bash -l {0} | |
| run: | | |
| echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE${{ runner.os == 'Linux' && '/' || '\\' }}" >> "$GITHUB_ENV" | |
| - name: Build conda package | |
| run: | | |
| # use bootstrap channel to pull NumPy linked with OpenBLAS | |
| conda build --no-test --python ${{ matrix.python }} --numpy 2.0 -c conda-forge --override-channels conda-recipe | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} | |
| path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.conda | |
| - name: Upload wheels artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }} | |
| path: ${{ env.WHEELS_OUTPUT_FOLDER }}${{ env.PACKAGE_NAME }}-*.whl | |
| build_windows: | |
| runs-on: windows-latest | |
| timeout-minutes: 150 | |
| defaults: | |
| run: | |
| shell: cmd /C CALL {0} | |
| strategy: | |
| matrix: | |
| python: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - name: Cancel Previous Runs | |
| uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1 | |
| with: | |
| access_token: ${{ github.token }} | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0 | |
| with: | |
| miniforge-version: latest | |
| activate-environment: build | |
| channels: conda-forge | |
| python-version: ${{ matrix.python }} | |
| - name: Install conda build | |
| run: | | |
| conda install -n base -y conda-build | |
| conda list -n base | |
| - name: Cache conda packages | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| env: | |
| CACHE_NUMBER: 3 # Increase to reset cache | |
| with: | |
| path: /home/runner/conda_pkgs_dir | |
| key: | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- | |
| - name: Store conda paths as envs | |
| shell: bash -l {0} | |
| run: | | |
| echo "CONDA_BLD=$CONDA/conda-bld/win-64/" | tr "\\\\" '/' >> "$GITHUB_ENV" | |
| echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE${{ runner.os == 'Linux' && '/' || '\\' }}" >> "$GITHUB_ENV" | |
| - name: Build conda package | |
| env: | |
| OVERRIDE_INTEL_IPO: 1 # IPO requires more resources that GH actions VM provides | |
| run: | | |
| conda build --no-test --python ${{ matrix.python }} --numpy 2.0 -c conda-forge --override-channels conda-recipe | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} | |
| path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.conda | |
| - name: Upload wheels artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }} | |
| path: ${{ env.WHEELS_OUTPUT_FOLDER }}${{ env.PACKAGE_NAME }}-*.whl | |
| test_linux: | |
| needs: build_linux | |
| runs-on: ${{ matrix.runner }} | |
| timeout-minutes: 30 | |
| strategy: | |
| matrix: | |
| python: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| experimental: [false] | |
| runner: [ubuntu-latest] | |
| continue-on-error: ${{ matrix.experimental }} | |
| steps: | |
| - name: Construct channels line | |
| run: | | |
| echo "CHANNELS=-c ${{ env.INTEL_CHANNEL }} -c conda-forge --override-channels" >> "$GITHUB_ENV" | |
| - name: Display channels line | |
| run: | | |
| echo "${{ env.CHANNELS }}" | |
| - name: Download artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} | |
| - name: Add conda to system path | |
| run: echo "$CONDA/bin" >> "$GITHUB_PATH" | |
| - name: Install conda-index | |
| # Needed to be able to run conda index | |
| run: | | |
| conda update -n base --all | |
| conda install conda-index -c conda-forge --override-channels | |
| - name: Create conda channel | |
| run: | | |
| mkdir -p "$GITHUB_WORKSPACE/channel/linux-64" | |
| conda index "$GITHUB_WORKSPACE/channel" || exit 1 | |
| mv "${PACKAGE_NAME}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1 | |
| conda index "$GITHUB_WORKSPACE/channel" || exit 1 | |
| # Test channel | |
| conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json" | |
| cat ver.json | |
| - name: Collect dependencies | |
| run: | | |
| CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}" | |
| export CHANNELS | |
| PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}") | |
| export PACKAGE_VERSION | |
| # shellcheck disable=SC2086 | |
| conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=${PACKAGE_VERSION} python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile | |
| cat lockfile | |
| - name: Set pkgs_dirs | |
| run: | | |
| echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc | |
| - name: Cache conda packages | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| env: | |
| CACHE_NUMBER: 3 # Increase to reset cache | |
| with: | |
| path: ~/.conda/pkgs | |
| key: | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }} | |
| restore-keys: | | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- | |
| - name: Install dpctl | |
| run: | | |
| CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}" | |
| export CHANNELS | |
| TEST_DEPENDENCIES="pytest pytest-cov cython setuptools" | |
| export TEST_DEPENDENCIES | |
| PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}") | |
| export PACKAGE_VERSION | |
| # shellcheck disable=SC2086 | |
| conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=${PACKAGE_VERSION} $TEST_DEPENDENCIES python=${{ matrix.python }} $CHANNELS | |
| # Test installed packages | |
| conda list -n "${{ env.TEST_ENV_NAME }}" | |
| - name: Smoke test | |
| run: | | |
| . "$CONDA/etc/profile.d/conda.sh" | |
| conda activate "${{ env.TEST_ENV_NAME }}" | |
| python -c "import dpctl; dpctl.lsplatform(verbosity=2)" | |
| - 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: | |
| needs: build_windows | |
| runs-on: ${{ matrix.runner }} | |
| timeout-minutes: 60 | |
| defaults: | |
| run: | |
| shell: cmd /C CALL {0} | |
| strategy: | |
| matrix: | |
| python: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| experimental: [false] | |
| runner: [windows-latest] | |
| continue-on-error: ${{ matrix.experimental }} | |
| env: | |
| workdir: '${{ github.workspace }}' | |
| steps: | |
| - name: Construct channels line | |
| shell: pwsh | |
| run: | | |
| echo "CHANNELS=-c ${{ env.INTEL_CHANNEL }} -c conda-forge --override-channels" >> $env:GITHUB_ENV | |
| - name: Display channels line | |
| run: | | |
| echo "${{ env.CHANNELS }}" | |
| - name: Download artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} | |
| - uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0 | |
| with: | |
| miniforge-version: latest | |
| channels: conda-forge | |
| activate-environment: ${{ env.TEST_ENV_NAME }} | |
| python-version: ${{ matrix.python }} | |
| - name: Install conda-index | |
| run: | | |
| conda install -n base conda-index | |
| - name: Create conda channel with the artifact bit | |
| shell: cmd /C CALL {0} | |
| run: | | |
| @echo on | |
| echo ${{ env.workdir }} | |
| mkdir ${{ env.workdir }}\channel | |
| mkdir ${{ env.workdir }}\channel\win-64 | |
| move ${{ env.PACKAGE_NAME }}-*.conda ${{ env.workdir }}\channel\win-64 | |
| dir ${{ env.workdir }}\channel\win-64\ | |
| - name: Index the channel | |
| shell: cmd /C CALL {0} | |
| run: | | |
| @echo on | |
| conda index ${{ env.workdir }}\channel | |
| - name: List content of the channels | |
| shell: cmd /C CALL {0} | |
| run: | | |
| dir ${{ env.workdir }}\channel | |
| dir ${{ env.workdir }}\channel\win-64 | |
| - name: Dump dpctl version info from created channel into ver.json | |
| shell: cmd /C CALL {0} | |
| run: | | |
| @echo on | |
| conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json | |
| dir ${{ env.workdir }} | |
| - name: Output content of produced ver.json | |
| shell: pwsh | |
| run: Get-Content -Path ${{ env.workdir }}\ver.json | |
| - name: Collect dependencies | |
| shell: cmd /C CALL {0} | |
| run: | | |
| IF NOT EXIST ver.json ( | |
| copy /Y ${{ env.workdir }}\ver.json . | |
| ) | |
| SET "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%" | |
| FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO ( | |
| SET PACKAGE_VERSION=%%F | |
| ) | |
| conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile | |
| - name: Display lockfile content | |
| shell: pwsh | |
| run: Get-Content -Path .\lockfile | |
| - name: Cache conda packages | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| env: | |
| CACHE_NUMBER: 3 # Increase to reset cache | |
| with: | |
| path: /home/runner/conda_pkgs_dir | |
| key: | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }} | |
| restore-keys: | | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- | |
| - name: Install opencl_rt | |
| shell: cmd /C CALL {0} | |
| run: conda install -n ${{ env.TEST_ENV_NAME }} opencl_rt -c ${{ env.INTEL_CHANNEL }} --override-channels | |
| - name: Install dpctl | |
| shell: cmd /C CALL {0} | |
| run: | | |
| @ECHO ON | |
| IF NOT EXIST ver.json ( | |
| copy /Y ${{ env.workdir }}\ver.json . | |
| ) | |
| set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%" | |
| FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO ( | |
| SET PACKAGE_VERSION=%%F | |
| ) | |
| SET TEST_DEPENDENCIES=pytest"<8" pytest-cov cython setuptools | |
| conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} | |
| - name: Report content of test environment | |
| shell: cmd /C CALL {0} | |
| run: | | |
| echo "Value of CONDA environment variable was: " %CONDA% | |
| echo "Value of CONDA_PREFIX environment variable was: " %CONDA_PREFIX% | |
| conda info && conda list -n ${{ env.TEST_ENV_NAME }} | |
| - name: Configure Intel OpenCL CPU RT | |
| 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, step 1 | |
| shell: cmd /C CALL {0} | |
| run: >- | |
| conda activate ${{ env.TEST_ENV_NAME }} && python -c "import sys; print(sys.executable)" | |
| - name: Smoke test, step 2 | |
| shell: cmd /C CALL {0} | |
| run: >- | |
| conda activate ${{ env.TEST_ENV_NAME }} && python -m dpctl -f | |
| - name: Create empty temporary directory to run tests from | |
| shell: cmd /C CALL {0} | |
| # create temporary empty folder to runs tests from | |
| # https://github.com/pytest-dev/pytest/issues/11904 | |
| run: >- | |
| mkdir "${{ env.workdir }}\test_tmp" | |
| - name: List content of workdir folder | |
| shell: cmd /C CALL {0} | |
| run: dir "${{ env.workdir }}" | |
| - name: Run tests | |
| shell: cmd /C CALL {0} | |
| env: | |
| SYCL_CACHE_PERSISTENT: 1 | |
| working-directory: ${{ env.workdir }}\test_tmp | |
| run: >- | |
| conda activate ${{ env.TEST_ENV_NAME }} && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }} | |
| upload_linux: | |
| needs: test_linux | |
| if: | | |
| (github.repository == 'IntelPython/dpctl') && | |
| (github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/')) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| strategy: | |
| matrix: | |
| python: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - name: Download conda artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} | |
| - name: Download wheel artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }} | |
| - name: Install anaconda-client | |
| run: conda install anaconda-client -c conda-forge --override-channels | |
| - name: Add conda to system path | |
| run: echo "$CONDA/bin" >> "$GITHUB_PATH" | |
| - name: Package version | |
| run: echo "PACKAGE_VERSION=$(basename ${{ env.PACKAGE_NAME }}-*.conda | sed 's/^${{ env.PACKAGE_NAME }}-\([^-]*\).*/\1/')" >> "$GITHUB_ENV" | |
| - name: Upload | |
| env: | |
| ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }} | |
| if: ${{ env.ANACONDA_TOKEN != '' }} | |
| run: | | |
| anaconda --token "${{ env.ANACONDA_TOKEN }}" upload --user dppy --label dev "${{ env.PACKAGE_NAME }}"-*.conda | |
| - name: Upload Wheels | |
| env: | |
| ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }} | |
| run: anaconda --token "${{ env.ANACONDA_TOKEN }}" upload --user dppy --label dev "${{ env.PACKAGE_NAME }}"-*.whl --version "${{ env.PACKAGE_VERSION }}" | |
| upload_windows: | |
| needs: test_windows | |
| if: | | |
| (github.repository == 'IntelPython/dpctl') && | |
| (github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/')) | |
| runs-on: windows-latest | |
| timeout-minutes: 20 | |
| defaults: | |
| run: | |
| shell: cmd /C CALL {0} | |
| strategy: | |
| matrix: | |
| python: ['3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} | |
| - name: Download wheel artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }} | |
| - uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0 | |
| with: | |
| miniforge-version: latest | |
| channels: conda-forge | |
| activate-environment: upload | |
| - name: Install anaconda-client | |
| run: conda install anaconda-client -c conda-forge --override-channels | |
| - name: Package version | |
| shell: bash -el {0} | |
| run: echo "PACKAGE_VERSION=$(basename ${{ env.PACKAGE_NAME }}-*.conda | sed 's/^${{ env.PACKAGE_NAME }}-\([^-]*\).*/\1/')" >> "$GITHUB_ENV" | |
| - name: Upload | |
| env: | |
| ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }} | |
| run: | | |
| anaconda --token "${{ env.ANACONDA_TOKEN }}" upload --user dppy --label dev "${{ env.PACKAGE_NAME }}"-*.conda | |
| - name: Upload Wheels | |
| env: | |
| ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }} | |
| run: anaconda --token "${{ env.ANACONDA_TOKEN }}" upload --user dppy --label dev "${{ env.PACKAGE_NAME }}"-*.whl --version "${{ env.PACKAGE_VERSION }}" | |
| test_examples_linux: | |
| needs: build_linux | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: | |
| python: ['3.11'] | |
| experimental: [false] | |
| runner: [ubuntu-latest] | |
| continue-on-error: ${{ matrix.experimental }} | |
| timeout-minutes: 60 | |
| env: | |
| EXAMPLES_ENV_NAME: examples | |
| BUILD_ENV_NAME: build_env | |
| steps: | |
| - name: Construct channels line | |
| run: | | |
| echo "CHANNELS=-c ${{ env.INTEL_CHANNEL }} -c conda-forge --override-channels" >> "$GITHUB_ENV" | |
| - name: Display channels line | |
| run: | | |
| echo ${{ env.CHANNELS }} | |
| - name: Install conda-index | |
| # Needed to be able to run conda index | |
| run: | | |
| conda update -n base --all | |
| conda install conda-index -c conda-forge --override-channels | |
| - name: Checkout dpctl repo | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} | |
| - name: Add conda to system path | |
| run: echo "$CONDA/bin" >> "$GITHUB_PATH" | |
| - name: Create conda channel | |
| run: | | |
| mkdir -p "$GITHUB_WORKSPACE/channel/linux-64" | |
| conda index "$GITHUB_WORKSPACE/channel" || exit 1 | |
| mv "${{ env.PACKAGE_NAME }}"-*.conda "$GITHUB_WORKSPACE/channel/linux-64" || exit 1 | |
| conda index "$GITHUB_WORKSPACE/channel" || exit 1 | |
| # Test channel | |
| conda search "$PACKAGE_NAME" -c "$GITHUB_WORKSPACE/channel" --override-channels --info --json > "$GITHUB_WORKSPACE/ver.json" | |
| cat ver.json | |
| - name: Collect dependencies | |
| run: | | |
| CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}" | |
| export CHANNELS | |
| PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}") | |
| export PACKAGE_VERSION | |
| # shellcheck disable=SC2086 | |
| conda create -n ${{ env.EXAMPLES_ENV_NAME }} ${{ env.PACKAGE_NAME }}=${PACKAGE_VERSION} python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile | |
| cat lockfile | |
| - name: Set pkgs_dirs | |
| run: | | |
| echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc | |
| - name: Cache conda packages | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| env: | |
| CACHE_NUMBER: 3 # Increase to reset cache | |
| with: | |
| path: ~/.conda/pkgs | |
| key: | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }} | |
| restore-keys: | | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- | |
| ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- | |
| - name: Install example requirements | |
| shell: bash -ex -l {0} | |
| env: | |
| # TODO: unpin when 2026.0 is available on conda-forge | |
| DPCPP_CMPLR: "dpcpp_linux-64>=2025.0,<2026.0" | |
| run: | | |
| export CHANNELS="${{ env.CHANNELS }}" | |
| . "$CONDA/etc/profile.d/conda.sh" | |
| DPCTL_DEPENDS="$(python -c "${VER_SCRIPT1} ${VER_SCRIPT3}")" | |
| export DPCTL_DEPENDS | |
| echo "Dpctl dependencies: ${DPCTL_DEPENDS}" | |
| # shellcheck disable=SC2086 | |
| conda create -n ${{ env.EXAMPLES_ENV_NAME }} -y pytest python=${{ matrix.python }} "setuptools<72.2.0" $CHANNELS | |
| echo "Environment created" | |
| # shellcheck disable=SC2086 | |
| conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y cmake ninja $CHANNELS || exit 1 | |
| echo "Cmake and Ninja installed" | |
| # shellcheck disable=SC2086 | |
| conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y pybind11 cython scikit-build $CHANNELS || exit 1 | |
| echo "scikit-build installed" | |
| # shellcheck disable=SC2086 | |
| conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y mkl-dpcpp \ | |
| mkl-devel-dpcpp dpcpp_cpp_rt "${DPCTL_DEPENDS}" \ | |
| $CHANNELS || exit 1 | |
| echo "IPL installed" | |
| # shellcheck disable=SC2086 | |
| conda create -y -n ${{ env.BUILD_ENV_NAME }} $CHANNELS gcc_linux-64 gxx_linux-64 \ | |
| "${{ env.DPCPP_CMPLR }}" "${DPCTL_DEPENDS}" \ | |
| "sysroot_linux-64>=2.28" | |
| echo "Compiler installed" | |
| conda list -n "${{ env.BUILD_ENV_NAME }}" | |
| - name: Install dpctl | |
| shell: bash -l {0} | |
| run: | | |
| source "$CONDA/etc/profile.d/conda.sh" | |
| CHANNELS="-c $GITHUB_WORKSPACE/channel -c dppy/label/dev -c ${{ env.INTEL_CHANNEL }} -c conda-forge --override-channels" | |
| export CHANNELS | |
| PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}") | |
| export PACKAGE_VERSION | |
| # shellcheck disable=SC2086 | |
| conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y $CHANNELS ${{ env.PACKAGE_NAME }}=${PACKAGE_VERSION} || exit 1 | |
| - name: Build and run examples of pybind11 extensions | |
| shell: bash -l {0} | |
| run: | | |
| source "$CONDA/etc/profile.d/conda.sh" | |
| conda activate "${{ env.EXAMPLES_ENV_NAME }}" | |
| conda list | |
| cd examples/pybind11 | |
| while IFS= read -r d; do | |
| pushd "$d" > /dev/null | |
| conda activate --stack build_env | |
| CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1 | |
| conda deactivate | |
| if [ -e tests ]; then | |
| LD_LIBRARY_PATH="${CONDA_PREFIX}/lib" python -m pytest tests || exit 1 | |
| else | |
| LD_LIBRARY_PATH="${CONDA_PREFIX}/lib" python example.py || exit 1 | |
| fi | |
| popd > /dev/null | |
| done < <(find . -maxdepth 1 -type d -not -path ".") | |
| - name: Build and run examples of Cython extensions | |
| shell: bash -l {0} | |
| run: | | |
| source "$CONDA/etc/profile.d/conda.sh" | |
| conda activate "${{ env.EXAMPLES_ENV_NAME }}" | |
| conda list | |
| cd examples/cython | |
| while IFS= read -r d; do | |
| pushd "$d" > /dev/null | |
| conda activate --stack "${{ env.BUILD_ENV_NAME }}" | |
| CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1 | |
| conda deactivate | |
| python -m pytest tests || exit 1 | |
| popd > /dev/null | |
| done < <(find . -maxdepth 1 -type d -not -path ".") | |
| - name: Build and run examples of C-extensions | |
| shell: bash -l {0} | |
| run: | | |
| source "$CONDA/etc/profile.d/conda.sh" | |
| conda activate "${{ env.EXAMPLES_ENV_NAME }}" | |
| conda list | |
| cd examples/c | |
| while IFS= read -r d; do | |
| pushd "$d" > /dev/null | |
| conda activate --stack "${{ env.BUILD_ENV_NAME }}" | |
| python setup.py build_ext --inplace || exit 1 | |
| conda deactivate | |
| python -m pytest tests || exit 1 | |
| popd > /dev/null | |
| done < <(find . -maxdepth 1 -type d -not -path ".") | |
| - name: Run Python examples | |
| shell: bash -l {0} | |
| run: | | |
| cd examples/python | |
| source "$CONDA/etc/profile.d/conda.sh" | |
| conda activate "${{ env.EXAMPLES_ENV_NAME }}" | |
| while IFS= read -r script; do | |
| echo "Executing ${script}" | |
| python "${script}" || exit 1 | |
| done < <(find . \( -not -name "_*" -and -name "*.py" \)) | |
| cleanup_packages: | |
| name: Clean up anaconda packages | |
| needs: [upload_linux, upload_windows] | |
| runs-on: 'ubuntu-latest' | |
| timeout-minutes: 30 | |
| defaults: | |
| run: | |
| shell: bash -el {0} | |
| steps: | |
| - uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0 | |
| with: | |
| run-post: false | |
| channel-priority: "disabled" | |
| channels: conda-forge | |
| python-version: '3.11' | |
| - name: Install anaconda-client | |
| run: conda install anaconda-client -c conda-forge --override-channels | |
| - name: Checkout repo | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| repository: IntelPython/devops-tools | |
| fetch-depth: 0 | |
| - name: Cleanup old packages | |
| run: | | |
| python scripts/cleanup-old-packages.py \ | |
| --verbose --force --token ${{ secrets.ANACONDA_TOKEN }} \ | |
| --package dppy/${{ env.PACKAGE_NAME }} --label dev |