@@ -11,42 +11,59 @@ const PUBLISH_PACKAGES_DOCKER_IMAGE_NAME = 'publish-packages';
11
11
12
12
const publishScriptNodeVersion = process . env . E2E_TEST_PUBLISH_SCRIPT_NODE_VERSION ;
13
13
14
- try {
15
- // Stop test registry container (Verdaccio) if it was already running
16
- childProcess . execSync ( `docker stop ${ TEST_REGISTRY_CONTAINER_NAME } ` , { stdio : 'ignore' } ) ;
17
- console . log ( 'Stopped previously running test registry' ) ;
18
- } catch ( e ) {
19
- // Don't throw if container wasn't running
14
+ // https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
15
+ function groupCIOutput ( groupTitle : string , fn : ( ) => void ) : void {
16
+ if ( process . env . CI ) {
17
+ console . log ( `::group::{${ groupTitle } }` ) ;
18
+ fn ( ) ;
19
+ console . log ( '::endgroup::' ) ;
20
+ } else {
21
+ fn ( ) ;
22
+ }
20
23
}
21
24
22
- // Start test registry (Verdaccio)
23
- childProcess . execSync (
24
- `docker run --detach --rm --name ${ TEST_REGISTRY_CONTAINER_NAME } -p 4873:4873 -v ${ __dirname } /verdaccio-config:/verdaccio/conf verdaccio/verdaccio:${ VERDACCIO_VERSION } ` ,
25
- { encoding : 'utf8' , stdio : 'inherit' } ,
26
- ) ;
27
-
28
- // Build container image that is uploading our packages to fake registry with specific Node.js/npm version
29
- childProcess . execSync (
30
- `docker build --tag ${ PUBLISH_PACKAGES_DOCKER_IMAGE_NAME } --file ./Dockerfile.publish-packages ${
31
- publishScriptNodeVersion ? `--build-arg NODE_VERSION=${ publishScriptNodeVersion } ` : ''
32
- } .`,
33
- {
34
- encoding : 'utf8' ,
35
- stdio : 'inherit' ,
36
- } ,
37
- ) ;
38
-
39
- // Run container that uploads our packages to fake registry
40
- childProcess . execSync (
41
- `docker run --rm -v ${ repositoryRoot } :/sentry-javascript --network host ${ PUBLISH_PACKAGES_DOCKER_IMAGE_NAME } ` ,
42
- {
43
- encoding : 'utf8' ,
44
- stdio : 'inherit' ,
45
- } ,
46
- ) ;
47
-
48
- // TODO: Run e2e tests here
49
-
50
- // Stop test registry
51
- childProcess . execSync ( `docker stop ${ TEST_REGISTRY_CONTAINER_NAME } ` , { encoding : 'utf8' , stdio : 'ignore' } ) ;
52
- console . log ( 'Successfully stopped test registry container' ) ; // Output from command above is not good so we `ignore` it and emit our own
25
+ groupCIOutput ( 'Test Registry Setup' , ( ) => {
26
+ try {
27
+ // Stop test registry container (Verdaccio) if it was already running
28
+ childProcess . execSync ( `docker stop ${ TEST_REGISTRY_CONTAINER_NAME } ` , { stdio : 'ignore' } ) ;
29
+ console . log ( 'Stopped previously running test registry' ) ;
30
+ } catch ( e ) {
31
+ // Don't throw if container wasn't running
32
+ }
33
+
34
+ // Start test registry (Verdaccio)
35
+ childProcess . execSync (
36
+ `docker run --detach --rm --name ${ TEST_REGISTRY_CONTAINER_NAME } -p 4873:4873 -v ${ __dirname } /verdaccio-config:/verdaccio/conf verdaccio/verdaccio:${ VERDACCIO_VERSION } ` ,
37
+ { encoding : 'utf8' , stdio : 'inherit' } ,
38
+ ) ;
39
+
40
+ // Build container image that is uploading our packages to fake registry with specific Node.js/npm version
41
+ childProcess . execSync (
42
+ `docker build --tag ${ PUBLISH_PACKAGES_DOCKER_IMAGE_NAME } --file ./Dockerfile.publish-packages ${
43
+ publishScriptNodeVersion ? `--build-arg NODE_VERSION=${ publishScriptNodeVersion } ` : ''
44
+ } .`,
45
+ {
46
+ encoding : 'utf8' ,
47
+ stdio : 'inherit' ,
48
+ } ,
49
+ ) ;
50
+
51
+ // Run container that uploads our packages to fake registry
52
+ childProcess . execSync (
53
+ `docker run --rm -v ${ repositoryRoot } :/sentry-javascript --network host ${ PUBLISH_PACKAGES_DOCKER_IMAGE_NAME } ` ,
54
+ {
55
+ encoding : 'utf8' ,
56
+ stdio : 'inherit' ,
57
+ } ,
58
+ ) ;
59
+ } ) ;
60
+
61
+ groupCIOutput ( 'Run E2E Test Suites' , ( ) => {
62
+ // TODO: Run e2e tests here
63
+ } ) ;
64
+
65
+ groupCIOutput ( 'Cleanup' , ( ) => {
66
+ // Stop test registry
67
+ childProcess . execSync ( `docker stop ${ TEST_REGISTRY_CONTAINER_NAME } ` , { encoding : 'utf8' , stdio : 'ignore' } ) ;
68
+ console . log ( 'Successfully stopped test registry container' ) ; // Output from command above is not good so we `ignore` it and emit our own
69
+ } ) ;
0 commit comments