Skip to content

Commit

Permalink
docs(screenshots): setup docker, makefile and tests to automate scree…
Browse files Browse the repository at this point in the history
…nshot

follows #342
fixes #339
  • Loading branch information
edouard-lopez committed Jan 23, 2024
1 parent ad66c8a commit f954f26
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 7 deletions.
22 changes: 22 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,27 @@ RUN echo 'Symlink dev files' \
&& ln -nfs "$(pwd)"/conf.d/*.fish ../conf.d/ \
&& ln -nfs "$(pwd)"/functions/*.fish ../functions/

FROM with-pure-installed as with-terminal-screenshot-installed
USER root
RUN apk add \
--no-cache \
chromium \
nss \
freetype \
harfbuzz \
ca-certificates \
ttf-freefont \
nodejs \
npm

# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

RUN npm install \
--global \
terminal-screenshot \
puppeteer
USER nemo

ENTRYPOINT ["fish", "-c"]
CMD ["fishtape tests/*.test.fish"]
Empty file.
25 changes: 18 additions & 7 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ test-pure-on-nix:
$(MAKE) dev-pure-on-nix CMD="${CMD}" TTY=


build-pure-doc:
docker build \
--file ./docker/doc.Dockerfile \
--tag=pure-doc \
--load \
./

serve-pure-doc:
docker run \
--name mkdocs \
Expand All @@ -97,11 +104,15 @@ serve-pure-doc:
--rm \
--publish 8000:8000 \
--volume=$$(pwd):/docs \
pure-doc
pure-doc

build-pure-doc:
docker build \
--file ./docker/doc.Dockerfile \
--tag=pure-doc \
--load \
./

.PHONY: build-pure-screenshot
build-pure-screenshot:
$(MAKE) build-pure-on FISH_VERSION=${FISH_VERSION} STAGE=with-terminal-screenshot-installed


.PHONY: run-pure-screenshot
run-pure-screenshot: CMD?=fishtape tests/*.test.fish
run-pure-screenshot:
$(MAKE) dev-pure-on FISH_VERSION=${FISH_VERSION} STAGE=with-terminal-screenshot-installed CMD="${CMD}"
12 changes: 12 additions & 0 deletions tests/fixtures/constants.fish
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,15 @@ end
function _print_filename --argument-names filename
echo (set_color cyan)$filename(set_color normal)
end

function screenshot \
--description "Take screenshot" \
--argument-names \
name

fish_prompt \
| terminal-screenshot \
--output ./docs/assets/screenshots/$name.png \
--background-color white \
--margin 5
end
67 changes: 67 additions & 0 deletions tests/screenshot.test.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
source (status dirname)/fixtures/constants.fish
@echo (_print_filename (status filename))

function before_each
_purge_configs
source ../conf.d/pure.fish
end

before_each
@test "screenshot `pure_enable_git false`" (
set --universal pure_enable_git false
screenshot "pure_enable_git=false"
) $status -eq $SUCCESS

before_each
@test "screenshot `pure_enable_git true `" (
set --universal pure_enable_git true
screenshot "pure_enable_git=true"
) $status -eq $SUCCESS

before_each
@test "screenshot `pure_enable_k8s false`" (
set --universal pure_enable_k8s false
screenshot "pure_enable_k8s=false"
) $status -eq $SUCCESS

before_each
@test "screenshot `pure_enable_k8s true `" (
set --universal pure_enable_k8s true
screenshot "pure_enable_k8s=true"
) $status -eq $SUCCESS

before_each
@test "screenshot `pure_enable_container_detection false`" (
set --universal pure_enable_container_detection false
screenshot "pure_enable_container_detection=false"
) $status -eq $SUCCESS

before_each
@test "screenshot `pure_enable_container_detection true `" (
set --universal pure_enable_container_detection true
screenshot "pure_enable_container_detection=true"
) $status -eq $SUCCESS

before_each
@test "screenshot `pure_enable_virtualenv false`" (
set --universal pure_enable_virtualenv false
screenshot "pure_enable_virtualenv=false"
) $status -eq $SUCCESS

before_each
@test "screenshot `pure_enable_virtualenv true `" (
set --universal pure_enable_virtualenv true
screenshot "pure_enable_virtualenv=true"
) $status -eq $SUCCESS

before_each
@test "screenshot `pure_enable_single_line_prompt false`" (
set --universal pure_enable_single_line_prompt false
screenshot "pure_enable_single_line_prompt=false"
) $status -eq $SUCCESS

before_each
@test "screenshot `pure_enable_single_line_prompt true `" (
set --universal pure_enable_single_line_prompt true
screenshot "pure_enable_single_line_prompt=true"
) $status -eq $SUCCESS

0 comments on commit f954f26

Please sign in to comment.