Skip to content

Commit 473611f

Browse files
committed
Added tests configuration to run in GitHub automatically
1 parent d349528 commit 473611f

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

.github/workflows/tests.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Ncpi Tests
2+
3+
on:
4+
push:
5+
branches: [ main, master, ncpi-tests ]
6+
pull_request:
7+
branches: [ main, master, ncpi-tests ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Cache downloaded file
16+
uses: actions/cache@v4
17+
id: file-cache
18+
with:
19+
path: |
20+
tests/data/zenodo_test_files_LFP/zenodo_sim_files
21+
tests/data/zenodo_test_files_LFP/zenodo_emp_files
22+
key: ${{ runner.os }}-file-${{ hashFiles('requirements.txt') }}-v1
23+
24+
- name: Create directory for tests data (empty in repo)
25+
if: steps.file-cache.outputs.cache-hit != 'true'
26+
run: |
27+
mkdir -p tests/data/zenodo_test_files_LFP
28+
29+
- name: Download files (if they are not cached)
30+
if: steps.file-cache.outputs.cache-hit != 'true'
31+
run: |
32+
# Download partial zenodo simulation test data (~196 MB) and extract files
33+
wget -O tests/data/zenodo_test_files_LFP/zenodo_sim_test_files_LFP.7z https://zenodo.org/records/17427470/files/zenodo_sim_test_files_LFP.7z
34+
7z x tests/data/zenodo_test_files_LFP/zenodo_sim_test_files_LFP.7z -otests/data/zenodo_test_files_LFP/
35+
rm tests/data/zenodo_test_files_LFP/zenodo_sim_test_files_LFP.7z # Free space immediately
36+
37+
# Download partial zenodo empirical test data (~490 MB) and extract files
38+
wget -O tests/data/zenodo_test_files_LFP/zenodo_emp_test_files_LFP.7z https://zenodo.org/records/17427470/files/zenodo_emp_test_files_LFP.7z
39+
7z x tests/data/zenodo_test_files_LFP/zenodo_emp_test_files_LFP.7z -otests/data/zenodo_test_files_LFP/
40+
rm tests/data/zenodo_test_files_LFP/zenodo_emp_test_files_LFP.7z # Free space immediately
41+
42+
43+
- name: List test data files
44+
run: |
45+
ls -lhat tests/data/zenodo_test_files_LFP
46+
echo "Data size:"
47+
du -sh tests/data/zenodo_test_files_LFP # Check size
48+
49+
- name: Install dependencies
50+
run: |
51+
python -m pip install --upgrade pip setuptools
52+
pip install pytest
53+
pip install -r requirements.txt
54+
pip install . # overwrites ncpi python package. It installs the current version of this repository
55+
56+
- name: Run tests with pytest
57+
run: |
58+
pytest -v

pytest.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# pytest.ini or .pytest.ini
2+
[pytest]
3+
testpaths = tests
4+
python_files = test_*.py
5+
python_classes = Test*
6+
python_functions = test_*

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# requirements.txt
2+
ncpi
3+
# p7zip-full
4+
# wget
5+
# LFPykernels

tests/test_LFP/test_LFP.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@
4141
# Paths to zenodo empirical files
4242
zenodo_dir_emp= os.path.join(test_dir, "..", "data", "zenodo_test_files_LFP", "zenodo_emp_files") # Dir of GitHub testing downloaded files (set in tests.yml)
4343

44-
# ML model used to compute the predictions
45-
ML_model = 'MLPRegressor'
46-
47-
4844
def LFP_mean(method):
4945
"""
5046
Compute only certain data for testing and calculate the average

0 commit comments

Comments
 (0)