clone

a personal forge on plain git: static pages, stacked-diff reviews, signed local ci, repo sites and releases

main
forge / test / container.sh
container.sh 1.6K
1#!/bin/sh2# Run the scenarios in the forge's container, as root, the way the forge3# runs there: Debian's sh (dash) and git, the image's Caddy, restic and4# litestream, a git user to hand restores to, and no curl. This checkout's5# code runs with the image's node_modules and DuckDB extensions, so only a6# change to the Dockerfile or the packages needs a new image.7#8# docker build -t forge:test . the image, once9# sh test/container.sh every scenario10# sh test/container.sh private release the ones whose names contain a word11# FORGE_TEST_IMAGE=forge:local sh test/container.sh another image12# FORGE_TEST_JOBS=1 sh test/container.sh one at a time13set -eu14if [ "${1:-}" = --inside ]; then15 shift16 # A copy of the checkout without its own node_modules (built for the17 # host, maybe not Linux) or anything the forge writes into it.18 w=$(mktemp -d /tmp/forge-src.XXXXXX)19 tar -C /opt/forge-src --exclude=./.git --exclude=./node_modules --exclude=./.duckdb --exclude=./.cache \20 --exclude=./_site --exclude=./demo/root --exclude=./demo/work -cf - . | tar -C "$w" -xf -21 ln -s /opt/forge/node_modules "$w/node_modules"22 ln -s /opt/forge/.duckdb "$w/.duckdb"23 exec sh "$w/test/run.sh" "$@"24fi25src=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)26image=${FORGE_TEST_IMAGE:-forge:test}27docker image inspect "$image" >/dev/null 2>&1 || { echo "no image $image: docker build -t $image $src" >&2; exit 1; }28exec docker run --rm ${FORGE_TEST_JOBS:+-e FORGE_TEST_JOBS} -v "$src:/opt/forge-src:ro" "$image" \29 sh /opt/forge-src/test/container.sh --inside "$@"