Skip to content

Commit 5895091

Browse files
committed
Add GH job with array API conformity run
1 parent 3d02b6b commit 5895091

File tree

1 file changed

+178
-2
lines changed

1 file changed

+178
-2
lines changed

.github/workflows/conda-package.yml

Lines changed: 178 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ jobs:
191191

192192
- name: Smoke test
193193
run: |
194-
python -c "import dpnp, dpctl; dpctl.lsplatform()"
194+
python -c "import dpctl; dpctl.lsplatform()"
195195
python -c "import dpnp; print(dpnp.__version__)"
196196
197197
- name: Run tests
@@ -332,7 +332,7 @@ jobs:
332332
333333
- name: Smoke test
334334
run: |
335-
python -c "import dpnp, dpctl; dpctl.lsplatform()"
335+
python -c "import dpctl; dpctl.lsplatform()"
336336
python -c "import dpnp; print(dpnp.__version__)"
337337
338338
- name: Run tests
@@ -414,6 +414,182 @@ jobs:
414414
env:
415415
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
416416

417+
array-api-conformity:
418+
name: Array API conformity
419+
420+
needs: build
421+
422+
permissions:
423+
# Needed to add a comment to a pull request's issue
424+
pull-requests: write
425+
426+
strategy:
427+
matrix:
428+
python: ['3.12']
429+
os: [ubuntu-22.04]
430+
431+
runs-on: ${{ matrix.os }}
432+
433+
defaults:
434+
run:
435+
shell: bash -el {0}
436+
437+
continue-on-error: true
438+
439+
env:
440+
array-api-tests-path: '${{ github.workspace }}/array-api-tests/'
441+
json-report-file: '${{ github.workspace }}/.report.json'
442+
channel-path: '${{ github.workspace }}/channel/'
443+
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
444+
extracted-pkg-path: '${{ github.workspace }}/pkg/'
445+
ver-json-path: '${{ github.workspace }}/version.json'
446+
447+
steps:
448+
- name: Download artifact
449+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
450+
with:
451+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
452+
path: ${{ env.pkg-path-in-channel }}
453+
454+
- name: Extract package archive
455+
run: |
456+
mkdir -p ${{ env.extracted-pkg-path }}
457+
tar -xvf ${{ env.pkg-path-in-channel }}/${{ env.PACKAGE_NAME }}-*.tar.bz2 -C ${{ env.extracted-pkg-path }}
458+
459+
- name: Setup miniconda
460+
id: setup_miniconda
461+
continue-on-error: true
462+
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
463+
with:
464+
miniforge-version: latest
465+
use-mamba: 'true'
466+
channels: conda-forge
467+
conda-remove-defaults: 'true'
468+
python-version: ${{ matrix.python }}
469+
activate-environment: 'array-api-conformity'
470+
471+
- name: ReSetup miniconda
472+
if: steps.setup_miniconda.outcome == 'failure'
473+
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
474+
with:
475+
miniforge-version: latest
476+
use-mamba: 'true'
477+
channels: conda-forge
478+
conda-remove-defaults: 'true'
479+
python-version: ${{ matrix.python }}
480+
activate-environment: 'array-api-conformity'
481+
482+
- name: Install conda-index
483+
id: install_conda_index
484+
continue-on-error: true
485+
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
486+
487+
- name: ReInstall conda-index
488+
if: steps.install_conda_index.outcome == 'failure'
489+
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
490+
491+
- name: Create conda channel
492+
run: |
493+
python -m conda_index ${{ env.channel-path }}
494+
495+
- name: Test conda channel
496+
run: |
497+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
498+
cat ${{ env.ver-json-path }}
499+
500+
- name: Get package version
501+
run: |
502+
export PACKAGE_VERSION=$(python -c "${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}")
503+
504+
echo PACKAGE_VERSION=${PACKAGE_VERSION}
505+
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
506+
507+
- name: Install dpnp
508+
id: install_dpnp
509+
continue-on-error: true
510+
run: |
511+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
512+
env:
513+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
514+
515+
- name: ReInstall dpnp
516+
if: steps.install_dpnp.outcome == 'failure'
517+
run: |
518+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
519+
env:
520+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
521+
522+
- name: List installed packages
523+
run: mamba list
524+
525+
- name: Smoke test
526+
run: |
527+
python -c "import dpctl; dpctl.lsplatform()"
528+
python -c "import dpnp; print(dpnp.__version__)"
529+
530+
- name: Clone array API tests repo
531+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
532+
with:
533+
repository: 'data-apis/array-api-tests'
534+
path: ${{ env.array-api-tests-path }}
535+
fetch-depth: 0
536+
submodules: 'recursive'
537+
538+
- name: Install array API test dependencies
539+
run: |
540+
pip install -r requirements.txt
541+
working-directory: ${{ env.array-api-tests-path }}
542+
543+
- name: Install jq
544+
run: |
545+
sudo apt-get install jq
546+
547+
- name: List installed packages
548+
run: mamba list
549+
550+
- name: Smoke test
551+
run: |
552+
python -c "import dpctl; dpctl.lsplatform()"
553+
python -c "import dpnp; print(dpnp.__version__)"
554+
555+
- name: Run array API conformance tests
556+
run: |
557+
python -m pytest --json-report --json-report-file=${{ env.json-report-file }} --disable-deadline array_api_tests
558+
env:
559+
ARRAY_API_TESTS_MODULE: 'dpnp'
560+
SYCL_CACHE_PERSISTENT: 1
561+
working-directory: ${{ env.array-api-tests-path }}
562+
563+
- name: Set Github environment variables
564+
run: |
565+
FILE=${{ env.json-report-file }}
566+
if test -f "$FILE"; then
567+
PASSED_TESTS=$(jq '.summary | .passed // 0' $FILE)
568+
FAILED_TESTS=$(jq '.summary | .failed // 0' $FILE)
569+
SKIPPED_TESTS=$(jq '.summary | .skipped // 0' $FILE)
570+
MESSAGE="Array API standard conformance tests for dpnp=$PACKAGE_VERSION ran successfully.
571+
Passed: $PASSED_TESTS
572+
Failed: $FAILED_TESTS
573+
Skipped: $SKIPPED_TESTS"
574+
echo "MESSAGE<<EOF" >> $GITHUB_ENV
575+
echo "$MESSAGE" >> $GITHUB_ENV
576+
echo "EOF" >> $GITHUB_ENV
577+
else
578+
echo "Array API standard conformance tests failed to run for dpnp=$PACKAGE_VERSION."
579+
exit 1
580+
fi
581+
582+
- name: Output API summary
583+
run: echo "::notice ${{ env.MESSAGE }}"
584+
585+
- name: Post result to PR
586+
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork }}
587+
uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2.8.2
588+
with:
589+
message: |
590+
${{ env.MESSAGE }}
591+
allow-repeats: false
592+
417593
cleanup_packages:
418594
name: Clean up anaconda packages
419595

0 commit comments

Comments
 (0)