Skip to content

Commit be4a01c

Browse files
Merge pull request #1566 from IntelPython/deal-with-pytest-permission-failure-on-window
To work around an issue in pytest, run tests from empty temp dir
2 parents be6bced + b961b1a commit be4a01c

File tree

1 file changed

+50
-32
lines changed

1 file changed

+50
-32
lines changed

.github/workflows/conda-package.yml

+50-32
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ permissions: read-all
1111
env:
1212
PACKAGE_NAME: dpctl
1313
MODULE_NAME: dpctl
14+
TEST_ENV_NAME: test_dpctl
1415
VER_SCRIPT1: "import json; f = open('ver.json', 'r'); j = json.load(f); f.close(); "
1516
VER_SCRIPT2: "d = j['dpctl'][0]; print('='.join((d[s] for s in ('version', 'build'))))"
1617

@@ -155,7 +156,7 @@ jobs:
155156
run: |
156157
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
157158
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
158-
conda create -n test_dpctl $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile
159+
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile
159160
cat lockfile
160161
- name: Set pkgs_dirs
161162
run: |
@@ -176,13 +177,13 @@ jobs:
176177
export CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
177178
export TEST_DEPENDENCIES="pytest pytest-cov cython"
178179
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
179-
conda create -n test_dpctl $PACKAGE_NAME=${PACKAGE_VERSION} ${TEST_DEPENDENCIES} python=${{ matrix.python }} ${CHANNELS}
180+
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} ${TEST_DEPENDENCIES} python=${{ matrix.python }} ${CHANNELS}
180181
# Test installed packages
181-
conda list -n test_dpctl
182+
conda list -n ${{ env.TEST_ENV_NAME }}
182183
- name: Smoke test
183184
run: |
184185
. $CONDA/etc/profile.d/conda.sh
185-
conda activate test_dpctl
186+
conda activate ${{ env.TEST_ENV_NAME }}
186187
python -c "import dpctl; dpctl.lsplatform(verbosity=2)"
187188
- name: Install gdb
188189
run: |
@@ -191,14 +192,19 @@ jobs:
191192
- name: Run test_elementwise under gdb
192193
run: |
193194
. $CONDA/etc/profile.d/conda.sh
194-
conda activate test_dpctl
195+
conda activate ${{ env.TEST_ENV_NAME }}
195196
gdb --batch -ex r -ex 'info sharedlibrary' -ex 'set print elements 1000' -ex bt --args ${CONDA_PREFIX}/bin/python -m pytest -q -ra --disable-warnings --pyargs dpctl.tests.elementwise.test_trigonometric::test_trig_order -vv || true
197+
- name: Create test temp dir
198+
# create temporary empty folder to runs tests from
199+
# https://github.com/pytest-dev/pytest/issues/11904
200+
run: mkdir -p ${GITHUB_WORKSPACE}/test_tmp
196201
- name: Run tests
202+
working-directory: ${{ github.workspace }}/test_tmp
197203
env:
198204
SYCL_CACHE_PERSISTENT: 1
199205
run: |
200206
. $CONDA/etc/profile.d/conda.sh
201-
conda activate test_dpctl
207+
conda activate ${{ env.TEST_ENV_NAME }}
202208
python -m pytest -v --pyargs $MODULE_NAME
203209
204210
test_windows:
@@ -227,7 +233,7 @@ jobs:
227233
auto-update-conda: true
228234
conda-build-version: '*'
229235
miniconda-version: 'latest'
230-
activate-environment: dpctl_test
236+
activate-environment: ${{ env.TEST_ENV_NAME }}
231237
python-version: ${{ matrix.python }}
232238
- name: Create conda channel with the artifact bit
233239
shell: cmd /C CALL {0}
@@ -257,7 +263,7 @@ jobs:
257263
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
258264
SET PACKAGE_VERSION=%%F
259265
)
260-
conda install -n dpctl_test ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
266+
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
261267
- name: Display lockfile content
262268
shell: pwsh
263269
run: Get-Content -Path .\lockfile
@@ -274,7 +280,7 @@ jobs:
274280
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
275281
- name: Install opencl_rt
276282
shell: cmd /C CALL {0}
277-
run: conda install -n dpctl_test opencl_rt -c intel --override-channels
283+
run: conda install -n ${{ env.TEST_ENV_NAME }} opencl_rt -c intel --override-channels
278284
- name: Install dpctl
279285
shell: cmd /C CALL {0}
280286
run: |
@@ -286,14 +292,14 @@ jobs:
286292
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
287293
SET PACKAGE_VERSION=%%F
288294
)
289-
SET "TEST_DEPENDENCIES=pytest pytest-cov cython"
290-
conda install -n dpctl_test ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
295+
SET TEST_DEPENDENCIES=pytest"<8" pytest-cov cython
296+
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
291297
- name: Report content of test environment
292298
shell: cmd /C CALL {0}
293299
run: |
294300
echo "Value of CONDA enviroment variable was: " %CONDA%
295301
echo "Value of CONDA_PREFIX enviroment variable was: " %CONDA_PREFIX%
296-
conda info && conda list -n dpctl_test
302+
conda info && conda list -n ${{ env.TEST_ENV_NAME }}
297303
- name: Configure Intel OpenCL CPU RT
298304
shell: pwsh
299305
run: |
@@ -305,17 +311,27 @@ jobs:
305311
- name: Smoke test, step 1
306312
shell: cmd /C CALL {0}
307313
run: >-
308-
conda activate dpctl_test && python -c "import sys; print(sys.executable)"
314+
conda activate ${{ env.TEST_ENV_NAME }} && python -c "import sys; print(sys.executable)"
309315
- name: Smoke test, step 2
310316
shell: cmd /C CALL {0}
311317
run: >-
312-
conda activate dpctl_test && python -m dpctl -f
318+
conda activate ${{ env.TEST_ENV_NAME }} && python -m dpctl -f
319+
- name: Create empty temporary directory to run tests from
320+
shell: cmd /C CALL {0}
321+
# create temporary empty folder to runs tests from
322+
# https://github.com/pytest-dev/pytest/issues/11904
323+
run: >-
324+
mkdir "${{ env.workdir }}\test_tmp"
325+
- name: List content of workdir folder
326+
shell: cmd /C CALL {0}
327+
run: dir "${{ env.workdir }}"
313328
- name: Run tests
314329
shell: cmd /C CALL {0}
315330
env:
316331
SYCL_CACHE_PERSISTENT: 1
332+
working-directory: ${{ env.workdir }}\test_tmp
317333
run: >-
318-
conda activate dpctl_test && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }}
334+
conda activate ${{ env.TEST_ENV_NAME }} && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }}
319335
320336
upload_linux:
321337
needs: test_linux
@@ -405,6 +421,8 @@ jobs:
405421
continue-on-error: ${{ matrix.experimental }}
406422
env:
407423
CHANNELS: -c intel -c conda-forge --override-channels
424+
EXAMPLES_ENV_NAME: examples
425+
BUILD_ENV_NAME: build_env
408426

