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

Add demo workflow #872

Open
wants to merge 69 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
e0d4b39
Add demo workflow
osterman Dec 19, 2024
75ae8d8
Add pull request trigger
osterman Dec 19, 2024
69cb6f0
install util-linux
osterman Dec 19, 2024
9e0777a
format
osterman Dec 19, 2024
9062468
format
osterman Dec 19, 2024
2600a6f
only commit when files changes
osterman Dec 19, 2024
2bbedb9
set committer
osterman Dec 23, 2024
8a2c86e
set committer
osterman Dec 23, 2024
63c62ca
set committer
osterman Dec 23, 2024
1e55e9d
set committer
osterman Dec 23, 2024
1fe7ffa
show status of files
osterman Dec 23, 2024
e838a8a
Rename Screengrabs to tmp
osterman Dec 23, 2024
a80687a
Rename tmp to screengrabs
osterman Dec 23, 2024
1df005f
Rename screengrabs to tmp
osterman Dec 23, 2024
806317c
Rename tmp to Screengrabs
osterman Dec 23, 2024
d27fceb
install to case sensitive path
osterman Dec 23, 2024
6b30d09
add new screengrabs
osterman Dec 23, 2024
1471ae2
simplify
osterman Dec 23, 2024
e77df1d
cannot import more than one level deep
osterman Dec 23, 2024
08673a8
use git ls
osterman Dec 23, 2024
a529cea
use git ls
osterman Dec 23, 2024
3031aa0
fix jq
osterman Dec 23, 2024
4f486b1
Add vhs step
osterman Dec 23, 2024
ef49fc9
Add vhs step
osterman Dec 23, 2024
09d0558
Add vhs step
osterman Dec 23, 2024
e0b4781
test install of atmos
osterman Dec 23, 2024
e1f5109
set path
osterman Dec 23, 2024
65608d2
set path
osterman Dec 23, 2024
c22cfb8
update
osterman Dec 23, 2024
62a9a70
update demo to add docs
osterman Dec 23, 2024
957aad4
update demo to add docs
osterman Dec 23, 2024
3e92700
increase ram
osterman Dec 23, 2024
97ff562
reduce frame rate
osterman Dec 23, 2024
6f1ce5b
reduce framerate
osterman Dec 24, 2024
4d84db3
install missing dep
osterman Dec 24, 2024
f9d23b3
strip out text
osterman Dec 24, 2024
6cafabf
add bat
osterman Dec 24, 2024
df2782a
add bat
osterman Dec 24, 2024
07390f8
Merge branch 'main' into regen-screengrabs
osterman Dec 24, 2024
cb688d9
symlink bat
osterman Dec 24, 2024
bddcb50
debug hanging vhs
osterman Dec 24, 2024
513c8e2
debug hanging screengrabs
osterman Dec 24, 2024
6c63877
debug broken tapes
osterman Dec 25, 2024
81eb5ee
debug broken tapes
osterman Dec 25, 2024
aa6599d
debug vhs
osterman Dec 25, 2024
2047d8e
debug vhs
osterman Dec 25, 2024
d859b4b
debug vhs
osterman Dec 25, 2024
f161810
debug vhs
osterman Dec 25, 2024
3d15df5
debug vhs
osterman Dec 25, 2024
b868732
debug vhs
osterman Dec 25, 2024
880c3e0
debug vhs
osterman Dec 25, 2024
a1e2006
debug vhs
osterman Dec 25, 2024
3195b0a
debug vhs
osterman Dec 25, 2024
73a8c1b
debug vhs
osterman Dec 25, 2024
67e5fff
debug vhs
osterman Dec 25, 2024
5793749
debug vhs
osterman Dec 25, 2024
1339e56
debug vhs
osterman Dec 25, 2024
0ab6e38
debug vhs
osterman Dec 25, 2024
3a0dccd
debug vhs
osterman Dec 25, 2024
dedf76c
debug vhs
osterman Dec 25, 2024
ce2bff7
debug vhs
osterman Dec 25, 2024
bd5cafd
debug vhs
osterman Dec 25, 2024
1856da7
debug vhs
osterman Dec 26, 2024
33956c4
switch vhs strategy and add audio
osterman Dec 26, 2024
e7c8db4
fix truncation
osterman Dec 26, 2024
d9245a4
move assets to cloudposse-corp
osterman Dec 31, 2024
dc6a905
move assets to cloudposse-corp
osterman Dec 31, 2024
f285b78
use github app
osterman Dec 31, 2024
1dfde36
use github app
osterman Dec 31, 2024
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
168 changes: 168 additions & 0 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: Demo

