-
Notifications
You must be signed in to change notification settings - Fork 9
129 lines (121 loc) · 4.28 KB
/
pytest.yaml
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: tests
on:
push:
pull_request:
types: [opened, reopened]
env:
# Increase this value to reset cache if environment.yml has not changed.
PY_CACHE_NUMBER: 2
PY_ENV: ccc_gene_expr
jobs:
ccc_pytest:
name: Python tests for CCC
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
fail-fast: false
matrix:
python-version: ["3.9", "3.10"]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest numpy scipy numba pandas==1.4.* scikit-learn==1.1.*
- name: Test CCC with pytest
env:
PYTHONPATH: libs/
run: |
pytest tests/test_coef.py tests/test_pytorch_core.py tests/test_scipy_stats.py tests/test_sklearn_metrics.py
pytest:
name: Python tests for analyses
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
fail-fast: false
matrix:
python-version: ["3.9"]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Cache conda
id: cache
uses: actions/cache@v3
with:
path: "${{ env.PY_ENV }}.tar.gz"
key: ${{ runner.os }}-${{ env.PY_CACHE_NUMBER }}-${{ hashFiles('environment/environment.yml', 'environment/scripts/install_r_packages.r', 'environment/scripts/install_other_packages.sh') }}
- name: Setup Miniconda
if: steps.cache.outputs.cache-hit != 'true'
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ${{ env.PY_ENV }}
environment-file: environment/environment.yml
auto-activate-base: false
miniforge-variant: Mambaforge
miniforge-version: 'latest'
use-mamba: true
- name: Install other packages and Conda-Pack environment
if: steps.cache.outputs.cache-hit != 'true'
shell: bash -l {0}
run: |
# other packages (R packages mainly)
bash environment/scripts/install_other_packages.sh
# install conda-pack, and pack environment
conda install --yes -c conda-forge conda-pack coverage
conda pack -f -n ${{ env.PY_ENV }} -o "${{ env.PY_ENV }}.tar.gz"
- name: Unpack environment
shell: bash -l {0}
run: |
mkdir -p "${{ env.PY_ENV }}"
tar -xzf "${{ env.PY_ENV }}.tar.gz" -C "${{ env.PY_ENV }}"
- name: Setup data and run pytest (Windows systems)
if: runner.os == 'Windows'
env:
PYTHONPATH: libs/
shell: cmd
run: |
echo on
cd ${{ env.PY_ENV }}
call .\Scripts\activate.bat
.\Scripts\conda-unpack.exe
cd ..
set R_HOME=%CONDA_PREFIX%\Lib\R
python environment\scripts\setup_data.py --mode testing
pytest -v -rs tests
- name: Setup data and run pytest (non-Windows systems)
if: runner.os != 'Windows'
shell: bash
env:
PYTHONPATH: libs/
run: |
source ${{ env.PY_ENV }}/bin/activate
conda-unpack
python environment/scripts/setup_data.py --mode testing
if [ "$RUNNER_OS" == "Linux" ]; then
# for linux/ubuntu, run the tests once: with numba jit activated
# (which is the expected implementation) and with the jit
# deactivated (otherwise coverage does not work).
# numba jit activated
pytest -v -rs tests
# numba jit deactivated + code coverage
export NUMBA_DISABLE_JIT=1
coverage run --source=libs/ -m pytest -v -rs tests
coverage xml -o coverage.xml
else
pytest -v -rs tests
fi
- name: Codecov upload
if: runner.os == 'Linux'
uses: codecov/codecov-action@v2
with:
files: ./coverage.xml
name: codecov-${{ matrix.os }}-python${{ matrix.python-version }}
fail_ci_if_error: true
verbose: true