Explorar o código

Merge pull request #1087 from ckeditor/t/1076

Internal: Scripts that build the documentation start working again. CI marks the build as failed if something goes wrong. Closes #1076.
Piotrek Koszuliński %!s(int64=7) %!d(string=hai) anos
pai
achega
6eff7033e7
Modificáronse 3 ficheiros con 29 adicións e 8 borrados
  1. 3 2
      .travis.yml
  2. 13 3
      scripts/docs/build-and-publish-nightly.js
  3. 13 3
      scripts/docs/build-and-publish.js

+ 3 - 2
.travis.yml

@@ -21,8 +21,9 @@ install:
 script:
   - npm t -- --reporter=dots
   - npm run docs:api -- --validate-only
-after_success:
-  - travis_wait npm run docs:build-and-publish-nightly
+  - 'if [ $TRAVIS_TEST_RESULT -eq 0 ]; then
+  	  travis_wait npm run docs:build-and-publish-nightly;
+    fi'
 notifications:
   slack:
     rooms:

+ 13 - 3
scripts/docs/build-and-publish-nightly.js

@@ -50,9 +50,12 @@ exec( 'rm -rf ckeditor5.github.io/docs/nightly/ckeditor5/latest' );
 // Copy built documentation to the new destination.
 exec( 'cp -R build/docs/* ckeditor5.github.io/docs/nightly/' );
 
+// Umberto makes a symlink between the latest version (`projectVersion`) and "latest/" directory.
+// The symlink must be deleted in order to copy a documentation for `projectVersion` as `latest`.
+exec( 'rm -rf ckeditor5.github.io/docs/nightly/ckeditor5/latest' );
+
 // Copy the versioned documentation to latest/.
-exec( 'mkdir ckeditor5.github.io/docs/nightly/ckeditor5/latest' );
-exec( `cp -R ckeditor5.github.io/docs/nightly/ckeditor5/${ projectVersion }/* ckeditor5.github.io/docs/nightly/ckeditor5/latest` );
+exec( `cp -R ckeditor5.github.io/docs/nightly/ckeditor5/${ projectVersion } ckeditor5.github.io/docs/nightly/ckeditor5/latest` );
 
 // Change work directory in order to make a commit in CKEditor 5 page's repository.
 process.chdir( path.join( process.cwd(), 'ckeditor5.github.io' ) );
@@ -73,5 +76,12 @@ if ( exec( 'git diff --name-only docs/' ).trim().length ) {
 }
 
 function exec( command ) {
-	return tools.shExec( command, { verbosity: 'error' } );
+	try {
+		return tools.shExec( command, { verbosity: 'error' } );
+	}
+	catch ( error ) {
+		console.error( error );
+
+		process.exit( 1 );
+	}
 }

+ 13 - 3
scripts/docs/build-and-publish.js

@@ -40,9 +40,12 @@ exec( 'rm -rf ../ckeditor5.github.io/docs/nightly/ckeditor5/latest' );
 // Copy built documentation to the new destination.
 exec( 'cp -R build/docs/* ../ckeditor5.github.io/docs/nightly/' );
 
+// Umberto makes a symlink between the latest version (`projectVersion`) and "latest/" directory.
+// The symlink must be deleted in order to copy a documentation for `projectVersion` as `latest`.
+exec( 'rm -rf ../ckeditor5.github.io/docs/nightly/ckeditor5/latest' );
+
 // Copy the versioned documentation to latest/.
-exec( 'mkdir ../ckeditor5.github.io/docs/nightly/ckeditor5/latest' );
-exec( `cp -R ../ckeditor5.github.io/docs/nightly/ckeditor5/${ projectVersion }/* ../ckeditor5.github.io/docs/nightly/ckeditor5/latest` );
+exec( `cp -R ../ckeditor5.github.io/docs/nightly/ckeditor5/${ projectVersion } ../ckeditor5.github.io/docs/nightly/ckeditor5/latest` );
 
 process.chdir( path.join( process.cwd(), '..', 'ckeditor5.github.io' ) );
 
@@ -61,5 +64,12 @@ if ( exec( 'git diff --name-only docs/' ).trim().length ) {
 process.chdir( path.join( process.cwd(), '..', 'ckeditor5' ) );
 
 function exec( command ) {
-	return tools.shExec( command, { verbosity: 'error' } );
+	try {
+		return tools.shExec( command, { verbosity: 'error' } );
+	}
+	catch ( error ) {
+		console.error( error );
+
+		process.exit( 1 );
+	}
 }