on:
workflow_dispatch:
pull_request:
types: [labeled, opened, synchronize]
paths:
- ".github/workflows/demo.yml"
osterman marked this conversation as resolved.
Show resolved Hide resolved

env:
TERM: "xterm-256color"
COLORTERM: "truecolor"
LANG: "en_US.UTF-8"
ATMOS_LOGS_LEVEL: "Info"
TERRAFORM_VERSION: "1.9.7"

jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get Atmos version
id: get-version
run: |
VERSION=$(curl -s https://api.github.com/repos/cloudposse/atmos/releases/latest | jq -r .tag_name)
echo "version=$VERSION" >> $GITHUB_OUTPUT
osterman marked this conversation as resolved.
Show resolved Hide resolved

outputs:
version: ${{ steps.get-version.outputs.version }}

screengrabs:
needs: [prepare]
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y aha util-linux make jq bat
sudo ln -s /usr/bin/batcat /usr/bin/bat
Comment on lines +37 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling to package installation.

The dependency installation step should verify that all required packages are installed successfully.

 run: |
-  sudo apt-get update
-  sudo apt-get install -y aha util-linux make jq bat
-  sudo ln -s /usr/bin/batcat /usr/bin/bat
+  if ! sudo apt-get update; then
+    echo "Failed to update package list"
+    exit 1
+  fi
+  if ! sudo apt-get install -y aha util-linux make jq bat; then
+    echo "Failed to install dependencies"
+    exit 1
+  fi
+  if ! sudo ln -sf /usr/bin/batcat /usr/bin/bat; then
+    echo "Failed to create bat symlink"
+    exit 1
+  fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: |
sudo apt-get update
sudo apt-get install -y aha util-linux make jq bat
sudo ln -s /usr/bin/batcat /usr/bin/bat
run: |
if ! sudo apt-get update; then
echo "Failed to update package list"
exit 1
fi
if ! sudo apt-get install -y aha util-linux make jq bat; then
echo "Failed to install dependencies"
exit 1
fi
if ! sudo ln -sf /usr/bin/batcat /usr/bin/bat; then
echo "Failed to create bat symlink"
exit 1
fi


- name: Checkout repository
uses: actions/checkout@v4

- name: Install Atmos
uses: jaxxstorm/[email protected]
with:
repo: cloudposse/atmos
tag: ${{ needs.prepare.outputs.version }}
chmod: 0755
extension-matching: disable
rename-to: atmos

- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false

- name: Run make build-all install
run: |
make -C demo/screengrabs build-all install
git add -A
git status

- name: Create or update PR
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: "chore/update-build-screengrabs-for-${{ needs.prepare.outputs.version }}"
title: "Update screengrabs for ${{ needs.prepare.outputs.version }}"
delete-branch: true
sign-commits: true
commit-message: |
chore: update screengrabs for ${{ needs.prepare.outputs.version }}
body: |
This PR updates the screengrabs for Atmos version ${{ needs.prepare.outputs.version }}.
base: main
labels: "no-release"

vhs:
needs: [prepare]
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@v4

- name: Checkout cloudposse-corp/assets
uses: actions/checkout@v4
with:
repository: cloudposse-corp/assets
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install audio track
run: |
cp assets/artlist/background-1.mp3 demo/recordings

- name: Set Swap Space
uses: pierotofy/set-swap-space@0404882bc4666c0ff2f6fd8b3d32af69a730183c
with:
swap-size-gb: 15
Comment on lines +107 to +110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Pin the set-swap-space action to a specific version.

Using a commit SHA for the action version is not recommended. Use a proper version tag instead.

-  uses: pierotofy/set-swap-space@0404882bc4666c0ff2f6fd8b3d32af69a730183c
+  uses: pierotofy/[email protected]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Set Swap Space
uses: pierotofy/set-swap-space@0404882bc4666c0ff2f6fd8b3d32af69a730183c
with:
swap-size-gb: 15
- name: Set Swap Space
uses: pierotofy/set-swap-space@v1.0
with:
swap-size-gb: 15


- name: Install Atmos
uses: jaxxstorm/[email protected]
with:
repo: cloudposse/atmos
tag: ${{ needs.prepare.outputs.version }}
chmod: 0755
extension-matching: disable
rename-to: atmos

- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false

- name: Test Atmos
run: |
which atmos
atmos version
atmos --help

osterman marked this conversation as resolved.
Show resolved Hide resolved
- name: Prepare variables
id: vars
run: |
VERSION="${{ needs.prepare.outputs.version }}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "job_name=${JOB_NAME}" >> $GITHUB_OUTPUT
echo "branch_name=chore/update-${JOB_NAME}-for-${VERSION}" >> $GITHUB_OUTPUT

- name: Setup VHS
uses: charmbracelet/vhs-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
install-fonts: true

- name: Record screencast
run: |
demo/recordings/build.sh
mv demo/recordings/gif/atmos.gif docs/demo.gif
Comment on lines +146 to +149
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling to screencast recording.

The recording step needs proper error handling and validation.

 run: |
-  demo/recordings/build.sh
-  mv demo/recordings/gif/atmos.gif docs/demo.gif
+  if ! demo/recordings/build.sh; then
+    echo "Failed to build screencast"
+    exit 1
+  fi
+  if ! mv demo/recordings/gif/atmos.gif docs/demo.gif; then
+    echo "Failed to move demo gif"
+    exit 1
+  fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Record screencast
run: |
demo/recordings/build.sh
mv demo/recordings/gif/atmos.gif docs/demo.gif
- name: Record screencast
run: |
if ! demo/recordings/build.sh; then
echo "Failed to build screencast"
exit 1
fi
if ! mv demo/recordings/gif/atmos.gif docs/demo.gif; then
echo "Failed to move demo gif"
exit 1
fi


- name: Create or update PR
uses: peter-evans/create-pull-request@v7
id: auto-commit
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.vars.outputs.branch_name }}
sign-commits: true
commit-message: |
chore: update ${{ steps.vars.outputs.job_name }} for ${{ steps.vars.outputs.version }}
title: Update ${{ steps.vars.outputs.job_name }} for ${{ steps.vars.outputs.version }}
body: |
This PR updates the demo gif for ${{ steps.vars.outputs.job_name }} with Atmos version ${{ steps.vars.outputs.version }}.
base: main
labels: no-release

