Skip to content

Commit 81bae3b

Browse files
authored
Merge pull request #802 from davidsiaw/video-tests
Video record testing
2 parents 684a923 + 4427317 commit 81bae3b

File tree

5 files changed

+87
-7
lines changed

5 files changed

+87
-7
lines changed

.circleci/compose-unit.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,25 @@ services:
1818
chrome:
1919
image: selenium/standalone-chrome
2020
container_name: chrome
21+
environment:
22+
SCREEN_WIDTH: 1280
23+
SCREEN_HEIGHT: 1024
2124
healthcheck:
2225
test: ["CMD", "curl", "-v", "http://localhost:4444/wd/hub/status"]
2326
interval: 10s
2427
timeout: 5s
2528
retries: 3
29+
chromevideo:
30+
platform: linux/amd64
31+
image: davidsiaw/vrec
32+
container_name: chromevideo
33+
environment:
34+
HOST: 'chrome:5900'
35+
MP4LOC: '/var/output/out.mp4'
36+
GIVEUID: "1000"
37+
GIVEGID: "1000"
38+
depends_on:
39+
- chrome
2640
volumes:
2741
db_data:
2842
active_storage:

.circleci/compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,25 @@ services:
5858
chrome:
5959
image: selenium/standalone-chrome-debug
6060
container_name: chrome
61+
environment:
62+
SCREEN_WIDTH: 1280
63+
SCREEN_HEIGHT: 1024
6164
healthcheck:
6265
test: ["CMD", "curl", "-v", "http://localhost:4444/wd/hub/status"]
6366
interval: 10s
6467
timeout: 5s
6568
retries: 3
69+
chromevideo:
70+
platform: linux/amd64
71+
image: davidsiaw/vrec
72+
container_name: chromevideo
73+
environment:
74+
HOST: 'chrome:5900'
75+
MP4LOC: '/var/output/out.mp4'
76+
GIVEUID: "1000"
77+
GIVEGID: "1000"
78+
depends_on:
79+
- chrome
6680
volumes:
6781
db_data:
6882
active_storage:

.circleci/config.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
- image: cimg/ruby:3.3.1-node
1111
environment:
1212
RAILS_ENV: test
13+
BUILDKIT_PROGRESS: plain
1314

1415
working_directory: ~/repo
1516

@@ -39,8 +40,12 @@ jobs:
3940
command: |
4041
mkdir -p /tmp/test-results
4142
docker-compose -f .circleci/compose.yml exec rails mkdir /tmp/test-results
42-
docker-compose -f .circleci/compose.yml exec rails rails db:test:prepare
43+
docker-compose -f .circleci/compose.yml exec rails rails db:test:prepare
4344
45+
- run:
46+
name: request to start recording video
47+
command: |
48+
docker-compose -f .circleci/compose.yml exec rails curl chromevideo:9494/start
4449
- run:
4550
name: run tests
4651
command: |
@@ -67,12 +72,28 @@ jobs:
6772
path: /tmp/test-results
6873
destination: test-results
6974

75+
- run:
76+
name: request to stop recording video
77+
when: always
78+
command: |
79+
sleep 3 # wait a bit for the video to finish being made
80+
docker-compose -f .circleci/compose.yml exec rails curl chromevideo:9494/stop
81+
- run:
82+
name: download the video
83+
when: always
84+
command: |
85+
docker cp chromevideo:/var/output/out.mp4 /tmp/test-video.mp4
86+
- store_artifacts:
87+
when: always
88+
path: /tmp/test-video.mp4
89+
7090
build-unit:
7191
docker:
7292
# specify the version you desire here
7393
- image: cimg/ruby:3.3.1-node
7494
environment:
7595
RAILS_ENV: test
96+
BUILDKIT_PROGRESS: plain
7697
working_directory: ~/repo
7798
steps:
7899
- checkout
@@ -99,6 +120,11 @@ jobs:
99120
docker-compose -f .circleci/compose-unit.yml exec rails-unit mkdir /tmp/test-results
100121
docker-compose -f .circleci/compose-unit.yml exec rails-unit rails db:test:prepare
101122
123+
- run:
124+
name: request to start recording video
125+
command: |
126+
docker-compose -f .circleci/compose-unit.yml exec rails-unit curl chromevideo:9494/start
127+
102128
- run:
103129
name: wait for container to ready
104130
command : |
@@ -136,6 +162,21 @@ jobs:
136162
path: /tmp/test-results
137163
destination: test-results
138164

165+
- run:
166+
name: request to stop recording video
167+
when: always
168+
command: |
169+
sleep 3 # wait a bit for the video to finish being made
170+
docker-compose -f .circleci/compose-unit.yml exec rails-unit curl chromevideo:9494/stop
171+
- run:
172+
name: download the video
173+
when: always
174+
command: |
175+
docker cp chromevideo:/var/output/out.mp4 /tmp/test-video.mp4
176+
- store_artifacts:
177+
when: always
178+
path: /tmp/test-video.mp4
179+
139180
brakeman:
140181
docker:
141182
- image: cimg/ruby:3.3.1-node

.gitlab-ci.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ before_script:
2525
- gem install bundler # Bundler is not installed with the image
2626
- bundle install -j $(nproc) --path vendor # Install dependencies into ./vendor/ruby
2727

28-
# Optional - Delete if not using `rubocop`
2928
rubocop:
30-
tags:
31-
- ruby
29+
variables:
30+
BUNDLE_ONLY: rubocop
3231
before_script:
3332
- apk --update add build-base git
34-
- gem install rubocop
33+
- bundle install
3534
script:
3635
- rubocop
3736

@@ -40,8 +39,6 @@ test:
4039
- redis:alpine
4140
- postgres:alpine
4241
- selenium/standalone-chrome
43-
tags:
44-
- ruby
4542
variables:
4643
DATABASE_URL: postgres://postgres:postgres@postgres
4744
REDIS_URL: redis://redis:6379/0

bin/vspec

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require 'time'
5+
6+
system 'curl chromevideo:9494/start'
7+
8+
system 'rspec'
9+
10+
sleep 3
11+
12+
system 'curl chromevideo:9494/stop'
13+
14+
system "cp vidoutput/out.mp4 vidoutput/#{Time.now.iso8601}-test.mp4"

0 commit comments

Comments
 (0)