Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Commit

Permalink
Merge c3f4b4c into 4db8443
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre committed Mar 27, 2015
2 parents 4db8443 + c3f4b4c commit f7cfaf1
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 24 deletions.
4 changes: 4 additions & 0 deletions kickoff/static/kickoff.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ body {
color: red;
}

.helpPartial {
margin-left: 45.5em;
}

.errorText {
color: red;
font-weight: bold;
Expand Down
141 changes: 124 additions & 17 deletions kickoff/static/suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,57 @@ function guessBranchFromVersion(name, version) {
return "";
}

function addLastVersionAsPartial(version, previousReleases, nb) {
partialList=""
nbAdded=0
// We always add the last released version to the list
for (k = 0; k < previousReleases.length; k++) {
previousRelease = stripBuildNumber(previousReleases[k]);
if (previousRelease < version) {
partialList += previousReleases[k] + ",";
nbAdded++;
if (nb == nbAdded) {
return partialList;
}
}
}
}

function getVersionWithBuildNumber(version, previousReleases) {
for (j = 0; j < previousReleases.length; j++) {
if (previousReleases[j].indexOf(version) > -1) {
return previousReleases[j];
}
}
console.warn("Could not find the build number of " + version + " from " + previousReleases);
}


function partialConsistencyCheck(partialsADI, previousReleases) {
stripped=[]
for (i = 0; i < previousReleases.length; i++) {
stripped[i]=stripBuildNumber(previousReleases[i]).replace("esr","");
}
// All partialsADI must be in previousReleases
for (i = 0; i < partialsADI.length; i++) {
if ($.inArray(partialsADI[i], stripped) == -1) {
console.warn("Partial '" + partialsADI[i] + "' not found in the previous build list " + stripped);
console.warn("This should not happen. Please report a bug");
}
}
}


function stripBuildNumber(release) {
// Reuse the previous builds info to generate the partial
// Strip the build number. "31.0build1" < "31.0.1" => false is JS
return release.replace(/build.*/g, "");
}


function populatePartial(name, version, previousBuilds, partialElement) {

partialElement.val("");
if (name.indexOf("fennec") > -1) {
// Android does not need partial
return true;
Expand All @@ -98,13 +147,17 @@ function populatePartial(name, version, previousBuilds, partialElement) {

nbPartial = 0;
previousReleases = [];
partialsADI = [];

// Beta version
betaRE = /^\d+\.\db\d+$/;
betaVersion = version.match(betaRE);
if (betaVersion != null && typeof previousBuilds !== 'undefined' && typeof previousBuilds[base + 'beta'] !== 'undefined') {
previousReleases = previousBuilds[base + 'beta'].sort().reverse();
nbPartial = 2;
// Copy the global variable
// For now, this is pretty much useless as we don't have metrics for specific beta
partialsADI = allPartial.beta;
}

// Release version
Expand All @@ -119,31 +172,68 @@ function populatePartial(name, version, previousBuilds, partialElement) {
previousReleases = previousBuilds[base].sort().reverse()
}
} else {
previousReleases = previousBuilds[base + 'release'].sort().reverse()
previousReleases = previousBuilds[base + 'release'];
}

if (isESR(version)) {
// Use the ESR partial
partialsADI = allPartial.esr;
} else {
partialsADI = allPartial.release;
}
// For thunderbird, use only the three last

nbPartial = 3;
}

// Transform the partialsADI datastruct in a single array to
// simplify processing
partialsADIVersion = [];
for (i = 0; i < partialsADI.length; i++) {
partialsADIVersion[i] = partialsADI[i].version;
}

if (previousReleases.length == 0) {
// No previous build. Not much we can do here.
return false;
}
// Check that all partials match a build.
partialConsistencyCheck(partialsADIVersion, previousReleases);

partial = "";
partialAdded = 0;
for (i = 0; i < previousReleases.length; i++) {
// Reuse the previous builds info to generate the partial
// Strip the build number. "31.0build1" < "31.0.1" => false is JS
previousRelease = previousReleases[i].replace(/build.*/g, "");
if (previousRelease < version) {
// Build a previous release should not occur but it is the case
// don't provide past partials
partial += previousReleases[i];

partialAdded++;
if (isTB(name)) {
// No ADI, select the three first
partial = addLastVersionAsPartial(version, previousReleases, 3);
partialAdded=3;
// Remove the last ","
partial=partial.slice(0,-1);
partialElement.val(partial);
return true;
} else {
// The first partial will always be the previous published release
partial = addLastVersionAsPartial(version, previousReleases, 1);
partialAdded++;
}

for (i = 0; i < partialsADIVersion.length; i++) {

if (i + 1 != previousReleases.length &&
partialAdded != nbPartial) {
// We don't want a trailing ","
partial += ",";
}
if (partial.indexOf(partialsADIVersion[i]) > -1) {
// We have already this version in the list of partial
// Go to the next one
continue;
}
// Build a previous release should not occur but it is the case
// don't provide past partials
partial += getVersionWithBuildNumber(partialsADIVersion[i], previousReleases);
partialAdded++;

if (i + 1 != partialsADIVersion.length &&
partialAdded != nbPartial) {
// We don't want a trailing ","
partial += ",";
}

if (partialAdded == nbPartial) {
// We have enough partials. Bye bye.
break;
Expand All @@ -154,7 +244,7 @@ function populatePartial(name, version, previousBuilds, partialElement) {
}


function setupVersionSuggestions(versionElement, versions, buildNumberElement, buildNumbers, branchElement, partialElement, previousBuilds, dashboardElement) {
function setupVersionSuggestions(versionElement, versions, buildNumberElement, buildNumbers, branchElement, partialElement, previousBuilds, dashboardElement, partialInfo) {

versions.sort(function(a, b) {
return a > b;
Expand Down Expand Up @@ -190,6 +280,22 @@ function setupVersionSuggestions(versionElement, versions, buildNumberElement, b
}
}

function populatePartialInfo(version) {
if (partialsADI.length == 0 || !isRelease(version)) {
partialInfo.html("");
// No ADI available, don't display anything
return;
}

// Format the data for display
partialString = "ADI:<br />";
for (i = 0; i < partialsADI.length; i++) {
partialString += partialsADI[i].version + ": " + partialsADI[i].ADI + "<br />";
}

partialInfo.html(partialString);
}

versionElement.autocomplete({
source: versions,
minLength: 0,
Expand All @@ -207,6 +313,7 @@ function setupVersionSuggestions(versionElement, versions, buildNumberElement, b
populateBranch(event.target.name, ui.item.value);
populatePartial(event.target.name, ui.item.value, previousBuilds, partialElement);
dashboardCheck(ui.item.value);
populatePartialInfo(ui.item.value);
}
}).focus(function() {
$(this).autocomplete('search');
Expand Down
15 changes: 13 additions & 2 deletions kickoff/templates/includes/firefox_release.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<script type='text/javascript'>
$(document).ready(function() {

$.getJSON( "http://localhost/partial.json" )
.done(function( allPartial ) {
window.allPartial = allPartial;
})
.fail(function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error;
console.log( "Request Failed: " + err );
});

setupVersionSuggestions(
$('#{{ firefoxForm.version.id }}'),
{{ firefoxForm.version.suggestions|safe }},
Expand All @@ -8,7 +18,8 @@
$('#{{ firefoxForm.branch.id }}'),
$('#{{ firefoxForm.partials.id }}'),
{{ firefoxForm.partials.suggestions|safe }},
$('#{{ firefoxForm.dashboardCheck.id }}')
$('#{{ firefoxForm.dashboardCheck.id }}'),
$('#partialInfo')
);
setupBranchSuggestions(
$('#{{ firefoxForm.branch.id }}'),
Expand All @@ -21,7 +32,6 @@
$('#{{ firefoxForm.mozillaRevision.id }}')
);
})

</script>
{{ firefoxForm.hidden_tag() }}
<div class="submit_release">
Expand Down Expand Up @@ -51,6 +61,7 @@
<div class="submit_release">
{{ firefoxForm.partials.label()|safe }}
{{ firefoxForm.partials(placeholder='15.0b5build1,15.0b4build2')|safe }}
<div class="helpPartial" id="partialInfo"></div>
<div class="help">A comma separated list of previous releases to create partial updates for. You MUST list the previous release from the chosen branch as one of the partials. For release-channel releases the recommend number of partials is 3, for Betas it's 2, and for ESRs only 1. Each partial chosen adds roughly 1.5h to the end-to-end time of the release.</div>
</div>
<div class="submit_release">
Expand Down

0 comments on commit f7cfaf1

Please sign in to comment.