- name: Add Image to Job Summary
if: steps.auto-commit.outputs.pull-request-operation == 'created' || steps.auto-commit.outputs.pull-request-operation == 'updated'
run: |
echo "## Demo GIF" >> $GITHUB_STEP_SUMMARY
echo "![Demo GIF](https://github.com/${{ github.repository }}/blob/${{ steps.auto-commit.outputs.pull-request-head-sha }}/docs/demo.gif?raw=true)" >> $GITHUB_STEP_SUMMARY
Comment on lines +168 to +170
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add proper quoting to GitHub step summary commands.

The GITHUB_STEP_SUMMARY environment variable needs proper quoting.

-    echo "## Demo GIF" >> $GITHUB_STEP_SUMMARY
-    echo "![Demo GIF](https://github.com/${{ github.repository }}/blob/${{ steps.auto-commit.outputs.pull-request-head-sha }}/docs/demo.gif?raw=true)" >> $GITHUB_STEP_SUMMARY
+    {
+      echo "## Demo GIF"
+      echo "![Demo GIF](https://github.com/${{ github.repository }}/blob/${{ steps.auto-commit.outputs.pull-request-head-sha }}/docs/demo.gif?raw=true)"
+    } >> "$GITHUB_STEP_SUMMARY"

-    echo "No changes to demo" >> $GITHUB_STEP_SUMMARY
+    echo "No changes to demo" >> "$GITHUB_STEP_SUMMARY"

