diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6e10472 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +# only used for bat-test.dockerfile + +* +!/syntaxes/ +!/tests/docker/*regression.sh +!/tests/source diff --git a/tests/docker/bat-server.compose.yaml b/tests/docker/bat-server.compose.yaml deleted file mode 100644 index a15ef78..0000000 --- a/tests/docker/bat-server.compose.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# usage: better run the regression scripts in tests/ - -services: - bat-server: - build: - context: . - dockerfile: bat-server.dockerfile - container_name: bat-server - image: bat-server # name for the built image - volumes: - # source paths relative to tests/docker/ - - ../../syntaxes:/root/.config/bat/syntaxes:ro - - ../source:/tests/source:ro - - ../highlighted:/tests/highlighted - - ../theme:/tests/theme diff --git a/tests/docker/bat-server.dockerfile b/tests/docker/bat-server.dockerfile deleted file mode 100644 index 12ad08e..0000000 --- a/tests/docker/bat-server.dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# usage: through the docker-compose service - -FROM curlimages/curl:latest as fetch-pkg -LABEL keep=false -ARG BAT_VERSION=0.21.0 -RUN curl -LJ \ - https://github.com/sharkdp/bat/releases/download/v$BAT_VERSION/bat_${BAT_VERSION}_amd64.deb \ - --output /tmp/bat.deb - -FROM debian:bullseye-slim -COPY --from=fetch-pkg /tmp/bat.deb /tmp -RUN dpkg --install /tmp/bat.deb -ENV COLORTERM=truecolor -COPY run_*_regression.sh /tests/ -CMD sleep infinity diff --git a/tests/docker/bat-test.dockerfile b/tests/docker/bat-test.dockerfile new file mode 100644 index 0000000..19850a2 --- /dev/null +++ b/tests/docker/bat-test.dockerfile @@ -0,0 +1,18 @@ +# usage: through highlight_regression.sh and theme_regression.sh + +FROM curlimages/curl:latest AS fetch-pkg +LABEL keep=false +ARG BAT_VERSION=0.21.0 +RUN curl -LJ \ + https://github.com/sharkdp/bat/releases/download/v$BAT_VERSION/bat_${BAT_VERSION}_amd64.deb \ + --output /tmp/bat.deb + +FROM debian:bullseye-slim +COPY --from=fetch-pkg /tmp/bat.deb /tmp +RUN dpkg --install /tmp/bat.deb +ENV COLORTERM=truecolor +COPY ./tests/docker/*regression.sh /tests/ +COPY ./tests/source /tests/source +COPY ./syntaxes/cmd-help.sublime-syntax /root/.config/bat/syntaxes/ +RUN bat cache --build > /dev/null +ENTRYPOINT /tests/run_highlight_regression.sh diff --git a/tests/docker/run_highlight_regression.sh b/tests/docker/run_highlight_regression.sh old mode 100644 new mode 100755 index f547190..281e617 --- a/tests/docker/run_highlight_regression.sh +++ b/tests/docker/run_highlight_regression.sh @@ -4,10 +4,8 @@ set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" -bat cache --build > /dev/null - for source_path in source/* ; do - # this dir is only for theme_regression.sh + # this dir is only for run_theme_regression.sh [ "$source_path" = source/theme ] && continue filename=$(basename "$source_path") diff --git a/tests/docker/run_theme_regression.sh b/tests/docker/run_theme_regression.sh index 9a2d24d..9c81b61 100755 --- a/tests/docker/run_theme_regression.sh +++ b/tests/docker/run_theme_regression.sh @@ -4,8 +4,6 @@ set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" -bat cache --build > /dev/null - readarray -t themes <<< "$(bat --list-themes --color=never)" cmd_prefix="bat --no-config -fpl cmd-help source/theme/synthetic.txt" diff --git a/tests/highlight_regression.sh b/tests/highlight_regression.sh index 22cd636..2b9c45a 100755 --- a/tests/highlight_regression.sh +++ b/tests/highlight_regression.sh @@ -4,9 +4,10 @@ set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" -docker compose -f docker/bat-server.compose.yaml up -d +docker build --quiet -f docker/bat-test.dockerfile -t bat-test .. -docker exec bat-server bash /tests/run_highlight_regression.sh +volume="$PWD"/highlighted:/tests/highlighted +docker run -v "$volume" bat-test # have git tell the effective difference between the version of the syntax # in staging/HEAD and the one in working dir, for all highlighted samples diff --git a/tests/theme_regression.sh b/tests/theme_regression.sh index b1b11cd..ad75dd6 100755 --- a/tests/theme_regression.sh +++ b/tests/theme_regression.sh @@ -4,9 +4,12 @@ set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" -docker compose -f docker/bat-server.compose.yaml up -d +docker build --quiet -f docker/bat-test.dockerfile -t bat-test .. -docker exec bat-server bash /tests/run_theme_regression.sh +volume="$PWD"/theme:/tests/theme +docker run -v "$volume" \ + --entrypoint /tests/run_theme_regression.sh \ + bat-test # effective difference between HEAD/staging and working dir GIT_PAGER='LESS=R less' git diff -- theme/