Skip to content

Commit d7d9306

Browse files
Merge pull request #79 from angular/master
Update upstream
2 parents 2239eb0 + dfcb5ac commit d7d9306

File tree

8 files changed

+87
-25
lines changed

8 files changed

+87
-25
lines changed

.travis.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,12 @@ env:
2020
- JOB=e2e TEST_TARGET=jqlite BROWSER_PROVIDER=saucelabs
2121
- JOB=e2e TEST_TARGET=jquery BROWSER_PROVIDER=saucelabs
2222
global:
23-
# node 4 likes the G++ v4.8 compiler
24-
# see https://docs.travis-ci.com/user/languages/javascript-with-nodejs#Node.js-v4-(or-io.js-v3)-compiler-requirements
25-
- CXX=g++-4.8
2623
- SAUCE_USERNAME=angular-ci
2724
- SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987
2825
- LOGS_DIR=/tmp/angular-build/logs
2926
- BROWSER_PROVIDER_READY_FILE=/tmp/browsersprovider-tunnel-ready
3027
- secure: oTBjhnOKhs0qDSKTf7fE4f6DYiNDPycvB7qfSF5QRIbJK/LK/J4UtFwetXuXj79HhUZG9qnoT+5e7lPaiaMlpsIKn9ann7ffqFWN1E8TMtpJF+AGigx3djYElwfgf5nEnFUFhwjFzvbfpZNnxVGgX5YbIZpe/WUbHkP4ffU0Wks=
3128

32-
addons:
33-
apt:
34-
sources:
35-
- ubuntu-toolchain-r-test
36-
packages:
37-
- g++-4.8
38-
3929
before_install:
4030
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.27.5
4131
- export PATH="$HOME/.yarn/bin:$PATH"
@@ -62,6 +52,9 @@ notifications:
6252
jobs:
6353
include:
6454
- stage: deploy
55+
# Don't deploy from PRs.
56+
# The deployment logic for pushed branches is defined in scripts\travis\build.sh
57+
if: type != pull_request
6558
env:
6659
- JOB=deploy
6760
before_script: skip
@@ -85,8 +78,7 @@ jobs:
8578
on:
8679
repo: angular/angular.js
8780
all_branches: true
88-
# deploy a new docs version when the commit is tagged on the "latest" npm version
89-
condition: $TRAVIS_TAG != '' && $( jq ".distTag" "package.json" | tr -d "\"[:space:]" ) = latest
81+
condition: $DEPLOY_DOCS
9082
- provider: gcs
9183
skip_cleanup: true
9284
access_key_id: GOOGLDB7W2J3LFHICF3R
@@ -98,6 +90,5 @@ jobs:
9890
on:
9991
repo: angular/angular.js
10092
all_branches: true
101-
# upload the build when the commit is tagged or the branch is "master"
102-
condition: $TRAVIS_TAG != '' || ($TRAVIS_PULL_REQUEST = false && $TRAVIS_BRANCH = master)
93+
condition: $DEPLOY_CODE
10394