Also applies to: 156-157

🧰 Tools
🪛 actionlint (1.7.4)

150-150: shellcheck reported issue in this script: SC2086:info:1:23: Double quote to prevent globbing and word splitting

(shellcheck)


150-150: shellcheck reported issue in this script: SC2086:info:2:151: Double quote to prevent globbing and word splitting

(shellcheck)


echo "## Demo Video" >> $GITHUB_STEP_SUMMARY
echo "https://github.com/${{ github.repository }}/blob/${{ steps.auto-commit.outputs.pull-request-head-sha }}/demo/recordings/mp4/atmos-with-audio.mp4?raw=true" >> $GITHUB_STEP_SUMMARY

- name: No changes
if: steps.auto-commit.outputs.pull-request-operation == 'none' || steps.auto-commit.outputs.pull-request-operation == 'closed'
run: |
echo "No changes to demo" >> $GITHUB_STEP_SUMMARY
102 changes: 0 additions & 102 deletions .github/workflows/vhs.yaml

This file was deleted.

31 changes: 31 additions & 0 deletions demo/defaults.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# VHS Defaults for Recordings and Screenshots

#Set Theme "Monokai Vivid"

# It's not possible to combine named themes, with explicitly defined themes
Set Theme { "name": "Monokai Vivid", "black": "#121212", "red": "#fa2934", "green": "#98e123", "yellow": "#fff30a", "blue": "#0443ff", "magenta": "#f800f8", "cyan": "#01b6ed", "white": "#ffffff", "brightBlack": "#838383", "brightRed": "#f6669d", "brightGreen": "#b1e05f", "brightYellow": "#fff26d", "brightBlue": "#0443ff", "brightMagenta": "#f200f6", "brightCyan": "#51ceff", "brightWhite": "#ffffff", "background": "#121212", "foreground": "#f9f9f9", "cursor": "#b3b0d6", "selection": "#ffffff"}

Set FontFamily "FiraCode Nerd Font"
#Set FontFamily "Hack Nerd Font"
Set FontSize 14

Set TypingSpeed 20ms

Set WindowBar Colorful

Set BorderRadius 8

Set Margin 0

Set Padding 10

# !! WARNING !!
# Large aspect ratios require more memory to process (and a factor of the framerate)
# Free-tier GitHub Action runners do not have sufficient memory to process long recordings
# at a high framerate before crashing. Therefore, for automation purposes we need to keep these small.

# Use standard aspect ratios
Set Width 1280
Set Height 720

Set Shell "bash"
1 change: 1 addition & 0 deletions demo/recordings/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
background.mp3
90 changes: 90 additions & 0 deletions demo/recordings/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env bash
set -euo pipefail

# ---------------------------------------------------------------------
# build.sh
# Executes VHS from the root of the git repository
# Converts tapes/*.tape to mp4/*.mp4, processes scenes, and generates gifs
# ---------------------------------------------------------------------

# Resolve absolute paths for key directories
REPO_ROOT="$(git rev-parse --show-toplevel)"
TAPES_DIR="$REPO_ROOT/demo/recordings/tapes"
SCENES_DIR="$REPO_ROOT/demo/recordings/scenes"
MP4_OUTDIR="$REPO_ROOT/demo/recordings/mp4"
GIF_OUTDIR="$REPO_ROOT/demo/recordings/gif"
AUDIO_FILE="$REPO_ROOT/demo/recordings/background.mp3"
Comment on lines +11 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Handle missing dependencies gracefully.

