| 1 |
name: Tests |
| 2 |
|
| 3 |
on: |
| 4 |
pull_request: |
| 5 |
schedule: |
| 6 |
# Run Test at 0400 UTC on Saturday. |
| 7 |
- cron: '0 4 * * 6' |
| 8 |
# Run test at 0400 UTC on day 1 of every month to create auto-generated |
| 9 |
# code afresh and cache it. |
| 10 |
- cron: '0 4 1 * *' # Ref https://crontab.guru/#0_4_1_*_* |
| 11 |
|
| 12 |
jobs: |
| 13 |
tests: |
| 14 |
strategy: |
| 15 |
fail-fast: false |
| 16 |
matrix: |
| 17 |
os: [ubuntu-latest, macos-latest, windows-latest] |
| 18 |
python-version: [3.11, 3.12] |
| 19 |
|
| 20 |
runs-on: ${{ matrix.os }} |
| 21 |
defaults: |
| 22 |
run: |
| 23 |
shell: bash -l {0} |
| 24 |
|
| 25 |
steps: |
| 26 |
- uses: actions/checkout@v4 |
| 27 |
- name: Set up Python ${{ matrix.python-version }} |
| 28 |
uses: conda-incubator/setup-miniconda@v3 |
| 29 |
with: |
| 30 |
auto-update-conda: true |
| 31 |
python-version: ${{ matrix.python-version }} |
| 32 |
channels: defaults, conda-forge |
| 33 |
channel-priority: flexible |
| 34 |
- name: Install dependencies on Linux/MacOS |
| 35 |
run: | |
| 36 |
conda info |
| 37 |
conda install pocl pyopencl |
| 38 |
python -c 'import pyopencl as cl' |
| 39 |
if: ${{ runner.os != 'Windows' }} |
| 40 |
- name: Setup compyle config on MacOS to use openmp enabled clang from homebrew |
| 41 |
run: | |
| 42 |
brew install libomp |
| 43 |
mkdir -p ~/.compyle |
| 44 |
touch ~/.compyle/config.py |
| 45 |
echo "import os" >> ~/.compyle/config.py |
| 46 |
echo "os.environ['CC'] = '$(brew --prefix llvm@15)/bin/clang'" >> ~/.compyle/config.py |
| 47 |
echo "os.environ['CXX'] = '$(brew --prefix llvm@15)/bin/clang++'" >> ~/.compyle/config.py |
| 48 |
export CPPFLAGS="-I$(brew --prefix libomp)/include -I$(brew --prefix llvm@15)/include -Xclang -fopenmp" |
| 49 |
export LDFLAGS="-L$(brew --prefix libomp)/lib -L$(brew --prefix llvm@15)/lib -lomp" |
| 50 |
python -c "import os; OMP_CFLAGS=os.environ.get('CPPFLAGS').split(' '); print(f'{OMP_CFLAGS=}')" >> ~/.compyle/config.py |
| 51 |
python -c "import os; OMP_LINK=os.environ.get('LDFLAGS').split(' '); print(f'{OMP_LINK=}')" >> ~/.compyle/config.py |
| 52 |
cat ~/.compyle/config.py |
| 53 |
if: ${{ runner.os == 'macOS' }} |
| 54 |
- name: Install dependencies |
| 55 |
run: | |
| 56 |
conda info |
| 57 |
conda install numpy cython |
| 58 |
python -m pip install -r requirements.txt |
| 59 |
python -m pip install coverage codecov |
| 60 |
python -m pip install -e ".[dev]" |
| 61 |
# Cache auto-generated code. Cache key changes every month. |
| 62 |
# Thanks https://stackoverflow.com/a/60942437 |
| 63 |
- name: Get month to use as cache key. |
| 64 |
id: month |
| 65 |
run: echo "month=$(date +'%m')" >> $GITHUB_OUTPUT |
| 66 |
- name: Deal with auto-generated code cache |
| 67 |
uses: actions/cache@v4 |
| 68 |
with: |
| 69 |
path: | |
| 70 |
~/.compyle |
| 71 |
key: ${{ runner.os }}-${{ steps.month.outputs.month }}-${{ matrix.python-version }} |
| 72 |
- name: Run tests |
| 73 |
run: | |
| 74 |
coverage erase |
| 75 |
coverage run -m pytest -v |
| 76 |
- name: Report |
| 77 |
if: ${{ success() }} |
| 78 |
run: coverage report |
| 79 |
- name: Upload Coverage to Codecov |
| 80 |
uses: codecov/codecov-action@v4 |
| 81 |
with: |
| 82 |
env_vars: ${{ matrix.os }}, ${{ matrix.python-version }} |