-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
45 changed files
with
1,432 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ jobs: | |
- name: Install library | ||
run: poetry install --no-interaction --no-ansi | ||
|
||
|
||
#---------------------------------------------- | ||
# run python style checks | ||
#---------------------------------------------- | ||
|
@@ -113,6 +114,40 @@ jobs: | |
- name: Install dependencies | ||
if: steps.cached-poetry-dependencies.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/**') }}-${{ matrix.python-version }} | ||
|
||
- name: Inject container-test-template-cache into docker | ||
uses: reproducible-containers/[email protected] | ||
with: | ||
cache-source: container-test-template-cache | ||
- name: Build and push | ||
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:${{ matrix.python-version }} | ||
platforms: linux/amd64 | ||
build-args: | | ||
PYTHON_VERSION=${{ matrix.python-version }} | ||
#---------------------------------------------- | ||
# install your root project, if required | ||
#---------------------------------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from __future__ import annotations | ||
|
||
import jinja2.parser | ||
from colorama import Fore | ||
from jinja2.ext import Extension | ||
|
||
|
||
class ColoramaExtension(Extension): | ||
def __init__(self, env: jinja2.Environment): | ||
super().__init__(env) | ||
env.globals["Fore"] = Fore # type: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import json | ||
|
||
import jinja2 | ||
from jinja2.ext import Extension | ||
|
||
|
||
def toml_string(item: str): | ||
return json.dumps(item, ensure_ascii=False).replace("\x7F", "\\u007f") | ||
|
||
|
||
class TomlEncodeExtension(Extension): | ||
def __init__(self, env: jinja2.Environment): | ||
env.filters["toml_string"] = toml_string # type: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from __future__ import annotations | ||
|
||
import re | ||
import subprocess | ||
import sys | ||
from pathlib import Path | ||
|
||
import jinja2.parser | ||
from jinja2 import nodes | ||
from jinja2.ext import Extension | ||
|
||
|
||
class GitConfigExtension(Extension): | ||
tags = {"gitconfig"} # noqa: RUF012 | ||
_config: dict[str, str] | ||
|
||
def __init__(self, env: jinja2.Environment) -> None: | ||
self._config = {} | ||
|
||
try: | ||
config_list = subprocess.check_output( | ||
[executable(), "config", "-l"], stderr=subprocess.STDOUT | ||
).decode() | ||
|
||
m = re.findall("(?ms)^([^=]+)=(.*?)$", config_list) | ||
if m: | ||
for group in m: | ||
self._config[group[0]] = group[1] | ||
except (subprocess.CalledProcessError, OSError): | ||
pass | ||
|
||
def get(self, key: str, default: str | None = None) -> str | None: | ||
return self._config.get(key, default) | ||
|
||
def __getitem__(self, item: str) -> str: | ||
return self._config[item] | ||
|
||
def parse(self, parser: jinja2.parser.Parser): | ||
lineno = next(parser.stream).lineno | ||
|
||
node = parser.parse_expression() | ||
|
||
if not isinstance(node, nodes.Const): | ||
raise ValueError("Argument to `gitconfig` must be a string") | ||
call_method = self.call_method( | ||
"get", | ||
[node], | ||
lineno=lineno, | ||
) | ||
return nodes.Output([call_method], lineno=lineno) | ||
|
||
|
||
def executable() -> str: | ||
_executable = None | ||
|
||
if sys.platform == "win32": | ||
# Finding git via where.exe | ||
where = "%WINDIR%\\System32\\where.exe" | ||
paths = subprocess.check_output( | ||
[where, "git"], shell=True, encoding="oem" | ||
).split("\n") | ||
for path in paths: | ||
if not path: | ||
continue | ||
|
||
_path = Path(path.strip()) | ||
try: | ||
_path.relative_to(Path.cwd()) | ||
except ValueError: | ||
_executable = str(_path) | ||
|
||
break | ||
else: | ||
_executable = "git" | ||
|
||
if _executable is None: # type: ignore | ||
raise RuntimeError("Unable to find a valid git executable") | ||
|
||
return _executable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# {{app_full_name}} | ||
|
||
{{ app_description }} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.