Skip to content

Add versioneer

Add versioneer #171

Workflow file for this run

# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
name: Conda package
on:
push:
branches:
- main
pull_request:
env:
PACKAGE_NAME: dpbench
MODULE_NAME: dpbench
# There is a separate action that removes defaults.
CHANNELS: 'dppy/label/dev,conda-forge,intel,nodefaults'
VER_JSON_NAME: 'version.json'
VER_SCRIPT1: "import json; f = open('version.json', 'r'); j = json.load(f); f.close(); "
VER_SCRIPT2: "d = j['dpbench'][0]; print('='.join((d[s] for s in ('version', 'build'))))"
jobs:
build:
name: Build ['${{ matrix.os }}', python='${{ matrix.python }}']
strategy:
fail-fast: false
matrix:
python: ['3.9', '3.10', '3.11']
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}
continue-on-error: false
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout ${{ env.PACKAGE_NAME }} repo
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python }}
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: "build"
channels: ${{ env.CHANNELS }}
channel-priority: "disabled"
run-post: false
- name: Disable defautls
run: conda config --remove channels defaults
- name: Store conda paths as envs
shell: bash -l {0}
run: echo "CONDA_BLD=$CONDA_PREFIX/conda-bld/${{ runner.os == 'Linux' && 'linux' || 'win' }}-64/" | tr "\\" '/' >> $GITHUB_ENV
# boa is an extention to conda so we can use mamba resolver in conda build
- name: Install conda-build
run: mamba install boa
- name: Configure MSBuild
if: runner.os == 'Windows'
uses: microsoft/[email protected]
with:
vs-version: '14.35'
- name: Build conda package
run: conda mambabuild --no-test --python ${{ matrix.python }} conda-recipe
- name: Upload artifact
uses: actions/[email protected]
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.tar.bz2
test:
name: Test ['${{ matrix.os }}', python='${{ matrix.python }}']
needs: build
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}
strategy:
fail-fast: false
matrix:
python: ['3.9', '3.10']
os: [ubuntu-20.04, ubuntu-latest, windows-latest]
experimental: [false]
continue-on-error: ${{ matrix.experimental }}
steps:
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python }}
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: "build"
channels: ${{ env.CHANNELS }}
channel-priority: "disabled"
run-post: false
- name: Disable defautls
run: conda config --remove channels defaults
- name: Store conda paths as envs
shell: bash -l {0}
run: |
echo "CHANNEL_PATH=${{ github.workspace }}/channel/" | tr "\\" "/" >> $GITHUB_ENV
echo "EXTRACTED_PKG_PATH=${{ github.workspace }}/pkg/" | tr "\\" "/" >> $GITHUB_ENV
echo "VER_JSON_PATH=${{ github.workspace }}/version.json" | tr "\\" "/" >> $GITHUB_ENV
echo "PKG_PATH_IN_CHANNEL=${{ github.workspace }}/channel/${{ runner.os == 'Linux' && 'linux' || 'win' }}-64/" | tr "\\" "/" >> $GITHUB_ENV
- name: Download artifact
uses: actions/[email protected]
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.PKG_PATH_IN_CHANNEL }}
# We need --force-local because on windows path looks like C:/foo/bar
# and tar interprits semicolons as remote device.
- name: Extract package archive
shell: bash -l {0}
run: |
mkdir -p ${EXTRACTED_PKG_PATH}
tar -xvf ${PKG_PATH_IN_CHANNEL}${PACKAGE_NAME}-*.tar.bz2 -C ${EXTRACTED_PKG_PATH} --force-local
# Needed to be able to run conda index
- name: Install conda-build
run: mamba install conda-build
- name: Create conda channel
run: conda index ${{ env.CHANNEL_PATH }}
- name: Test conda channel
run: |
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.CHANNEL_PATH }} --override-channels --info --json > ${{ env.VER_JSON_PATH }}
cat ${{ env.VER_JSON_PATH }}
- name: Install dpbench
run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest opencl_rt python=${{ matrix.python }} -c ${{ env.CHANNEL_PATH }}
- name: List installed packages
run: conda list
- name: Smoke test
run: python -c "import dpnp, dpctl, dpbench; dpctl.lsplatform()"
- name: Run benchmakrs
run: |
dpbench -i numpy,numba_dpex_p,dpnp,numba_n,sycl run
dpbench report
upload_anaconda:
name: Upload dppy/label/dev ['${{ matrix.os }}', python='${{ matrix.python }}']
needs: [test]
strategy:
matrix:
python: ['3.9', '3.10']
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
continue-on-error: false
if: |
(github.repository == 'IntelPython/dpbench') &&
(github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
steps:
- name: Download artifact
uses: actions/[email protected]
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
- name: Setup miniconda
uses: conda-incubator/[email protected]
with:
auto-update-conda: true
python-version: ${{ matrix.python }}
miniconda-version: 'latest'
activate-environment: 'upload'
- name: Install anaconda-client
run: conda install anaconda-client
- name: Upload
run: anaconda --token ${{ env.ANACONDA_TOKEN }} upload --user dppy --label dev ${{ env.PACKAGE_NAME }}-*.tar.bz2
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}