Skip to content

Commit 0936bde

Browse files
dgarciabrisenoDaniel Garcia Briseno
andauthored
Update CI test execution steps (#460)
* Update php.yml to use new gh actions * Rename php.yml to ci.yml for gh actions * Use github.ref instead of github.sha * Print docker logs after php tests * Add more logging to workflow * Fix log path * Add more logging to movie builder * Add more debug info * update logging * trying to figure out why movie is failing even though it's not. * Add more logging to ffmpeg * . * Add pytest command from docker repo * Update test to use env for API host * Do the unthinkable * oop * Disable movie builder while running php tests * Enable playwright tests --------- Co-authored-by: Daniel Garcia Briseno <[email protected]>
1 parent 4927f7b commit 0936bde

File tree

5 files changed

+138
-203
lines changed

5 files changed

+138
-203
lines changed

.github/workflows/ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
php-integration-tests:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Setup Helioviewer Docker environment
17+
uses: Helioviewer-Project/helioviewer.org-docker/.github/actions/helioviewer-docker@main
18+
with:
19+
api-ref: ${{ github.ref }}
20+
21+
- name: Disable movie builder (required for tests)
22+
working-directory: helioviewer.org-docker
23+
run: docker compose down movies
24+
25+
# Run tests inside the api container
26+
- name: Run phpunit tests
27+
working-directory: helioviewer.org-docker
28+
run: docker compose exec -T api composer run-script test
29+
30+
- name: Run python tests
31+
uses: Helioviewer-Project/helioviewer.org-docker/.github/actions/pytest-api@main
32+
with:
33+
working-directory: helioviewer.org-docker
34+
35+
- name: Print container logs
36+
if: always()
37+
working-directory: helioviewer.org-docker
38+
run: |
39+
docker compose logs
40+
41+
- name: Print API error logs
42+
if: always()
43+
working-directory: helioviewer.org-docker
44+
run: cat data/log/*
45+
46+
playwright-e2e-tests:
47+
strategy:
48+
matrix:
49+
shardIndex: [1, 2, 3, 4, 5]
50+
shardTotal: [5]
51+
# If one of the shards fails, continue running the remaining tests
52+
fail-fast: false
53+
54+
timeout-minutes: 60
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Run Playwright tests
58+
uses: Helioviewer-Project/helioviewer.org-tests/.github/actions/playwright-test@main
59+
with:
60+
api-ref: ${{ github.sha }}
61+
shard-index: ${{ matrix.shardIndex }}
62+
shard-total: ${{ matrix.shardTotal }}
63+
merge-reports:
64+
# Merge reports after playwright-tests, even if some shards have failed
65+
if: ${{ !cancelled() }}
66+
needs: [playwright-e2e-tests]
67+
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Checkout test code
71+
uses: actions/checkout@v4
72+
with:
73+
repository: 'Helioviewer-Project/helioviewer.org-tests'
74+
path: 'helioviewer.org-tests'
75+
76+
- name: Merge Playwright reports
77+
uses: Helioviewer-Project/helioviewer.org-tests/.github/actions/playwright-merge-reports@main
78+
with:
79+
test-repo-path: 'helioviewer.org-tests'

.github/workflows/php.yml

Lines changed: 0 additions & 155 deletions
This file was deleted.
Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
1-
from unittest.mock import patch
2-
import responses
3-
import unittest
4-
import requests
5-
import os
6-
7-
class TestVsoDownload(unittest.TestCase):
8-
9-
@patch("sunpy.net.Fido.fetch")
10-
@responses.activate
11-
def test_getImageGroup(self, fido_fetch_response):
12-
# Allow requests to localhost to go through.
13-
responses.add_passthru("http://localhost")
14-
URL = "http://localhost/?action=getSciDataScript&imageScale=4.84088176&sourceIds=[13,10]&startDate=2021-06-01T00:01:00Z&endDate=2021-06-01T00:01:15Z&lang=sunpy&provider=vso";
15-
16-
response = requests.get(URL)
17-
18-
self.assertEqual(200, response.status_code)
19-
self.assertEqual("OK", response.reason)
20-
21-
script_with_paths = response.content.replace(b'os.path.expanduser(\'~/\')', bytes('\'/tmp/\'', encoding='utf-8'))
22-
23-
try:
24-
script_for_compile = compile(script_with_paths, '', 'exec', flags=0, dont_inherit=True)
25-
except SyntaxError:
26-
self.fail("Test Fail: Could not compile downloaded sunpy vso script , possible error in script")
27-
28-
test_dir = os.path.dirname(os.path.abspath(__file__))
29-
request_path = os.path.join(test_dir, 'mocked_requests', 'vso_sunpy_download.yaml')
30-
responses._add_from_file(file_path=request_path)
31-
32-
fido_fetch_response.return_value = ['theoretical_file.fits']
33-
locals = {};
34-
exec(script_for_compile,globals(), locals)
35-
36-
self.assertEqual(len(locals['data_aia_304']), 1)
37-
self.assertEqual(len(locals['data_aia_171']), 1)
38-
39-
if __name__ == '__main__':
40-
unittest.main()
1+
from unittest.mock import patch
2+
import responses
3+
import unittest
4+
import requests
5+
import os
6+
7+
class TestVsoDownload(unittest.TestCase):
8+
9+
@patch("sunpy.net.Fido.fetch")
10+
@responses.activate
11+
def test_getImageGroup(self, fido_fetch_response):
12+
# Get API host from environment variable, default to localhost
13+
host = os.environ.get('PYTEST_API_HOST', 'localhost')
14+
# Allow requests to the configured host to go through.
15+
responses.add_passthru(f"http://{host}")
16+
URL = f"http://{host}/?action=getSciDataScript&imageScale=4.84088176&sourceIds=[13,10]&startDate=2021-06-01T00:01:00Z&endDate=2021-06-01T00:01:15Z&lang=sunpy&provider=vso"
17+
18+
response = requests.get(URL)
19+
20+
self.assertEqual(200, response.status_code)
21+
self.assertEqual("OK", response.reason)
22+
23+
script_with_paths = response.content.replace(b'os.path.expanduser(\'~/\')', bytes('\'/tmp/\'', encoding='utf-8'))
24+
25+
try:
26+
script_for_compile = compile(script_with_paths, '', 'exec', flags=0, dont_inherit=True)
27+
except SyntaxError:
28+
self.fail("Test Fail: Could not compile downloaded sunpy vso script , possible error in script")
29+
30+
test_dir = os.path.dirname(os.path.abspath(__file__))
31+
request_path = os.path.join(test_dir, 'mocked_requests', 'vso_sunpy_download.yaml')
32+
responses._add_from_file(file_path=request_path)
33+
34+
fido_fetch_response.return_value = ['theoretical_file.fits']
35+
locals = {};
36+
exec(script_for_compile,globals(), locals)
37+
38+
self.assertEqual(len(locals['data_aia_304']), 1)
39+
self.assertEqual(len(locals['data_aia_171']), 1)
40+
41+
if __name__ == '__main__':
42+
unittest.main()

src/Movie/FFMPEGEncoder.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ public function __construct($directory, $filename, $frameRate, $width, $height,
5555
$this->_log = fopen($directory . 'ffmpeg.log', 'a');
5656
}
5757

58+
private function checkVideoOutput($outputFile) {
59+
// If FFmpeg segfaults, an empty movie container may still be produced,
60+
if (!file_exists($outputFile)) {
61+
throw new Exception("FFMpeg error encountered - movie file $outputFile does not exist");
62+
}
63+
$fsize = filesize($outputFile);
64+
if ($fsize < 1000) {
65+
throw new Exception("FFmpeg error encountered - Expected movie to be at least 1000 bytes, got $fsize ($outputFile)", 43);
66+
}
67+
}
68+
5869
/**
5970
* Creates a medium quality video
6071
*/
@@ -72,9 +83,7 @@ public function createVideo($convertHQ = false)
7283
$this->_createWebMVideo($outputFile);
7384
}
7485