You rely on git, vhs, and ffmpeg. Consider adding checks to confirm these tools are installed, providing clearer error messaging if missing.


# Handle "clean" argument
if [[ "${1:-}" == "clean" ]]; then
echo ">> Cleaning up generated files..."
rm -rf "$MP4_OUTDIR" "$GIF_OUTDIR"
exit 0
fi

# Ensure output directories exist
echo ">> Ensuring $MP4_OUTDIR and $GIF_OUTDIR exist"
mkdir -p "$MP4_OUTDIR" "$GIF_OUTDIR"

# 1) Convert each tapes/*.tape => mp4/<basename>.mp4
echo ">> Step 1: Converting $TAPES_DIR/*.tape to $MP4_OUTDIR/*.mp4 via VHS"
shopt -s nullglob
TAPEFILES=( "$TAPES_DIR"/*.tape )
if [[ ${#TAPEFILES[@]} -eq 0 ]]; then
echo "No .tape files found in $TAPES_DIR. Exiting."
exit 1
fi

for tape in "${TAPEFILES[@]}"; do
base="$(basename "$tape" .tape)"
echo " Processing $tape -> $MP4_OUTDIR/$base.mp4"
(cd "$REPO_ROOT" && vhs "$tape" --output "$MP4_OUTDIR/$base.mp4")
done
Comment on lines +39 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add error handling around the vhs command.

If the vhs invocation fails, consider exiting early with an informative message to prevent subsequent steps from running on partial output.


# 2) Process scenes/*.txt
echo ">> Step 2: Building each scene from $SCENES_DIR/*.txt"
SCENE_FILES=( "$SCENES_DIR"/*.txt )
if [[ ${#SCENE_FILES[@]} -eq 0 ]]; then
echo "No scene text files found in $SCENES_DIR. Skipping scene-building steps."
exit 0
fi

for scene_file in "${SCENE_FILES[@]}"; do
scene_name="$(basename "$scene_file" .txt)"

echo " Scene: $scene_file => $scene_name"

# Concatenate scene
echo " Concatenating -> $MP4_OUTDIR/$scene_name.mp4"
ffmpeg -f concat -safe 0 -i "$scene_file" -c copy "$MP4_OUTDIR/$scene_name.mp4"

# Add audio fade
echo " Adding fade audio -> $MP4_OUTDIR/$scene_name-with-audio.mp4"
DURATION="$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$MP4_OUTDIR/$scene_name.mp4")"
FADE_START=$(( ${DURATION%.*} - 5 ))
ffmpeg -i "$MP4_OUTDIR/$scene_name.mp4" -i "$AUDIO_FILE" \
-filter_complex "[1:a]afade=t=out:st=${FADE_START}:d=5[aout]" \
-map 0:v -map "[aout]" \
-c:v copy -c:a aac "$MP4_OUTDIR/$scene_name-with-audio.mp4"

# Create GIF
echo " Creating GIF -> $GIF_OUTDIR/$scene_name.gif"
ffmpeg -y -i "$MP4_OUTDIR/$scene_name-with-audio.mp4" \
-vf palettegen "$GIF_OUTDIR/$scene_name-palette.png"

ffmpeg -i "$MP4_OUTDIR/$scene_name-with-audio.mp4" \
-i "$GIF_OUTDIR/$scene_name-palette.png" \
-lavfi "fps=10 [video]; [video][1:v] paletteuse" \
-y "$GIF_OUTDIR/$scene_name.gif"

echo " Done with scene: $scene_name"
done

echo
echo ">> Done building scenes!"
echo " Segments: $MP4_OUTDIR/<segment>.mp4"
echo " Scenes: $MP4_OUTDIR/<scene>.mp4"
echo " Audio: $MP4_OUTDIR/<scene>-with-audio.mp4"
echo " GIFs: $GIF_OUTDIR/<scene>.gif"
echo
echo "Use './build.sh clean' to remove them."
Loading
Loading