From ee06e1c76823fd0c0ae78e287df1e04b09b155b2 Mon Sep 17 00:00:00 2001 From: Tony Spataro Date: Fri, 8 Jul 2022 22:56:11 -0700 Subject: [PATCH] Make X11/etc persistent; add ffmpeg --- .github/workflows/main.yml | 63 ++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 68d3bde..5602b9c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,24 +28,67 @@ jobs: with: bundler-cache: true ruby-version: ${{ matrix.ruby }} + - name: Install gem + run: gem install syntax_tree - name: Compile extension run: | yarn install --frozen-lockfile yarn compile - - name: Install gem - run: gem install syntax_tree - - name: Setup upterm session - uses: lhotari/action-upterm@v1 - with: - limit-access-to-actor: true - - name: Run tests + - name: Setup GUI Environment + run: | + # prerequisites + sudo apt-get install -yq dbus-x11 ffmpeg > /dev/null + mkdir -p ~/bin + mkdir -p ~/var/run + cat < ~/bin/xvfb-daemon + #! /bin/bash + echo DISPLAY=\$DISPLAY >> ${GITHUB_ENV} + echo XAUTHORITY=\$XAUTHORITY >> ${GITHUB_ENV} + sleep 86400 + EOF + chmod a+x ~/bin/xvfb-daemon + dbus-launch >> ${GITHUB_ENV} + start-stop-daemon --start --quiet --pidfile ~/var/run/Xvfb.pid --make-pidfile --background --exec /usr/bin/xvfb-run -- ~/bin/xvfb-daemon + echo "Waiting for Xvfb to start..." + while ! grep -q DISPLAY= ${GITHUB_ENV}; do + echo -n . + sleep 3 + done + if: runner.os == 'Linux' + - name: Start Screen Recording run: | - sudo apt install dbus-x11 - dbus-launch xvfb-run -a npm test + no_close=#--no-close # uncomment to see ffmpeg output (i.e. leave stdio open) + start-stop-daemon $no_close --start --quiet --pidfile ~/var/run/ffmpeg.pid --make-pidfile --background --exec /usr/bin/ffmpeg -- -f x11grab -video_size cif -framerate 10 -i ${DISPLAY}.0+0,0 $PWD/test.mp4 + pid=`cat ~/var/run/ffmpeg.pid` + echo "Waiting for ffmpeg (pid $pid) to start recording (display $DISPLAY)..." + while [ ! -f $PWD/test.mp4 ]; do + echo -n . + sleep 3 + done if: runner.os == 'Linux' - - name: Run tests + # - name: Setup SSH Debugging + # uses: lhotari/action-upterm@v1 + # with: + # limit-access-to-actor: true + - name: Run Tests run: npm test if: runner.os != 'Linux' + - name: Stop Screen Recording + run: | + start-stop-daemon --stop --pidfile ~/var/run/ffmpeg.pid + if: runner.os == 'Linux' + - name: Archive Screen Recording + uses: actions/upload-artifact@v3 + with: + name: test-video + path: | + test.mp4 + if: runner.os == 'Linux' + - name: Teardown GUI Environment + run: | + start-stop-daemon --stop --pidfile ~/var/run/Xvfb.pid + kill $DBUS_SESSION_BUS_PID + if: runner.os == 'Linux' automerge: name: AutoMerge needs: ci