Skip to content

Commit

Permalink
vhs: basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jan 6, 2025
1 parent 433c47f commit 16fe966
Show file tree
Hide file tree
Showing 66 changed files with 1,568 additions and 13 deletions.
54 changes: 52 additions & 2 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,55 @@
name: Doc

on:
pull_request:
push:
branches:
- 'master'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: shallow clone
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.0'

- name: build
run: |
cd example
go build
- uses: actions/upload-artifact@v4
with:
name: example
path: example/example
retention-days: 1

word:
needs: build
uses: ./.github/workflows/vhs-template.yml
with:
topic: word

nospace:
needs: build
uses: ./.github/workflows/vhs-template.yml
with:
topic: nospace

doubleQuote:
needs: build
uses: ./.github/workflows/vhs-template.yml
with:
topic: doubleQuote

doc:
needs:
- word
- nospace
- doubleQuote
runs-on: ubuntu-latest
container: ghcr.io/carapace-sh/carapace
steps:
Expand All @@ -17,6 +60,13 @@ jobs:
key: linkcheck
path: docs/book/linkcheck

- uses: actions/download-artifact@v4
with:
path: docs/src/development/vhs/

- name: Display structure of downloaded files
run: ls -R docs/src/development/vhs/

- name: "build docs"
run: |
mdbook build docs
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/vhs-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: vhs template

on:
workflow_call:
inputs:
topic:
required: true
type: string

jobs:
vhs:
runs-on: ubuntu-latest
continue-on-error: true
container: ghcr.io/carapace-sh/carapace
steps:
- name: shallow clone
uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: example
path: /usr/local/bin/

- run: chmod +x /usr/local/bin/example

- name: vhs
run: |
cd docs/src/development/vhs/${{ inputs.topic }}
ls *.tape | xargs -n1 vhs
- uses: actions/upload-artifact@v4
with:
name: ${{ inputs.topic }}
path: |
docs/src/development/vhs/${{ inputs.topic }}/
!docs/src/development/vhs/${{ inputs.topic }}/*.tape
retention-days: 1

- name: check
run: |
git diff
[ -z "$(git status --porcelain)" ] # clean workspace unless .ascii files changed
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ caraparse/caraparse
.cover
dist
docs/book
docs/src/development/vhs/*/out/*.gif
example/cmd/_test_files/*.txt
example/example
example-nonposix/example-nonposix
Expand Down
21 changes: 12 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ RUN wget -q https://github.com/PowerShell/PowerShell/releases/download/v7.4.6/p
&& rm powershell_7.4.6-1.deb_amd64.deb

RUN apt-get update \
&& apt-get install -y fish \
elvish \
ffmpeg \
expect \
shellcheck \
sudo \
tcsh \
xonsh \
zsh
&& apt-get install -y \
chromium \
elvish \
expect \
ffmpeg \
fish \
shellcheck \
sudo \
tcsh \
xonsh \
zsh

RUN pwsh -Command "Install-Module PSScriptAnalyzer -Scope AllUsers -Force"

Expand Down Expand Up @@ -122,4 +124,5 @@ COPY --chown=1000:1000 .dockerfile/home /home/carapace/
COPY .dockerfile/usr/local/bin/* /usr/local/bin/

ENV TERM xterm
ENV VHS_NO_SANDBOX 1
ENTRYPOINT [ "entrypoint.sh" ]
6 changes: 4 additions & 2 deletions docker-compose.yml → compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
build: &base
build: .
Expand Down Expand Up @@ -63,6 +61,10 @@ services:
working_dir: /carapace
command: fish -c "go test -v ./..."

vhs:
<<: *base
working_dir: /carapace/docs/src/development/vhs
command: bash -c "ls -d */ | xargs -I'{}' bash -c \"cd {};ls *.tape | xargs -n1 vhs\""

volumes:
go:
4 changes: 4 additions & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,7 @@
- [Zsh](./development/shells/zsh.md)
- [Testing](./development/testing.md)
- [Asciinema](./development/asciinema.md)
- [VHS](./development/vhs.md)
- [Word](./development/vhs/word.md)
- [Nospace](./development/vhs/nospace.md)
- [Double Quote](./development/vhs/doubleQuote.md)
1 change: 1 addition & 0 deletions docs/src/development/vhs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# VHS
15 changes: 15 additions & 0 deletions docs/src/development/vhs/bash.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Require example

