Skip to content

Commit 557768a

Browse files
committed
use action files filter
1 parent 211d3bf commit 557768a

File tree

4 files changed

+59
-24
lines changed

4 files changed

+59
-24
lines changed

.github/workflows/test_changed_files.yml

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,73 @@ on:
66
types: [synchronize, opened, reopened, ready_for_review]
77

88
jobs:
9-
set-matrix-job:
10-
name: Set jobs by changed Dockerfile
11-
runs-on: ubuntu-latest
9+
prepare-matrix-jobs:
10+
name: Prepare Build and Test Jobs
11+
runs-on: "ubuntu-latest"
1212
outputs:
13-
sorters: ${{ steps.set-matrix.outputs.sorters }}
13+
has_changed_files: ${{ steps.changed-files.outputs.any_changed }}
14+
sorters: ${{ steps.get-changed-sorters.outputs.sorters }}
1415
steps:
15-
- name: Checkount
16+
- name: Checkout
1617
uses: actions/checkout@v3
1718

1819
- name: Get changed files
1920
id: changed-files
2021
uses: tj-actions/changed-files@v23
22+
with:
23+
files: |
24+
*/Dockerfile
2125
22-
- name: Set jobs' matrix
23-
id: set-matrix
26+
- name: Prepare jobs matrix
27+
id: get-changed-sorters
2428
run: |
29+
# sorters variable will be a JSON-like array
2530
sorters="["
26-
for file in /Dockerfilesabc/Dockerfiles def/Dockerfiles huea; do
27-
if [[ "$file" == *"Dockerfile"* ]]; then
28-
# Removing /Dockerfile from string
29-
parsed=${file%*/Dockerfile*}
30-
31-
# Appending to sorters Array
32-
sorters+="\"${parsed}\", "
33-
fi
31+
32+
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
33+
# Removing /Dockerfile from string
34+
parsed=${file%*/Dockerfile*}
35+
36+
# Appending to final string
37+
sorters+="\"${parsed}\", "
3438
done
3539
sorters=${sorters%*, *}
3640
sorters+="]"
37-
echo $sorters
3841
42+
echo ${sorters}
3943
echo "::set-output name=sorters::${sorters}"
40-
test:
41-
needs: set-matrix-job
42-
runs-on: "ubuntu-latest"
44+
45+
build-and-test-image:
46+
name: build (${{ matrix.sorter }})
47+
if: needs.prepare-matrix-jobs.outputs.has_changed_files == 'true'
48+
needs: prepare-matrix-jobs
49+
runs-on: ${{ matrix.os }}
4350
strategy:
51+
fail-fast: false
4452
matrix:
45-
sorter: ${{ fromJSON(needs.set-matrix-job.outputs.matrix) }}
53+
# "macos-latest", "windows-latest"
54+
os: ["ubuntu-latest", ]
55+
sorter: ${{ fromJSON(needs.prepare-matrix-jobs.outputs.sorters) }}
4656
steps:
47-
- run: echo ${{ matrix.sorter }}
57+
- name: Checkout
58+
uses: actions/checkout@v3
59+
with:
60+
python-version: 3.8
61+
62+
- name: Build ${{ matrix.sorter }} Docker image
63+
run: |
64+
cd ${{ matrix.sorter }}
65+
bash build.sh
66+
cd ..
67+
68+
- uses: eWaterCycle/setup-singularity@v7
69+
with:
70+
singularity-version: 3.8.3
71+
72+
- name: Install dependencies & Test ${{ matrix.sorter }} image
73+
run: |
74+
if [[ ${{ matrix.sorter }} == 'tridesclous' ]]
75+
pip install tridesclous
76+
fi
77+
pip install -r requirements_test.txt
78+
pytest -sv tests/test_singularity_containers.py::test_${{ matrix.sorter }}

spykingcircus/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ RUN apt-get update && apt-get install -y packagekit-gtk3-module libcanberra-gtk-
1414
RUN pip install scikit-build
1515
RUN pip install cmake>=3.18
1616
RUN pip install spyking-circus==1.1.0
17+
18+
# test

tests/test_singularity_containers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ def run_kwargs(work_dir):
2121
test_recording, _ = se.toy_example(
2222
duration=30,
2323
seed=0,
24-
num_channels=32,
24+
num_channels=64,
2525
num_segments=1
2626
)
2727
test_recording = test_recording.save(name='toy')
2828
return dict(recording=test_recording, verbose=True, singularity_image=True)
2929

3030

31-
def test_spyking_circus(run_kwargs):
32-
sorting = ss.run_spykingcircus(output_folder="spyking_circus", **run_kwargs)
31+
def test_spykingcircus(run_kwargs):
32+
sorting = ss.run_spykingcircus(output_folder="spykingcircus", **run_kwargs)
3333
print(sorting)
3434

3535

tridesclous/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ RUN pip install h5py
2020
RUN pip install loky packaging
2121

2222
RUN pip install tridesclous==1.6.5
23+
24+
# test

0 commit comments

Comments
 (0)