Skip to content

Video record testing #802

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

Merged
merged 4 commits into from
Jun 11, 2024
Merged
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
14 changes: 14 additions & 0 deletions .circleci/compose-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,25 @@ services:
chrome:
image: selenium/standalone-chrome
container_name: chrome
environment:
SCREEN_WIDTH: 1280
SCREEN_HEIGHT: 1024
healthcheck:
test: ["CMD", "curl", "-v", "http://localhost:4444/wd/hub/status"]
interval: 10s
timeout: 5s
retries: 3
chromevideo:
platform: linux/amd64
image: davidsiaw/vrec
container_name: chromevideo
environment:
HOST: 'chrome:5900'
MP4LOC: '/var/output/out.mp4'
GIVEUID: "1000"
GIVEGID: "1000"
depends_on:
- chrome
volumes:
db_data:
active_storage:
14 changes: 14 additions & 0 deletions .circleci/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,25 @@ services:
chrome:
image: selenium/standalone-chrome-debug
container_name: chrome
environment:
SCREEN_WIDTH: 1280
SCREEN_HEIGHT: 1024
healthcheck:
test: ["CMD", "curl", "-v", "http://localhost:4444/wd/hub/status"]
interval: 10s
timeout: 5s
retries: 3
chromevideo:
platform: linux/amd64
image: davidsiaw/vrec
container_name: chromevideo
environment:
HOST: 'chrome:5900'
MP4LOC: '/var/output/out.mp4'
GIVEUID: "1000"
GIVEGID: "1000"
depends_on:
- chrome
volumes:
db_data:
active_storage:
43 changes: 42 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
- image: cimg/ruby:3.3.1-node
environment:
RAILS_ENV: test
BUILDKIT_PROGRESS: plain

working_directory: ~/repo

Expand Down Expand Up @@ -39,8 +40,12 @@ jobs:
command: |
mkdir -p /tmp/test-results
docker-compose -f .circleci/compose.yml exec rails mkdir /tmp/test-results
docker-compose -f .circleci/compose.yml exec rails rails db:test:prepare
docker-compose -f .circleci/compose.yml exec rails rails db:test:prepare

- run:
name: request to start recording video
command: |
docker-compose -f .circleci/compose.yml exec rails curl chromevideo:9494/start
- run:
name: run tests
command: |
Expand All @@ -67,12 +72,28 @@ jobs:
path: /tmp/test-results
destination: test-results

- run:
name: request to stop recording video
when: always
command: |
sleep 3 # wait a bit for the video to finish being made
docker-compose -f .circleci/compose.yml exec rails curl chromevideo:9494/stop
- run:
name: download the video
when: always
command: |
docker cp chromevideo:/var/output/out.mp4 /tmp/test-video.mp4
- store_artifacts:
when: always
path: /tmp/test-video.mp4

build-unit:
docker:
# specify the version you desire here
- image: cimg/ruby:3.3.1-node
environment:
RAILS_ENV: test
BUILDKIT_PROGRESS: plain
working_directory: ~/repo
steps:
- checkout
Expand All @@ -99,6 +120,11 @@ jobs:
docker-compose -f .circleci/compose-unit.yml exec rails-unit mkdir /tmp/test-results
docker-compose -f .circleci/compose-unit.yml exec rails-unit rails db:test:prepare

- run:
name: request to start recording video
command: |
docker-compose -f .circleci/compose-unit.yml exec rails-unit curl chromevideo:9494/start

- run:
name: wait for container to ready
command : |
Expand Down Expand Up @@ -136,6 +162,21 @@ jobs:
path: /tmp/test-results
destination: test-results

- run:
name: request to stop recording video
when: always
command: |
sleep 3 # wait a bit for the video to finish being made
docker-compose -f .circleci/compose-unit.yml exec rails-unit curl chromevideo:9494/stop
- run:
name: download the video
when: always
command: |
docker cp chromevideo:/var/output/out.mp4 /tmp/test-video.mp4
- store_artifacts:
when: always
path: /tmp/test-video.mp4

brakeman:
docker:
- image: cimg/ruby:3.3.1-node
Expand Down
9 changes: 3 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ before_script:
- gem install bundler # Bundler is not installed with the image
- bundle install -j $(nproc) --path vendor # Install dependencies into ./vendor/ruby

# Optional - Delete if not using `rubocop`
rubocop:
tags:
- ruby
variables:
BUNDLE_ONLY: rubocop
before_script:
- apk --update add build-base git
- gem install rubocop
- bundle install
script:
- rubocop

Expand All @@ -40,8 +39,6 @@ test:
- redis:alpine
- postgres:alpine
- selenium/standalone-chrome
tags:
- ruby
variables:
DATABASE_URL: postgres://postgres:postgres@postgres
REDIS_URL: redis://redis:6379/0
Expand Down
14 changes: 14 additions & 0 deletions bin/vspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'time'

system 'curl chromevideo:9494/start'

system 'rspec'

sleep 3

system 'curl chromevideo:9494/stop'

system "cp vidoutput/out.mp4 vidoutput/#{Time.now.iso8601}-test.mp4"
Loading