Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs/screenshot automation #345

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

- name: Prepare screenshot image
run: make build-pure-screenshot FISH_VERSION=3.6.1

- name: Take screenshot
run: make run-pure-screenshot FISH_VERSION=3.6.1 CMD='CI=true fishtape tests/screenshot.test.fish'

- name: Deploy docs
uses: mhausenblas/mkdocs-deploy-gh-pages@master
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.cache
docs/assets/screenshots/*.png
6 changes: 5 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ RUN apk add \
ca-certificates \
ttf-freefont \
nodejs \
npm
npm \
font-noto \
font-noto-symbols \
font-noto-emoji


# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
Expand Down
18 changes: 17 additions & 1 deletion docs/components/features-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,30 @@
set --universal pure_check_for_new_release false
```

=== "Enabled (with update)"

![screenshot pure_check_for_new_release=true,with-update](../assets/screenshots/pure_check_for_new_release=true,with-update.png)

=== "Enabled (no update)"

![screenshot pure_check_for_new_release=true,no-update](../assets/screenshots/pure_check_for_new_release=true,no-update.png)

### Container Detection (Docker)

| Option | Default | Description |
| :------------------------------------ | :------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`pure_enable_container_detection`** | `true` | `false`: Do not check _pure_ runs inside a container (e.g. `docker`, `podman`, `LXC`/`LXD`, etc.).<br/>:warning: Detection is a bit [tricky across OSes][container-detection]. |
| **`pure_symbol_container_prefix`** | | Prefix when being inside a container ([to customize][to-set]) |

[container-detection]: https://stackoverflow.com/q/23513045/802365
[container-detection]: <https://stackoverflow.com/q/23513045/802365>

=== "Enabled (inside a container)"

![screenshot pure_enable_container_detection=true,inside](../assets/screenshots/pure_enable_container_detection=true,inside.png)

=== "Enabled (outside a container)"

![screenshot pure_enable_container_detection=true,outside](../assets/screenshots/pure_enable_container_detection=true,outside.png)

### Current Working Directory

Expand Down
6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ usage:
build-pure-on: STAGE?=only-fish
build-pure-on:
docker build \
--quiet \
--file ./docker/Dockerfile \
--target ${STAGE} \
--build-arg FISH_VERSION=${FISH_VERSION} \
Expand Down Expand Up @@ -113,6 +112,7 @@ build-pure-screenshot:


.PHONY: run-pure-screenshot
run-pure-screenshot: CMD?=fishtape tests/*.test.fish
run-pure-screenshot: CMD?=fishtape tests/*.test.doc.fish
run-pure-screenshot:
$(MAKE) dev-pure-on FISH_VERSION=${FISH_VERSION} STAGE=with-terminal-screenshot-installed CMD="${CMD}"
rm --recursive --force ./docs/assets/screenshots/*.png
$(MAKE) dev-pure-on FISH_VERSION=${FISH_VERSION} STAGE=with-terminal-screenshot-installed CMD="CI=true ${CMD}"
67 changes: 33 additions & 34 deletions tests/screenshot.test.doc.fish
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
source (status dirname)/fixtures/constants.fish
source (status dirname)/mocks/spectra.fish

@echo (_print_filename (status filename))

function before_each
_purge_configs
source ../conf.d/pure.fish
source (status dirname)/../conf.d/pure.fish
_clean_all_mocks
end

function screenshot \
Expand All @@ -12,56 +15,52 @@ function screenshot \
name \
action

set --query action; or set action fish_prompt
set --query action[1]; or set action fish_prompt


$action \
| terminal-screenshot \
--output ./docs/assets/screenshots/$name.png \
--margin 5 \
--font-family "Noto Sans "
--font-family "Noto Sans Mono, Noto Sans Symbols, Noto Sans Emoji"
# --background-color white # some text are invisible with white background
end

function boolean_test \
--description "Take screenshot" \
--argument-names \
name \
setup_context \
value \
action
if set --query CI
before_each
@test "screenshot: pure_check_for_new_release=true,with-update" (
set --universal pure_check_for_new_release true
set --global pure_version 0.0.1
_mock_response curl '"tag_name": "v9.9.9",'

screenshot "pure_check_for_new_release=true,with-update" _pure_check_for_new_release

) $status -eq $SUCCESS

echo $value
echo $action
echo $setup_context
before_each
@test "screenshot `$name $value`" (
$setup_context
set --universal $name $value
screenshot "$name=$value" $action
@test "screenshot: pure_check_for_new_release=true,no-update" (
set --universal pure_check_for_new_release true
set --global pure_version 0.0.1
_mock_response curl '"tag_name": "v0.0.1",'

screenshot "pure_check_for_new_release=true,no-update" _pure_check_for_new_release
) $status -eq $SUCCESS
end


if set --query CI
function setup
set --universal pure_check_for_new_release true
set --universal pure_version 0.0.1
function curl
echo '"tag_name": "v0.0.1",'
end # mock
end
# boolean_test pure_check_for_new_release setup false _pure_check_for_new_release
before_each
@test "screenshot `pure_check_for_new_release true`" (
set --universal pure_check_for_new_release true
set --universal pure_version 0.0.1
function curl
echo '"tag_name": "v0.0.1",'
end # mock
@test "screenshot: pure_enable_container_detection=true,inside" (
set --universal pure_enable_container_detection true
set --universal pure_symbol_container_prefix "🐋"

screenshot "pure_check_for_new_release=true" _pure_check_for_new_release
screenshot "pure_enable_container_detection=true,inside"
) $status -eq $SUCCESS

before_each
@test "screenshot: pure_enable_container_detection=true,outside" (
set --universal pure_enable_container_detection true
_mock_exit_status _pure_is_inside_container $FAILURE

screenshot "pure_enable_container_detection=true,outside"
) $status -eq $SUCCESS


Expand Down