Skip to content

Commit

Permalink
Overhaul of snakebids create
Browse files Browse the repository at this point in the history
Use copier instead of cookiecutter
- Better feature set
- Better documentation
- More polished (e.g. typed codebase)

Change starting workflow into a "welcome" workflow
- Pregenerated empty data file based on the tutorial
- workflow reads in the datafiles using generate_inputs and prints a
  welcome message

Allow choice of build systems. App will be immediately installable and
publishable

End-to-end testing of app creation, dependency installation, and initial
run

Validation of email address and app_name. Make app_name and version
mandatory fields
  • Loading branch information
pvandyken committed Oct 18, 2023
1 parent c327507 commit 5d3fdc7
Show file tree
Hide file tree
Showing 44 changed files with 1,564 additions and 586 deletions.
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

0 comments on commit 5d3fdc7

Please sign in to comment.