Tests #148
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
pull_request: | |
schedule: | |
# Run Test at 0400 UTC on Saturday. | |
- cron: '0 4 * * 6' | |
# Run test at 0400 UTC on day 1 of every month to create auto-generated | |
# code afresh and cache it. | |
- cron: '0 4 1 * *' # Ref https://crontab.guru/#0_4_1_*_* | |
jobs: | |
tests: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: [3.8, 3.9] | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
auto-update-conda: true | |
python-version: ${{ matrix.python-version }} | |
channels: conda-forge | |
- name: Install dependencies on Linux/MacOS | |
run: | | |
conda info | |
conda install -c conda-forge pocl pyopencl | |
python -c 'import pyopencl as cl' | |
if: ${{ runner.os != 'Windows' }} | |
- name: Install dependencies | |
run: | | |
conda info | |
conda install -c conda-forge numpy cython | |
python -m pip install -r requirements.txt | |
python -m pip install coverage codecov | |
python -m pip install -e ".[dev]" | |
# Cache auto-generated code. Cache key changes every month. | |
# Thanks https://stackoverflow.com/a/60942437 | |
- name: Get month to use as cache key. | |
id: month | |
run: echo "::set-output name=month::$(date +'%m')" | |
- name: Deal with auto-generated code cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.compyle | |
key: ${{ runner.os }}-py${{ matrix.python-version }}-${{ steps.month.outputs.month }} | |
- name: Run tests | |
run: | | |
coverage erase | |
coverage run -m pytest -v | |
- name: Report | |
if: ${{ success() }} | |
run: coverage report | |
- name: Upload Coverage to Codecov | |
uses: codecov/codecov-action@v1 | |
with: | |
env_vars: ${{ matrix.os }}, ${{ matrix.python-version }} |