75-
// If FFmpeg segfaults, an empty movie container may still be produced,
76-
if (!file_exists($outputFile) || filesize($outputFile) < 1000)
77-
throw new Exception("FFmpeg error encountered.", 43);
86+
$this->checkVideoOutput($outputFile);
7887

7988
return $outputFile;
8089
}
@@ -93,9 +102,8 @@ public function createHQVideo()
93102
$this->_createWebMVideo($outputFile, 1);
94103
}
95104

96-
// If FFmpeg segfaults, an empty movie container may still be produced
97-
if (!file_exists($outputFile) || filesize($outputFile) < 1000)
98-
throw new Exception("FFmpeg error encountered.", 43);
105+
// If FFmpeg segfaults, an empty movie container may still be produced,
106+
$this->checkVideoOutput($outputFile);
99107

100108
return $outputFile;
101109
}

src/Movie/HelioviewerMovie.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public function build() {
275275
}
276276
catch (Exception $e) {
277277
Sentry::capture($e);
278-
$this->_abort('Error encountered during movie frame compilation: ' . $e->getFile() . ":" . $e->getLine() . " - " . $e->getMessage() );
278+
$this->_abort('Error encountered during movie frame compilation: ' . $e->getFile() . ":" . $e->getLine() . " - " . $e->getMessage() . "\n" . $e->getTraceAsString());
279279
}
280280

281281
$t3 = time();
@@ -289,7 +289,8 @@ public function build() {
289289
$t4 = time();
290290
$this->_abort('Error encountered during video encoding. ' .
291291
'This may be caused by an FFmpeg configuration issue, ' .
292-
'or by insufficient permissions in the cache.', $t4 - $t3);
292+
'or by insufficient permissions in the cache.' . "\n" .
293+
$e->getFile() . ":" . $e->getLine() . " - " . $e->getMessage() . "\n" . $e->getTraceAsString(), $t4 - $t3);
293294
}
294295

295296
// Log buildMovie in statistics table

0 commit comments

Comments
 (0)