Gruntfile.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ module.exports = function(grunt) {
6363
NG_VERSION.cdn = versionInfo.cdnVersion;
6464
var dist = 'angular-' + NG_VERSION.full;
6565

66-
var deployVersion = NG_VERSION.isSnapshot ? 'snapshot' : NG_VERSION.full;
66+
var deployVersion = NG_VERSION.full;
67+
68+
if (NG_VERSION.isSnapshot) {
69+
deployVersion = NG_VERSION.distTag === 'latest' ? 'snapshot-stable' : 'snapshot';
70+
}
6771

6872
if (versionInfo.cdnVersion == null) {
6973
throw new Error('Unable to read CDN version, are you offline or has the CDN not been properly pushed?\n' +

docs/app/src/versions.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ angular.module('versions', ['currentVersionData', 'allVersionsData'])
1212
/** @this VersionPickerController */
1313
function VersionPickerController($location, $window, CURRENT_NG_VERSION, ALL_NG_VERSIONS) {
1414

15-
var versionStr = CURRENT_NG_VERSION.isSnapshot ? 'snapshot' : CURRENT_NG_VERSION.version;
15+
var versionStr = CURRENT_NG_VERSION.version;
16+
17+
if (CURRENT_NG_VERSION.isSnapshot) {
18+
versionStr = CURRENT_NG_VERSION.distTag === 'latest' ? 'snapshot-stable' : 'snapshot';
19+
}
1620

1721
this.versions = ALL_NG_VERSIONS;
18-
this.selectedVersion = find(ALL_NG_VERSIONS, function(value) { return value.version.version === versionStr; });
22+
this.selectedVersion = find(ALL_NG_VERSIONS, function(value) {
23+
return value.version.version === versionStr;
24+
});
1925

2026
this.jumpToDocsVersion = function(value) {
2127
var currentPagePath = $location.path().replace(/\/$/, '');

docs/config/processors/versions-data.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ module.exports = function generateVersionDocProcessor(gitData) {
5555

5656
if (missesCurrentVersion) versions.push(currentVersion.version);
5757

58+
// Get the stable release with the highest version
59+
var highestStableRelease = versions.reverse().find(semverIsStable);
60+
5861
versions = versions
5962
.filter(function(versionStr) {
6063
return blacklist.indexOf(versionStr) === -1;
@@ -82,7 +85,21 @@ module.exports = function generateVersionDocProcessor(gitData) {
8285
var latest = sortObject(latestMap, reverse(semver.compare))
8386
.map(function(version) { return makeOption(version, 'Latest'); });
8487

85-
return [makeOption({version: 'snapshot'}, 'Latest', 'master')]
88+
// Generate master and stable snapshots
89+
var snapshots = [
90+
makeOption(
91+
{version: 'snapshot'},
92+
'Latest',
93+
'master-snapshot'
94+
),
95+
makeOption(
96+
{version: 'snapshot-stable'},
97+
'Latest',
98+
createSnapshotStableLabel(highestStableRelease)
99+
)
100+
];
101+
102+
return snapshots
86103
.concat(latest)
87104
.concat(versions);
88105
}
@@ -112,6 +129,18 @@ module.exports = function generateVersionDocProcessor(gitData) {
112129
function sortObject(obj, cmp) {
113130
return Object.keys(obj).map(function(key) { return obj[key]; }).sort(cmp);
114131
}
132+
133+
// https://github.com/kaelzhang/node-semver-stable/blob/34dd29842409295d49889d45871bec55a992b7f6/index.js#L25
134+
function semverIsStable(version) {
135+
var semverObj = semver.parse(version);
136+
return semverObj === null ? false : !semverObj.prerelease.length;
137+
}
138+
139+
function createSnapshotStableLabel(version) {
140+
var label = 'v' + version.replace(/.$/, 'x') + '-snapshot';
141+
142+
return label;
143+
}
115144
}
116145
};
117146
};

lib/versions/version-info.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ var getSnapshotVersion = function() {
210210
version.format();
211211
version.full = version.version + '+' + version.build;
212212
version.branch = 'master';
213+
version.distTag = currentPackage.distTag;
213214

214215
return version;
215216
};

scripts/code.angularjs.org-firebase/functions/index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ function sendStoredFile(request, response) {
169169
}
170170
}
171171

172+
const snapshotRegex = /^snapshot(-stable)?\//;
173+
174+
/**
175+
* The build folder contains a zip file that is unique per build.
176+
* When a new zip file is uploaded into snapshot or snapshot-stable,
177+
* delete the previous zip file.
178+
*/
172179
function deleteOldSnapshotZip(event) {
173180
const object = event.data;
174181

@@ -179,15 +186,17 @@ function deleteOldSnapshotZip(event) {
179186

180187
const bucket = gcs.bucket(bucketId);
181188

182-
if (contentType !== 'application/zip' ||
183-
!filePath.startsWith('snapshot/') ||
189+
const snapshotFolderMatch = filePath.match(snapshotRegex);
190+
191+
if (!snapshotFolderMatch ||
192+
contentType !== 'application/zip' ||
184193
resourceState === 'not_exists' // Deletion event
185194
) {
186195
return;
187196
}
188197

189198
bucket.getFiles({
190-
prefix: 'snapshot/',
199+
prefix: snapshotFolderMatch[0],
191200
delimiter: '/',
192201
autoPaginate: false
193202
}).then(function(data) {
@@ -197,6 +206,8 @@ function deleteOldSnapshotZip(event) {
197206
return file.metadata.name !== filePath && file.metadata.contentType === 'application/zip';
198207
});
199208

209+
console.info(`found ${oldZipFiles.length} old zip files to delete`);
210+
200211
oldZipFiles.forEach(function(file) {
201212
file.delete();
202213
});

scripts/code.angularjs.org-firebase/readme.firebase.code.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ This folder contains the Google Firebase scripts for the code.angularjs.org setu
66
firebase.json contains the rewrite rules that route every subdirectory request to the cloud function
77
in functions/index.js that serves the docs from the Firebase Google Cloud Storage bucket.
88

9+
functions/index.js also contains a rule that deletes outdated build zip files
10+
from the snapshot and snapshot-stable folders when new zip files are uploaded.
11+
912
The deployment to the Google Cloud Storage bucket happens automatically via Travis. See the travis.yml
1013
file in the repository root.
1114

scripts/travis/build.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ case "$JOB" in
1818
fi
1919
;;
2020
"unit")
21-
if [ "$BROWSER_PROVIDER" == "browserstack" ]; then
21+
if [[ "$BROWSER_PROVIDER" == "browserstack" ]]; then
2222
BROWSERS="BS_Chrome,BS_Safari,BS_Firefox,BS_IE_9,BS_IE_10,BS_IE_11,BS_EDGE,BS_iOS_8,BS_iOS_9"
2323
else
2424
BROWSERS="SL_Chrome,SL_Chrome-1,SL_Firefox,SL_Firefox-1,SL_Safari_8,SL_Safari_9,SL_IE_9,SL_IE_10,SL_IE_11,SL_EDGE,SL_EDGE-1,SL_iOS"
@@ -46,11 +46,28 @@ case "$JOB" in
4646
grunt test:travis-protractor --specs="$TARGET_SPECS"
4747
;;
4848
"deploy")
49-
# we never deploy on Pull requests, so it's safe to skip the build here
50-
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then
49+
export DEPLOY_DOCS
50+
export DEPLOY_CODE
51+
52+
DIST_TAG=$( jq ".distTag" "package.json" | tr -d "\"[:space:]" )
53+
54+
# upload docs if the branch distTag from package.json is "latest" (i.e. stable branch)
55+
if [[ "$DIST_TAG" == latest ]]; then
56+
DEPLOY_DOCS=true
57+
fi
58+
59+
# upload the build (code + docs) if ...
60+
# the commit is tagged
61+
# - or the branch is "master"
62+
# - or the branch distTag from package.json is "latest" (i.e. stable branch)
63+
if [[ "$TRAVIS_TAG" != '' || "$TRAVIS_BRANCH" == master || "$DIST_TAG" == latest ]]; then
64+
DEPLOY_CODE=true
65+
fi
66+
67+
if [[ "$DEPLOY_DOCS" || "$DEPLOY_CODE" ]]; then
5168
grunt prepareFirebaseDeploy
5269
else
53-
echo "Skipping build because Travis has been triggered by Pull Request"
70+
echo "Skipping deployment build because conditions have not been met."
5471
fi
5572
;;
5673
*)

0 commit comments

Comments
 (0)