Skip to content

Commit 77d61f9

Browse files
committed
video record testing
1 parent 684a923 commit 77d61f9

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
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: 36 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,25 @@ jobs:
6772
path: /tmp/test-results
6873
destination: test-results
6974

75+
- run:
76+
name: request to stop recording video
77+
command: |
78+
sleep 3 # wait a bit for the video to finish being made
79+
docker-compose -f .circleci/compose.yml exec rails curl chromevideo:9494/stop
80+
- run:
81+
name: download the video
82+
command: |
83+
docker cp chromevideo:/var/output/out.mp4 /tmp/test-video.mp4
84+
- store_artifacts:
85+
path: /tmp/test-video.mp4
86+
7087
build-unit:
7188
docker:
7289
# specify the version you desire here
7390
- image: cimg/ruby:3.3.1-node
7491
environment:
7592
RAILS_ENV: test
93+
BUILDKIT_PROGRESS: plain
7694
working_directory: ~/repo
7795
steps:
7896
- checkout
@@ -99,6 +117,11 @@ jobs:
99117
docker-compose -f .circleci/compose-unit.yml exec rails-unit mkdir /tmp/test-results
100118
docker-compose -f .circleci/compose-unit.yml exec rails-unit rails db:test:prepare
101119
120+
- run:
121+
name: request to start recording video
122+
command: |
123+
docker-compose -f .circleci/compose.yml exec rails curl chromevideo:9494/start
124+
102125
- run:
103126
name: wait for container to ready
104127
command : |
@@ -136,6 +159,18 @@ jobs:
136159
path: /tmp/test-results
137160
destination: test-results
138161

162+
- run:
163+
name: request to stop recording video
164+
command: |
165+
sleep 3 # wait a bit for the video to finish being made
166+
docker-compose -f .circleci/compose-unit.yml exec rails-unit curl chromevideo:9494/stop
167+
- run:
168+
name: download the video
169+
command: |
170+
docker cp chromevideo:/var/output/out.mp4 /tmp/test-video.mp4
171+
- store_artifacts:
172+
path: /tmp/test-video.mp4
173+
139174
brakeman:
140175
docker:
141176
- image: cimg/ruby:3.3.1-node

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)