Skip to content

Tests and CI/CD #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/build_test_push_images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Build, Test and Push changed Dockerfiles

on:
push:
branches:
- main
pull_request:
branches: [main]
types: [synchronize, opened, reopened, ready_for_review]

jobs:
prepare-matrix-jobs:
name: Prepare Build and Test Jobs
runs-on: "ubuntu-latest"
outputs:
has_changed_files: ${{ steps.changed-files.outputs.any_changed }}
sorters: ${{ steps.get-changed-sorters.outputs.sorters }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v23
with:
files: |
*/Dockerfile
files_ignore: |
hdsort-compiled/*
ironclust-compiled/*
kilosort_no_license/*
kilosort_with_license/*
spikeinterface-jupyterlab/*
tests/*
waveclus-compiled/*

- name: Prepare jobs matrix
id: get-changed-sorters
run: |
# sorters variable will be a JSON-like array
sorters="["

for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
# Removing /Dockerfile from string
parsed=${file%*/Dockerfile*}

# Appending to final string
sorters+="\"${parsed}\", "
done
sorters=${sorters%*, *}
sorters+="]"

echo ${sorters}
echo "::set-output name=sorters::${sorters}"

build-and-test-image:
name: Build and Test (${{ matrix.sorter }})
if: needs.prepare-matrix-jobs.outputs.has_changed_files == 'true'
needs: prepare-matrix-jobs
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# "macos-latest", "windows-latest"
os: ["ubuntu-latest", ]
sorter: ${{ fromJSON(needs.prepare-matrix-jobs.outputs.sorters) }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
python-version: 3.8

- name: Build ${{ matrix.sorter }} Docker image
run: |
cd ${{ matrix.sorter }}
bash build.sh

- uses: eWaterCycle/setup-singularity@v7
with:
singularity-version: 3.8.3

- name: Install dependencies & Test ${{ matrix.sorter }} image
run: |
if [[ ${{ matrix.sorter }} == 'tridesclous' ]]; then
pip install tridesclous
fi
pip install -r requirements_test.txt
pytest -sv tests/test_singularity_containers.py::test_${{ matrix.sorter }}

- name: Docker login & Push image
if: github.ref == 'refs/heads/main'
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
cd ${{ matrix.sorter }}
bash push.sh
1 change: 0 additions & 1 deletion .github/workflows/test_containers_singularity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ jobs:

- name: Run test singularity containers
run: |
pip install tridesclous
pytest -sv tests/test_singularity_containers.py