Skip to content

Adding tests with pytest #46

Adding tests with pytest

Adding tests with pytest #46

Workflow file for this run

name: build
on:
release:
types: [published]
push:
branches: [master]
tags: ['**']
pull_request:
branches: [master]
jobs:
test-cuda:
defaults: {run: {shell: 'bash -el {0}'}}
runs-on: [self-hosted, python, cuda]
strategy:
matrix:
python-version: [3.11]
numpy-version: [1.25]
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0, submodules: recursive}
- id: reqs
name: set requirements
run: |
envname="${GITHUB_REPOSITORY##*/}-${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}"
echo "envname=$envname" >> $GITHUB_OUTPUT
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
activate-environment: ${{ steps.reqs.outputs.envname }}
run-post: false
- id: build
name: build
run: |
conda activate "${{ steps.reqs.outputs.envname }}"
which cmake || conda install -yq cmake
cmake -S . -B ./build_proj -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=ON -DCMAKE_INSTALL_PREFIX=./install
cmake --build ./build_proj --target install
pip install ./src/Python
- name: test
run: |
conda activate "${{ steps.reqs.outputs.envname }}"
PYTHONPATH=./src/Python python -m unittest discover ./test
- if: always()
name: Post Run conda-incubator/setup-miniconda@v3
shell: bash
run: |
sed -i '/${{ steps.reqs.outputs.envname }}/d' ~/.profile
source ~/.profile
conda env remove -n "${{ steps.reqs.outputs.envname }}"
test:
defaults: {run: {shell: 'bash -el {0}'}}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.10', 3.11]
numpy-version: [1.23, 1.26]
os: [ubuntu-latest, windows-latest]
include:
- python-version: 3.12 # needs numpy>=1.26
numpy-version: 1.26
os: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0, submodules: recursive}
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
- name: build
run: |
cmake -S . -B ./build_proj -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=OFF -DCMAKE_INSTALL_PREFIX=./install
cmake --build ./build_proj --target install
pip install ./src/Python
- name: test
run: PYTHONPATH=./src/Python python -m unittest discover ./test
conda:
defaults: {run: {shell: 'bash -el {0}'}}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11] # penultimate supported
numpy-version: [1.25]
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0, submodules: recursive}
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge
- name: conda build & test
working-directory: recipe
run: |
conda install boa
conda mambabuild . -c conda-forge -c ccpi --python=${{ matrix.python-version }} --numpy=${{ matrix.numpy-version }} --output-folder .
- name: Upload artifact of the conda package
uses: actions/upload-artifact@v4
with:
name: ccpi-regulariser-package
path: recipe/linux-64/ccpi-regulariser*
pass:
needs: [test-cuda, test, conda]
runs-on: ubuntu-latest
steps: [{run: echo success}]