From 6ac35638acbd786cb90956ce35b1cdb861ac4618 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 14 Jun 2016 11:44:37 +0100 Subject: [PATCH 1/5] chore(Gruntfile): kill the build if the CDN version was not found --- Gruntfile.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index c29f87b43624..35cfc7b8d4d8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -17,6 +17,10 @@ module.exports = function(grunt) { NG_VERSION.cdn = versionInfo.cdnVersion; var dist = 'angular-'+ NG_VERSION.full; + if (versionInfo.cdnVersion == null) { + throw new Error('Unable to read CDN version, are you offline or has the CDN not been properly pushed?'); + } + //config grunt.initConfig({ NG_VERSION: NG_VERSION, From c58a04c2fbaade8b34e3b452a4ec1ec57dc3eed7 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 14 Jun 2016 12:22:16 +0100 Subject: [PATCH 2/5] chore(app.scenario): test docs app against production libraries We have had issues where the docs application has gone down because our build included invalid URLs to the production angular libraries. This change runs a subset of the docs e2e tests directly against these production libraries to ensure that they are accessible. If not then these tests will fail and the CI build will abort, preventing the docs app from being updated. --- docs/app/e2e/app.scenario.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/app/e2e/app.scenario.js b/docs/app/e2e/app.scenario.js index f25d5d8233a5..7dfe4b15434c 100644 --- a/docs/app/e2e/app.scenario.js +++ b/docs/app/e2e/app.scenario.js @@ -39,7 +39,7 @@ describe('docs.angularjs.org', function () { it('should change the page content when clicking a link to a service', function () { - browser.get('build/docs/index.html'); + browser.get('build/docs/index-production.html'); var ngBindLink = element(by.css('.definition-table td a[href="api/ng/directive/ngClick"]')); ngBindLink.click(); @@ -51,33 +51,33 @@ describe('docs.angularjs.org', function () { it('should be resilient to trailing slashes', function() { - browser.get('build/docs/index.html#!/api/ng/function/angular.noop/'); + browser.get('build/docs/index-production.html#!/api/ng/function/angular.noop/'); var pageBody = element(by.css('h1')); expect(pageBody.getText()).toEqual('angular.noop'); }); it('should be resilient to trailing "index"', function() { - browser.get('build/docs/index.html#!/api/ng/function/angular.noop/index'); + browser.get('build/docs/index-production.html#!/api/ng/function/angular.noop/index'); var pageBody = element(by.css('h1')); expect(pageBody.getText()).toEqual('angular.noop'); }); it('should be resilient to trailing "index/"', function() { - browser.get('build/docs/index.html#!/api/ng/function/angular.noop/index/'); + browser.get('build/docs/index-production.html#!/api/ng/function/angular.noop/index/'); var pageBody = element(by.css('h1')); expect(pageBody.getText()).toEqual('angular.noop'); }); it('should display formatted error messages on error doc pages', function() { - browser.get('build/docs/index.html#!error/ng/areq?p0=Missing&p1=not%20a%20function,%20got%20undefined'); + browser.get('build/docs/index-production.html#!error/ng/areq?p0=Missing&p1=not%20a%20function,%20got%20undefined'); expect(element(by.css('.minerr-errmsg')).getText()).toEqual("Argument 'Missing' is not a function, got undefined"); }); it("should display an error if the page does not exist", function() { - browser.get('build/docs/index.html#!/api/does/not/exist'); + browser.get('build/docs/index-production.html#!/api/does/not/exist'); expect(element(by.css('h1')).getText()).toBe('Oops!'); }); From 7057d26b28866f630b99fbff40288c0bb276f196 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 14 Jun 2016 12:43:07 +0100 Subject: [PATCH 3/5] chore(version-info): add offline-build support Previously it was slow and problematic to run builds if you were not connected to the internet because the build scripts make requests to github and the Google CDN to find out version information. You can now disable these requests by setting the ANGULAR_1_OFFLINE_BUILD environment variable to a truthy value. --- lib/versions/version-info.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/versions/version-info.js b/lib/versions/version-info.js index cf3f000cbd58..2bf15aea559f 100644 --- a/lib/versions/version-info.js +++ b/lib/versions/version-info.js @@ -6,6 +6,9 @@ var shell = require('shelljs'); var semver = require('semver'); var _ = require('lodash'); +var process = require('process'); +var OFFLINE = !!process.env['ANGULAR_1_OFFLINE_BUILD']; + var currentPackage, previousVersions, cdnVersion, gitRepoInfo; @@ -100,8 +103,8 @@ var getPreviousVersions = function() { // not contain all commits when cloned with git clone --depth=... // Needed e.g. for Travis var repo_url = currentPackage.repository.url; - var tagResults = shell.exec('git ls-remote --tags ' + repo_url, - {silent: true}); + var query = OFFLINE ? 'git tag' : 'git ls-remote --tags ' + repo_url; + var tagResults = shell.exec(query, {silent: true}); if (tagResults.code === 0) { return _(tagResults.output.match(/v[0-9].*[0-9]$/mg)) .map(function(tag) { @@ -138,6 +141,10 @@ var getCdnVersion = function() { .reverse() .reduce(function(cdnVersion, version) { if (!cdnVersion) { + if (OFFLINE) { + // We are offline so just use the most recent version + cdnVersion = version; + } // Note: need to use shell.exec and curl here // as version-infos returns its result synchronously... var cdnResult = shell.exec('curl http://ajax.googleapis.com/ajax/libs/angularjs/' + version + '/angular.min.js ' + @@ -204,3 +211,13 @@ exports.gitRepoInfo = gitRepoInfo = getGitRepoInfo(); exports.previousVersions = previousVersions = getPreviousVersions(); exports.cdnVersion = cdnVersion = getCdnVersion(); exports.currentVersion = getTaggedVersion() || getSnapshotVersion(); + +if (OFFLINE) { + console.log('=============================================================================================='); + console.log('Running Offline:'); + console.log(' - this due to the "ANGULAR_1_OFFLINE_BUILD" environment variable being defined.'); + console.log(' - be aware that the generated docs may not have valid or the most recent version information.'); + console.log('=============================================================================================='); +} +console.log('CDN version:', cdnVersion.raw); +console.log('Current version:', exports.currentVersion.raw); \ No newline at end of file From 18206f0800841bf72f010fea7a837977ba2c163e Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 14 Jun 2016 17:09:43 +0100 Subject: [PATCH 4/5] chore(version-info): add offline-build support Previously it was slow and problematic to run builds if you were not connected to the internet because the build scripts make requests to github and the Google CDN to find out version information. You can now disable these requests by setting the NG1_BUILD_NO_REMOTE_VERSION_REQUESTS environment variable to a non-empty value --- lib/versions/version-info.js | 38 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/lib/versions/version-info.js b/lib/versions/version-info.js index 2bf15aea559f..7c109616f8b8 100644 --- a/lib/versions/version-info.js +++ b/lib/versions/version-info.js @@ -7,7 +7,8 @@ var semver = require('semver'); var _ = require('lodash'); var process = require('process'); -var OFFLINE = !!process.env['ANGULAR_1_OFFLINE_BUILD']; +// We are only interested in whether this environment variable exists, hence the !! +var NO_REMOTE_REQUESTS = !!process.env['NG1_BUILD_NO_REMOTE_VERSION_REQUESTS']; var currentPackage, previousVersions, cdnVersion, gitRepoInfo; @@ -99,11 +100,11 @@ var getTaggedVersion = function() { * @return {Array.} The collection of previous versions */ var getPreviousVersions = function() { - // always use the remote tags as the local clone might + // If we are allowing remote requests then use the remote tags as the local clone might // not contain all commits when cloned with git clone --depth=... - // Needed e.g. for Travis + // Otherwise just use the tags in the local repository var repo_url = currentPackage.repository.url; - var query = OFFLINE ? 'git tag' : 'git ls-remote --tags ' + repo_url; + var query = NO_REMOTE_REQUESTS ? 'git tag' : 'git ls-remote --tags ' + repo_url; var tagResults = shell.exec(query, {silent: true}); if (tagResults.code === 0) { return _(tagResults.output.match(/v[0-9].*[0-9]$/mg)) @@ -141,19 +142,20 @@ var getCdnVersion = function() { .reverse() .reduce(function(cdnVersion, version) { if (!cdnVersion) { - if (OFFLINE) { - // We are offline so just use the most recent version + if (NO_REMOTE_REQUESTS) { + // We do not want to make any remote calls to the CDN so just use the most recent version cdnVersion = version; - } - // Note: need to use shell.exec and curl here - // as version-infos returns its result synchronously... - var cdnResult = shell.exec('curl http://ajax.googleapis.com/ajax/libs/angularjs/' + version + '/angular.min.js ' + - '--head --write-out "%{http_code}" -o /dev/null -silent', - {silent: true}); - if (cdnResult.code === 0) { - var statusCode = cdnResult.output.trim(); - if (statusCode === '200') { - cdnVersion = version; + } else { + // Note: need to use shell.exec and curl here + // as version-infos returns its result synchronously... + var cdnResult = shell.exec('curl http://ajax.googleapis.com/ajax/libs/angularjs/' + version + '/angular.min.js ' + + '--head --write-out "%{http_code}" -o /dev/null -silent', + {silent: true}); + if (cdnResult.code === 0) { + var statusCode = cdnResult.output.trim(); + if (statusCode === '200') { + cdnVersion = version; + } } } } @@ -212,10 +214,10 @@ exports.previousVersions = previousVersions = getPreviousVersions(); exports.cdnVersion = cdnVersion = getCdnVersion(); exports.currentVersion = getTaggedVersion() || getSnapshotVersion(); -if (OFFLINE) { +if (NO_REMOTE_REQUESTS) { console.log('=============================================================================================='); console.log('Running Offline:'); - console.log(' - this due to the "ANGULAR_1_OFFLINE_BUILD" environment variable being defined.'); + console.log(' - this is due to the "NG1_BUILD_NO_REMOTE_VERSION_REQUESTS" environment variable being defined.'); console.log(' - be aware that the generated docs may not have valid or the most recent version information.'); console.log('=============================================================================================='); } From d2b214f8aea45f6876856373abb756951cbb0c7a Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 14 Jun 2016 18:30:38 +0100 Subject: [PATCH 5/5] chore(version-info): add offline-build support Previously it was slow and problematic to run builds if you were not connected to the internet because the build scripts make requests to github and the Google CDN to find out version information. You can now disable these requests by setting the NG1_BUILD_NO_REMOTE_VERSION_REQUESTS environment variable to a non-empty value --- lib/versions/version-info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/versions/version-info.js b/lib/versions/version-info.js index 7c109616f8b8..73df518a8740 100644 --- a/lib/versions/version-info.js +++ b/lib/versions/version-info.js @@ -216,7 +216,7 @@ exports.currentVersion = getTaggedVersion() || getSnapshotVersion(); if (NO_REMOTE_REQUESTS) { console.log('=============================================================================================='); - console.log('Running Offline:'); + console.log('Running with no remote requests for version data:'); console.log(' - this is due to the "NG1_BUILD_NO_REMOTE_VERSION_REQUESTS" environment variable being defined.'); console.log(' - be aware that the generated docs may not have valid or the most recent version information.'); console.log('==============================================================================================');