409427
steps:
410428
- name: Install conda-build
@@ -454,24 +472,24 @@ jobs:
454472
run: |
455473
CHANNELS="${{ env.CHANNELS }}"
456474
. $CONDA/etc/profile.d/conda.sh
457-
conda create -n examples -y pytest python=${{ matrix.python }} $CHANNELS
458-
conda install -n examples -y cmake">=3.22" $CHANNELS || exit 1
459-
conda install -n examples -y ninja $CHANNELS || exit 1
460-
conda install -n examples -y pybind11 cython scikit-build $CHANNELS || exit 1
461-
conda install -n examples -y mkl-dpcpp mkl-devel-dpcpp dpcpp_cpp_rt $CHANNELS || exit 1
462-
conda create -y -n build_env $CHANNELS gcc_linux-64 gxx_linux-64 ${{ env.DPCPP_CMPLR }} sysroot_linux-64">=2.28"
475+
conda create -n ${{ env.EXAMPLES_ENV_NAME }} -y pytest python=${{ matrix.python }} $CHANNELS
476+
conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y cmake">=3.22" $CHANNELS || exit 1
477+
conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y ninja $CHANNELS || exit 1
478+
conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y pybind11 cython scikit-build $CHANNELS || exit 1
479+
conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y mkl-dpcpp mkl-devel-dpcpp dpcpp_cpp_rt $CHANNELS || exit 1
480+
conda create -y -n ${{ env.BUILD_ENV_NAME }} $CHANNELS gcc_linux-64 gxx_linux-64 ${{ env.DPCPP_CMPLR }} sysroot_linux-64">=2.28"
463481
- name: Install dpctl
464482
shell: bash -l {0}
465483
run: |
466484
source $CONDA/etc/profile.d/conda.sh
467485
CHANNELS="-c $GITHUB_WORKSPACE/channel -c dppy/label/dev -c intel -c conda-forge --override-channels"
468486
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
469-
conda install -n examples -y ${CHANNELS} dpctl=${PACKAGE_VERSION} dpnp">=0.10.1" || exit 1
487+
conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y ${CHANNELS} dpctl=${PACKAGE_VERSION} dpnp || exit 1
470488
- name: Build and run examples of pybind11 extensions
471489
shell: bash -l {0}
472490
run: |
473491
source $CONDA/etc/profile.d/conda.sh
474-
conda activate examples
492+
conda activate ${{ env.EXAMPLES_ENV_NAME }}
475493
conda list
476494
cd examples/pybind11
477495
for d in $(find . -maxdepth 1 -type d -not -path ".")
@@ -498,13 +516,13 @@ jobs:
498516
shell: bash -l {0}
499517
run: |
500518
source $CONDA/etc/profile.d/conda.sh
501-
conda activate examples
519+
conda activate ${{ env.EXAMPLES_ENV_NAME }}
502520
conda list
503521
cd examples/cython
504522
for d in $(find . -maxdepth 1 -type d -not -path ".")
505523
do
506524
pushd $d
507-
conda activate --stack build_env
525+
conda activate --stack ${{ env.BUILD_ENV_NAME }}
508526
python setup.py build_ext --inplace || exit 1
509527
conda deactivate
510528
python -m pytest tests || exit 1
@@ -514,13 +532,13 @@ jobs:
514532
shell: bash -l {0}
515533
run: |
516534
source $CONDA/etc/profile.d/conda.sh
517-
conda activate examples
535+
conda activate ${{ env.EXAMPLES_ENV_NAME }}
518536
conda list
519537
cd examples/c
520538
for d in $(find . -maxdepth 1 -type d -not -path ".")
521539
do
522540
pushd $d
523-
conda activate --stack build_env
541+
conda activate --stack ${{ env.BUILD_ENV_NAME }}
524542
python setup.py build_ext --inplace || exit 1
525543
conda deactivate
526544
python -m pytest tests || exit 1
@@ -531,7 +549,7 @@ jobs:
531549
run: |
532550
cd examples/python
533551
source $CONDA/etc/profile.d/conda.sh
534-
conda activate examples
552+
conda activate ${{ env.EXAMPLES_ENV_NAME }}
535553
for script in $(find . \( -not -name "_*" -and -name "*.py" \))
536554
do
537555
echo "Executing ${script}"
@@ -599,7 +617,7 @@ jobs:
599617
run: |
600618
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
601619
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
602-
conda create -n test_dpctl $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile
620+
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile
603621
cat lockfile
604622
- name: Set pkgs_dirs
605623
run: |
@@ -619,14 +637,14 @@ jobs:
619637
run: |
620638
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
621639
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
622-
conda create -n test_dpctl $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} $CHANNELS
640+
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} $CHANNELS
623641
# Test installed packages
624642
conda list
625643
- name: Install array API test dependencies
626644
shell: bash -l {0}
627645
run: |
628646
. $CONDA/etc/profile.d/conda.sh
629-
conda activate test_dpctl
647+
conda activate ${{ env.TEST_ENV_NAME }}
630648
cd /home/runner/work/array-api-tests
631649
pip install -r requirements.txt
632650
- name: Install jq
@@ -641,7 +659,7 @@ jobs:
641659
run: |
642660
FILE=/home/runner/work/.report.json
643661
. $CONDA/etc/profile.d/conda.sh
644-
conda activate test_dpctl
662+
conda activate ${{ env.TEST_ENV_NAME }}
645663
cd /home/runner/work/array-api-tests
646664
${CONDA_PREFIX}/bin/python -c "import dpctl; dpctl.lsplatform()"
647665
export ARRAY_API_TESTS_MODULE=dpctl.tensor

0 commit comments

Comments
 (0)