Skip to content

Commit 5f2e951

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

File tree

1 file changed

+182
-0
lines changed

1 file changed

+182
-0
lines changed

.github/workflows/conda-package.yml

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

0 commit comments

Comments
 (0)