@@ -3,91 +3,185 @@ name: CI
33on :
44 push :
55 branches :
6- - main
6+ - main
77 pull_request :
8- branches :
9- - main
8+ branches :
9+ - main
1010
1111jobs :
1212 build-core :
1313 runs-on : ubuntu-latest
1414 steps :
15- - name : Checkout Source Code
16- uses : actions/checkout@v2
17- - name : Update pkg-config database
18- run : sudo ldconfig
19- - name : Setup Docker Buildx
20- id : buildx
21- uses : docker/setup-buildx-action@v2
22- - name : Cache build
23- id : cache-build
24- uses : actions/cache@v2
25- with :
26- path : build-cache-st
27- key : build-cache-st-v1-${{ hashFiles('Dockerfile', 'Makefile', 'build/*') }}
28- restore-keys : |
29- build-cache-st-v1-
30- - name : Build ffmpeg-core
31- run : make prd EXTRA_ARGS="--cache-from=type=local,src=build-cache-st --cache-to=type=local,dest=build-cache-st,mode=max"
32- - name : Upload core
33- uses : actions/upload-artifact@v2
34- with :
35- name : ffmpeg-core
36- path : packages/core/dist/*
15+ - name : Checkout Source Code
16+ uses : actions/checkout@v2
17+ - name : Update pkg-config database
18+ run : sudo ldconfig
19+ - name : Setup Docker Buildx
20+ id : buildx
21+ uses : docker/setup-buildx-action@v2
22+ - name : Cache build
23+ id : cache-build
24+ uses : actions/cache@v4
25+ with :
26+ path : build-cache-st
27+ key : build-cache-st-v1-${{ hashFiles('Dockerfile', 'Makefile', 'build/*') }}
28+ restore-keys : |
29+ build-cache-st-v1-
30+ - name : Build ffmpeg-core
31+ run : make prd EXTRA_ARGS="--cache-from=type=local,src=build-cache-st --cache-to=type=local,dest=build-cache-st,mode=max"
32+ - name : Upload core
33+ uses : actions/upload-artifact@v4
34+ with :
35+ name : ffmpeg-core
36+ path : packages/core/dist/*
3737 build-core-mt :
3838 runs-on : ubuntu-latest
3939 steps :
40- - name : Checkout Source Code
41- uses : actions/checkout@v2
42- - name : Setup Docker Buildx
43- id : buildx
44- uses : docker/setup-buildx-action@v2
45- - name : Cache build
46- id : cache-build
47- uses : actions/cache@v2
48- with :
49- path : build-cache-mt
50- key : build-cache-mt-v1-${{ hashFiles('Dockerfile', 'Makefile', 'build/*') }}
51- restore-keys : |
52- build-cache-v1-
53- - name : Build ffmpet-core-mt
54- run : make prd-mt EXTRA_ARGS="--cache-from=type=local,src=build-cache-mt --cache-to=type=local,dest=build-cache-mt,mode=max"
55- - name : Upload core-mt
56- uses : actions/upload-artifact@v2
57- with :
58- name : ffmpeg-core-mt
59- path : packages/core-mt/dist/*
40+ - name : Checkout Source Code
41+ uses : actions/checkout@v2
42+ - name : Setup Docker Buildx
43+ id : buildx
44+ uses : docker/setup-buildx-action@v2
45+ - name : Cache build
46+ id : cache-build
47+ uses : actions/cache@v4
48+ with :
49+ path : build-cache-mt
50+ key : build-cache-mt-v1-${{ hashFiles('Dockerfile', 'Makefile', 'build/*') }}
51+ restore-keys : |
52+ build-cache-v1-
53+ - name : Build ffmpet-core-mt
54+ run : make prd-mt EXTRA_ARGS="--cache-from=type=local,src=build-cache-mt --cache-to=type=local,dest=build-cache-mt,mode=max"
55+ - name : Upload core-mt
56+ uses : actions/upload-artifact@v4
57+ with :
58+ name : ffmpeg-core-mt
59+ path : packages/core-mt/dist/*
6060 tests :
6161 runs-on : ubuntu-latest
6262 needs :
6363 - build-core
6464 - build-core-mt
6565 steps :
66- - name : Checkout Source Code
67- uses : actions/checkout@v2
68- - name : Download ffmpeg-core
69- uses : actions/download-artifact@v2
70- with :
71- name : ffmpeg-core
72- path : packages/core/dist
73- - name : Download ffmpeg-core-mt
74- uses : actions/download-artifact@v2
75- with :
76- name : ffmpeg-core-mt
77- path : packages/core-mt/dist
78- - name : Use Node.js 18
79- uses : actions/setup-node@v2
80- with :
81- node-version : 18.x
82- - name : Cache dependencies
83- id : cache-dependencies
84- uses : actions/cache@v2
85- with :
86- path : node_modules
87- key : node-modules-${{ hashFiles('package-lock.json') }}
88- restore-keys : |
89- node-modules-
90- - name : Install dependencies
91- run : npm install
92- - name : Run tests
93- run : npm test
66+ - name : Checkout Source Code
67+ uses : actions/checkout@v2
68+ - name : Download ffmpeg-core
69+ uses : actions/download-artifact@v4
70+ with :
71+ name : ffmpeg-core
72+ path : packages/core/dist
73+ - name : Download ffmpeg-core-mt
74+ uses : actions/download-artifact@v4
75+ with :
76+ name : ffmpeg-core-mt
77+ path : packages/core-mt/dist
78+ - name : Use Node.js 18
79+ uses : actions/setup-node@v2
80+ with :
81+ node-version : 18.x
82+ - name : Cache dependencies
83+ id : cache-dependencies
84+ uses : actions/cache@v4
85+ with :
86+ path : node_modules
87+ key : node-modules-${{ hashFiles('package-lock.json') }}
88+ restore-keys : |
89+ node-modules-
90+ - name : Install dependencies
91+ run : npm install
92+ - name : Install Chrome
93+ uses : browser-actions/setup-chrome@latest
94+ with :
95+ chrome-version : stable
96+ - name : Run tests
97+ env :
98+ CHROME_HEADLESS : 1
99+ CHROME_PATH : chrome
100+ CHROME_FLAGS : " --headless --disable-gpu --no-sandbox --enable-features=SharedArrayBuffer,CrossOriginIsolation"
101+ HEADERS : ' {"Cross-Origin-Opener-Policy": "same-origin", "Cross-Origin-Embedder-Policy": "require-corp"}'
102+ run : |
103+ # Start test server with proper headers for all tests
104+ npm run serve -- --headers "$HEADERS" &
105+
106+ # Increase wait time to ensure server is ready
107+ sleep 15
108+
109+ # Verify headers and isolation status
110+ echo "Checking security headers and isolation status..."
111+ curl -v http://localhost:3000/tests/ffmpeg-core-st.test.html 2>&1 | grep -i "cross-origin"
112+
113+ # Run verification script first
114+ echo "Verifying browser environment..."
115+ cat << EOF > verify-browser.html
116+ <!DOCTYPE html>
117+ <html>
118+ <head>
119+ <meta http-equiv="Cross-Origin-Opener-Policy" content="same-origin">
120+ <meta http-equiv="Cross-Origin-Embedder-Policy" content="require-corp">
121+ </head>
122+ <body>
123+ <script>
124+ console.log('SharedArrayBuffer available:', typeof SharedArrayBuffer !== 'undefined');
125+ console.log('crossOriginIsolated:', window.crossOriginIsolated);
126+ if (!window.crossOriginIsolated || typeof SharedArrayBuffer === 'undefined') {
127+ throw new Error('Browser environment not properly configured for SharedArrayBuffer');
128+ }
129+ </script>
130+ </body>
131+ </html>
132+ EOF
133+
134+ # Run single-threaded tests first
135+ echo "Running single-threaded tests..."
136+ npx mocha-headless-chrome \
137+ --args="$CHROME_FLAGS" \
138+ -a no-sandbox \
139+ -f http://localhost:3000/tests/ffmpeg-core-st.test.html 2>&1 | tee st-core-test.log
140+
141+ npx mocha-headless-chrome \
142+ --args="$CHROME_FLAGS" \
143+ -a no-sandbox \
144+ -f http://localhost:3000/tests/ffmpeg-st.test.html 2>&1 | tee st-test.log
145+
146+ # Run multi-threaded tests
147+ echo "Running multi-threaded tests..."
148+ # Create a test script to verify browser environment
149+ cat << EOF > verify-browser.html
150+ <!DOCTYPE html>
151+ <html>
152+ <head>
153+ <title>Browser Environment Test</title>
154+ </head>
155+ <body>
156+ <script>
157+ console.log('SharedArrayBuffer available:', typeof SharedArrayBuffer !== 'undefined');
158+ console.log('crossOriginIsolated:', window.crossOriginIsolated);
159+ </script>
160+ </body>
161+ </html>
162+ EOF
163+
164+ # Run the verification in Chrome
165+ echo "Verifying browser environment..."
166+ npx mocha-headless-chrome \
167+ --args="$CHROME_FLAGS --enable-features=SharedArrayBuffer,CrossOriginIsolation" \
168+ -a no-sandbox \
169+ -f http://localhost:3000/verify-browser.html
170+
171+ # Run MT tests with verified configuration
172+ npx mocha-headless-chrome \
173+ --args="$CHROME_FLAGS --enable-features=SharedArrayBuffer,CrossOriginIsolation" \
174+ -a no-sandbox \
175+ -f http://localhost:3000/tests/ffmpeg-core-mt.test.html 2>&1 | tee mt-core-test.log
176+
177+ npx mocha-headless-chrome \
178+ --args="$CHROME_FLAGS --enable-features=SharedArrayBuffer,CrossOriginIsolation" \
179+ -a no-sandbox \
180+ -f http://localhost:3000/tests/ffmpeg-mt.test.html 2>&1 | tee mt-test.log
181+
182+ # Display all logs for debugging
183+ echo "=== Test Logs ==="
184+ for log in *-test.log; do
185+ echo "Contents of $log:"
186+ cat $log
187+ done
0 commit comments