Set Theme "Snazzy"
Set FontFamily "JetBrains Mono"
Set FontSize 30
Set Width 1400
Set Height 300
Set Padding 0

Set Shell "bash"

Hide
[email protected] "source <(example _carapace bash)" Enter
[email protected] "clear" Enter
Show
18 changes: 18 additions & 0 deletions docs/src/development/vhs/doubleQuote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Double Quote

- bash
![](./doubleQuote/out/doubleQuote.bash.gif)
- elvish
![](./doubleQuote/out/doubleQuote.elvish.gif)
- fish
![](./doubleQuote/out/doubleQuote.fish.gif)
- nushell
![](./doubleQuote/out/doubleQuote.nushell.gif)
- oil
![](./doubleQuote/out/doubleQuote.oil.gif)
- powershell
![](./doubleQuote/out/doubleQuote.powershell.gif)
- xonsh
![](./doubleQuote/out/doubleQuote.xonsh.gif)
- zsh
![](./doubleQuote/out/doubleQuote.zsh.gif)
8 changes: 8 additions & 0 deletions docs/src/development/vhs/doubleQuote/doubleQuote.bash.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Source ../bash.tape

Output out/doubleQuote.bash.gif
Output out/doubleQuote.bash.ascii

Type `example "ac"` Sleep 1 Tab@1

Sleep 2
8 changes: 8 additions & 0 deletions docs/src/development/vhs/doubleQuote/doubleQuote.elvish.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Source ../elvish.tape

Output out/doubleQuote.elvish.gif
Output out/doubleQuote.elvish.ascii

Type `example "ac"` Sleep 1 Tab@1

Sleep 2
8 changes: 8 additions & 0 deletions docs/src/development/vhs/doubleQuote/doubleQuote.fish.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Source ../fish.tape

Output out/doubleQuote.fish.gif
Output out/doubleQuote.fish.ascii

Type `example "ac"` Sleep 1 Tab@1

Sleep 2
8 changes: 8 additions & 0 deletions docs/src/development/vhs/doubleQuote/doubleQuote.nushell.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Source ../nushell.tape

Output out/doubleQuote.nushell.gif
Output out/doubleQuote.nushell.ascii

Type `example "ac"` Sleep 1 Tab@1

Sleep 2
8 changes: 8 additions & 0 deletions docs/src/development/vhs/doubleQuote/doubleQuote.oil.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Source ../oil.tape

Output out/doubleQuote.oil.gif
Output out/doubleQuote.oil.ascii

Type `example "ac"` Sleep 1 Tab@1

Sleep 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Source ../powershell.tape

Output out/doubleQuote.powershell.gif
Output out/doubleQuote.powershell.ascii

Type `example "ac"` Sleep 1 Tab@1

Sleep 2
8 changes: 8 additions & 0 deletions docs/src/development/vhs/doubleQuote/doubleQuote.xonsh.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Source ../xonsh.tape

Output out/doubleQuote.xonsh.gif
Output out/doubleQuote.xonsh.ascii

Type `example "ac"` Sleep 1 Tab@1

Sleep 2
8 changes: 8 additions & 0 deletions docs/src/development/vhs/doubleQuote/doubleQuote.zsh.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Source ../zsh.tape

Output out/doubleQuote.zsh.gif
Output out/doubleQuote.zsh.ascii

Type `example "ac"` Sleep 1 Tab@1

Sleep 2
40 changes: 40 additions & 0 deletions docs/src/development/vhs/doubleQuote/out/doubleQuote.bash.ascii
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
>






────────────────────────────────────────────────────────────────────────────────
> example "ac"






────────────────────────────────────────────────────────────────────────────────
> example "ac"






────────────────────────────────────────────────────────────────────────────────
> example action






────────────────────────────────────────────────────────────────────────────────
> example action






────────────────────────────────────────────────────────────────────────────────
40 changes: 40 additions & 0 deletions docs/src/development/vhs/doubleQuote/out/doubleQuote.elvish.ascii
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
>






────────────────────────────────────────────────────────────────────────────────
> example "ac"






────────────────────────────────────────────────────────────────────────────────
> example "ac"






────────────────────────────────────────────────────────────────────────────────
> example "action"
COMPLETING argument
action (action example)




────────────────────────────────────────────────────────────────────────────────
> example "action"
COMPLETING argument
action (action example)




────────────────────────────────────────────────────────────────────────────────
Loading

0 comments on commit 16fe966

Please sign in to comment.