Skip to content
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

Overhaul snakebids create #336

Merged
merged 8 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
56 changes: 56 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,33 @@ jobs:
if: steps.setup-python.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --no-ansi

# Build docker container needed for test
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Template Testing Containers
uses: actions/cache@v3
with:
path: container-test-template-cache
key: ${{ runner.os }}-test-template-cache-${{ hashFiles('containers/test-template/**') }}-${{ steps.setup-python.outputs.python-version }}
- name: Inject container-test-template-cache into docker
uses: reproducible-containers/[email protected]
with:
cache-source: container-test-template-cache
- name: Build Docker container for cache
uses: docker/build-push-action@v5
with:
context: containers/test-template
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
load: false
tags: snakebids/test-template:${{ steps.setup-python.outputs.python-version }}
platforms: linux/amd64
build-args: |
PYTHON_VERSION=${{ steps.setup-python.outputs.python-version }}

test:
runs-on: ubuntu-latest
needs: [ 'build-cache-env' ]
Expand Down Expand Up @@ -153,6 +180,35 @@ jobs:
- name: Install dependencies
if: steps.setup-python.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --no-ansi


# Build docker container needed for test
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Template Testing Containers
uses: actions/cache@v3
with:
path: container-test-template-cache
key: ${{ runner.os }}-test-template-cache-${{ hashFiles('containers/test-template/**') }}-${{ steps.setup-python.outputs.python-version }}
- name: Inject container-test-template-cache into docker
uses: reproducible-containers/[email protected]
with:
cache-source: container-test-template-cache
- name: Build Docker container for cache
uses: docker/build-push-action@v5
with:
context: containers/test-template
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
load: true
tags: snakebids/test-template:${{ steps.setup-python.outputs.python-version }}
platforms: linux/amd64
build-args: |
PYTHON_VERSION=${{ steps.setup-python.outputs.python-version }}

- name: Install library
run: poetry install --no-interaction --no-ansi

Expand Down
21 changes: 21 additions & 0 deletions containers/test-template/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION}-slim

# Install and uninstall snakebids to cache it and it's dependences
RUN apt-get update && apt-get install -y gcc && \
rm -rf /var/lib/apt/lists/* && \
python -m pip install pipx && \
pipx install poetry && \
pipx install hatch && \
pipx install pdm && \
mkdir prebuild && \
cd prebuild && \
pip wheel snakebids && \
cd .. && \
rm -rf prebuild

COPY ./test-template.sh /run/test-template.sh
ENV PATH="/root/.local/bin:$PATH"

WORKDIR /work
ENTRYPOINT [ "/run/test-template.sh" ]
32 changes: 32 additions & 0 deletions containers/test-template/test-template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

set -eu

method="$1"
script_name="$2"

cp -r /app/* /work
script="'${script_name}' tests/data tests/result participant -c1 --skip-bids-validation"
case "$method" in
"setuptools" )
python -m venv .venv
.venv/bin/python -m pip install .
PATH=".venv/bin:$PATH" eval "$script"
;;
"poetry" )
poetry install
eval "poetry run $script"
;;
"hatch" )
hatch env create
eval "hatch env run -- $script"
;;
"pdm" )
pdm install
eval "pdm run $script"
;;
* )
>&2 echo "Invalid method"
exit 1
;;
esac
Loading