File: tests.yml

package info (click to toggle)
compyle 0.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,080 kB
  • sloc: python: 12,898; makefile: 21
file content (82 lines) | stat: -rw-r--r-- 3,118 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        python-version: [3.11, 3.12]

    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash -l {0}

    steps:
      - uses: actions/checkout@v4
      - name: Set up Python ${{ matrix.python-version }}
        uses: conda-incubator/setup-miniconda@v3
        with:
          auto-update-conda: true
          python-version: ${{ matrix.python-version }}
          channels: defaults, conda-forge
          channel-priority: flexible
      - name: Install dependencies on Linux/MacOS
        run: |
          conda info
          conda install pocl pyopencl
          python -c 'import pyopencl as cl'
        if: ${{ runner.os != 'Windows' }}
      - name: Setup compyle config on MacOS to use openmp enabled clang from homebrew
        run: |
          brew install libomp
          mkdir -p ~/.compyle
          touch ~/.compyle/config.py
          echo "import os" >> ~/.compyle/config.py
          echo "os.environ['CC'] = '$(brew --prefix llvm@15)/bin/clang'" >> ~/.compyle/config.py
          echo "os.environ['CXX'] = '$(brew --prefix llvm@15)/bin/clang++'" >> ~/.compyle/config.py
          export CPPFLAGS="-I$(brew --prefix libomp)/include -I$(brew --prefix llvm@15)/include -Xclang -fopenmp"
          export LDFLAGS="-L$(brew --prefix libomp)/lib -L$(brew --prefix llvm@15)/lib -lomp"
          python -c "import os; OMP_CFLAGS=os.environ.get('CPPFLAGS').split(' '); print(f'{OMP_CFLAGS=}')" >> ~/.compyle/config.py
          python -c "import os; OMP_LINK=os.environ.get('LDFLAGS').split(' '); print(f'{OMP_LINK=}')" >> ~/.compyle/config.py
          cat ~/.compyle/config.py
        if: ${{ runner.os == 'macOS' }}
      - name: Install dependencies
        run: |
          conda info
          conda install 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 "month=$(date +'%m')" >> $GITHUB_OUTPUT
      - name: Deal with auto-generated code cache
        uses: actions/cache@v4
        with:
          path: |
            ~/.compyle
          key: ${{ runner.os }}-${{ steps.month.outputs.month }}-${{ matrix.python-version }}
      - 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@v4
        with:
          env_vars: ${{ matrix.os }}, ${{ matrix.python-version }}