Contribute to Toaster: Difference between revisions

From Yocto Project
Jump to navigationJump to search
No edit summary
No edit summary
Line 6: Line 6:
The [https://bugzilla.yoctoproject.org/buglist.cgi?product=Toaster Yocto Project Bugzilla instance] lists all the things that need to be done:
The [https://bugzilla.yoctoproject.org/buglist.cgi?product=Toaster Yocto Project Bugzilla instance] lists all the things that need to be done:


* [https://bugzilla.yoctoproject.org/buglist.cgi?list_id=169705&resolution=---&query_format=advanced&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ACCEPTED&bug_status=IN%20PROGRESS%20DESIGN&bug_status=IN%20PROGRESS%20DESIGN%20COMPLETE&bug_status=IN%20PROGRESS%20IMPLEMENTATION&bug_status=IN%20PROGRESS%20REVIEW&bug_status=REOPENED&bug_status=NEEDINFO&bug_status=WaitForUpstream&component=toaster&product=Toaster See a full list of Toaster issues]
* If the issue says <strong>GUI design available</strong> in the Whiteboard field, there is a design specification document attached to the issue that you should follow. Send questions / comments about it to the [https://lists.yoctoproject.org/listinfo/toaster Toaster mailing list]
* If the issue says <strong>GUI design pending</strong> in the Whiteboard field, there is some design work still to be done. Feel free to take the issue and send an email to the [https://lists.yoctoproject.org/listinfo/toaster Toaster mailing list] to find out why the design work is not done yet


* [https://bugzilla.yoctoproject.org/buglist.cgi?list_id=169706&resolution=---&status_whiteboard_type=allwordssubstr&query_format=advanced&status_whiteboard=GUI&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ACCEPTED&bug_status=IN%20PROGRESS%20DESIGN&bug_status=IN%20PROGRESS%20DESIGN%20COMPLETE&bug_status=IN%20PROGRESS%20IMPLEMENTATION&bug_status=IN%20PROGRESS%20REVIEW&bug_status=REOPENED&bug_status=NEEDINFO&bug_status=WaitForUpstream&component=toaster&target_milestone=1.6&target_milestone=1.6%20M1&target_milestone=1.6%20M2&target_milestone=1.6%20M3&target_milestone=1.6%20M4&target_milestone=1.6%20M5&product=Toaster See a list of Toaster user interface issues ]
** If the issue says <strong>GUI design available</strong> in the Whiteboard field, there is a design specification document attached to the issue that you should follow. Send questions / comments about it to the [https://lists.yoctoproject.org/listinfo/toaster Toaster mailing list]
** If the issue says <strong>GUI design pending</strong> in the Whiteboard field, there is some design work still to be done. Feel free to take the issue and send an email to the [https://lists.yoctoproject.org/listinfo/toaster Toaster mailing list] to find out why the design work is not done yet
We have some sample data for development purposes you can download: [[File:Toaster.sqlite]]. Save the file to your <code>/poky/build/</code> directory.


== Set up the local repository ==
== Set up the local repository ==


* Select a [http://www.yoctoproject.org/docs/1.5.1/ref-manual/ref-manual.html#detailed-supported-distros Yocto Project 1.5 compatible host], [https://www.djangoproject.com/download/ install Django-1.5] and South 0.8.4. The "pip" application is recommended to manage the install process.
For development of Toaster we recommend setting up a local install of Toaster.
 
<code>
    $ sudo apt-get install pip
    $ sudo pip uninstall django
    $ sudo pip install django==1.5
    $ sudo pip install South==0.8.4
</code>
 
* Here is an example alternate method for installing "pip" if the above method does not work with your host.
 
<code>
    $ curl --silent --show-error --retry 5 https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python2.7
</code>
 
* Setup a local repository for the development branch, and setup up your branch for pushes to the Yocto Project [http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/ poky-contrib repository]


1. Clone the poky repository
<code>
<code>
    $ cd <installdir>
     $ git clone git://git.yoctoproject.org/poky
     $ git clone git://git.yoctoproject.org/poky
     $ cd poky
     $ cd poky
    $ git remote set-url origin git://git.yoctoproject.org/poky
    $ git remote add poky-contrib ssh://git@git.yoctoproject.org/poky-contrib
    $ git fetch --all -p
</code>
== Set up the project and Toaster interface ==
* Run a build, with Toaster database capture enabled
<code>
    $ cd <installdir>
    $ source poky/oe-init-build-env
    $ source toaster start
    $ bitbake core-image-minimal
</code>
<strong>NOTE:</strong> Toaster MUST be started before you start your build, else no data will be captured. You can recover a working (if sparse) database if you do this to execute a quick re-build.
<code>
    $ source toaster start
    $ bitbake -c cleansstate base-files
    $ bitbake core-image-minimal
</code>
</code>


* Run the Toaster interface
2. Install a python virtual environment to sandbox the python modules from your OS
3. Enter/Activate the python virtual environment in your current shell


<code>
<code>
     $ xdg-open http://localhost:8000/
     $ virtualenv venv
    $ source ./venv/bin/activate
</code>
</code>


<strong>NOTE:</strong> You can alternatively open your browser manually and point it to <code>http://localhost:8000/</code>
== Prepare your SSH credentials for pushing to Yocto Project ==


* Insure that you have registered your <username> with Yocto Project to enable you to push content. You can choose any user name (for example "dreyna") and send it to Michael Halstead (mhalstead at linuxfoundation dot org), together with your SSL public key to enable your pushes to the Yocto Project [http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/ poky-contrib repository].
4. Install the python module dependencies for Toaster
 
* You can run the following command to create the ssh key, noting that you just want to hit return after any of the questions the shell script asks, including the password questions. You will then send the resulting "~/.ssh/id_*.pub" files as your public keys.


<code>
<code>
     $ ssh-keygen -t dsa
     $ pip install -r ./bitbake/toaster-requirements.txt
</code>
</code>


== Edit and submit content for review ==
5. Run the setup and start script, follow instructions displayed
 
* Create a local branch. The BRANCH_NAME is generally of the form <code><username>/<a_name_for_the_branch></code> (for example: <code>dreyna/recipe-detail-view</code>), using:
 
<code>
<code>
    $ git checkout origin/master -b <BRANCH_NAME>
    $ ./bitbake/bin/toaster
</code>
</code>


* Edit and test your content. You might find [https://getfirebug.com/ Firebug] useful for web development purposes. If you need some sample data to test your code, download [[File:Toaster.sqlite]]


* Validate your code.
== Sending patches to Yocto Project ==
** Make sure that all files are in Unix format (and not say DOS by accident)
** Fix any white space at the end of line; i.e, there should not be white space on any line before \n; <code>$ sed -i "s/[[:space:]]\+$//" <file></code>
** Validate your markup for HTML format compliance. There are lots of HTML validators you can use: [http://users.skynet.be/mgueury/mozilla/ HtmlValidator] is one of them.


* Set up your commit(s). The same push can have several partitioned commits. First, add the content for the commit:
<strong>NOTE:</strong> The format of the commit message should be like this


<code>
<pre>
     $ cd <installdir>/poky
     bitbake: toaster: <short one line summary>
    $ git add [-p] bitbake/lib/toaster/...
</code>
 
The <code>-p</code> patch interactive option can help you preview the changes.
 
Then, create the commit:  
 
<code>
    $ git commit -s
</code>


The <code>-s</code> option adds the <code>Signed-off-by</code> to your patches.
    long(er) description


<strong>NOTE:</strong> The format of the commit should be like this
    [YOCTO #0000]


<code>
    vvvvvvvvvvvvvvvvvvvvvvvvv
    bitbake: toaster: <short one line summary>
    <br />
    <long(er) description, can be multi-line, should break at around 60 chars>
    <br />
    [YOCTO #0000]          # replace with the bugzilla issue number; there can be multiple lines
    <br />
     Signed-off-by: First Last <name@company.com>
     Signed-off-by: First Last <name@company.com>
    ^^^^^^^^^^^^^^^^^^^^^^^^^
</pre>
</code>
 
If your patch is directly addressing a Bugzilla issue, you should reference the issue number by adding the <code>YOCTO #0000</code> line just above the <code>Signed-off</code> line.
 
A comprehensive document about commit messages is available at:
 
http://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
 
*  Push your branch for review. You may need <code>-f</code> if this is a commit update, which should be fine since the push is to a private branch managed only by you. The argument to rebase is a ref (branch name, tag name, hash, etc.).
 
<code>
    $ git push [-f] poky-contrib <BRANCH_NAME>
</code>
 
See it on the web using the branch name. For example:
 
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/?h=dreyna%2Frecipe-detail-view
 
* Send an email to the [https://lists.yoctoproject.org/listinfo/webhob Toaster mailing list] with the following content:
** Preface the email's subject line with "<strong>[review-request]</strong>", so that it be routed correctly in each reviewer's mail box
** A brief description of the review request together with the branch name
** Any technical details to call out to reviewers
** Any limitations, assumptions, dependencies, and/or differed work
** Ideally, a test plan that demonstrates how the feature was tested with sufficient detail for general testers and documentation writers. [https://lists.yoctoproject.org/pipermail/toaster/2014-January/000280.html This is a test plan example] you can use as a reference.


Where YOCTO #0000 is the related bug number if there is one. Signed off by with your git commit -s credentials.


<strong>NOTE:</strong> Once your receive a reply on the mailing list confirming that the patches are merged, abandon the branch and start new development on a new branch. To delete an old branch, proceed the branch name with a ":".
We accept patches on the [https://www.yoctoproject.org/tools-resources/community/mailing-lists toaster mailing list] by "git send-email" please include in your subject line "[review-request][PATCH]"  


e.g.
<code>
<code>
     $ git push poky-contrib :<OLD_BRANCH_NAME>
     $ git send-email HEAD^  --subject-prefix="review-request][PATCH"
</code>
</code>


A comprehensive document about commit messages is available on the [http://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines openembedded wiki]


More help learning git is available on [https://try.github.io github] and [http://git-scm.com/documentation/ the official documentation]


* Update the Bugzilla entry. If your patch is directly addressing a Bugzilla issue, please mark the Bugzilla entry as "In Progress Review", and when the patch is merged into upstream <code>bitbake/master</code> (<strong>not</strong> <code>poky-contrib/toaster/master</code>), please mark the Bugzilla entry as "Resolved / Fixed". This will let the QA team know what happens to the code base and the Bugzilla entries.
If you need to get push access to poky-contrib repository please contact Michael Halstead michael@yoctoproject.org if you need any assistance please post on the mailing list.
 
== Rebase your repository from toaster/master ==
 
To update your repository to the latest content, rebase it (as opposed to attempting a merge, which can lose history).
 
<code>
    $ cd <installdir>/poky
    $ git fetch
    $ git rebase [-i] origin/master
</code>


== Style guide DRAFT ==
== Code syle guide ==


=== Templates ===
=== Templates ===

Revision as of 16:16, 2 April 2015

This page summarises the Toaster development process. We hope this will help you start contributing to the project.

What can I do?

The Yocto Project Bugzilla instance lists all the things that need to be done:

  • If the issue says GUI design available in the Whiteboard field, there is a design specification document attached to the issue that you should follow. Send questions / comments about it to the Toaster mailing list
  • If the issue says GUI design pending in the Whiteboard field, there is some design work still to be done. Feel free to take the issue and send an email to the Toaster mailing list to find out why the design work is not done yet


Set up the local repository

For development of Toaster we recommend setting up a local install of Toaster.

1. Clone the poky repository

   $ git clone git://git.yoctoproject.org/poky
   $ cd poky

2. Install a python virtual environment to sandbox the python modules from your OS 3. Enter/Activate the python virtual environment in your current shell

   $ virtualenv venv
   $ source ./venv/bin/activate


4. Install the python module dependencies for Toaster

   $ pip install -r ./bitbake/toaster-requirements.txt

5. Run the setup and start script, follow instructions displayed

    $ ./bitbake/bin/toaster


Sending patches to Yocto Project

NOTE: The format of the commit message should be like this

    bitbake: toaster: <short one line summary>

    long(er) description

    [YOCTO #0000]

    Signed-off-by: First Last <name@company.com>

Where YOCTO #0000 is the related bug number if there is one. Signed off by with your git commit -s credentials.

We accept patches on the toaster mailing list by "git send-email" please include in your subject line "[review-request][PATCH]"

e.g.

   $ git send-email HEAD^  --subject-prefix="review-request][PATCH" 

A comprehensive document about commit messages is available on the openembedded wiki

More help learning git is available on github and the official documentation

If you need to get push access to poky-contrib repository please contact Michael Halstead michael@yoctoproject.org if you need any assistance please post on the mailing list.

Code syle guide

Templates

Django has a template language which allows us to render pages based on the data (context). We use the template language to setup the initial state of the page and to create re-usable components that can be included in other pages.

The recommend template code style is as follows

Yes please:

{{var}}

<div>
  {# Maintaining indentation #}
  {% if %}
   <p>this</p>
  {% else %}
   <p>that</p>
  {% endif %}
</div>

{% comment %}
This is a longer comment that describes all the things
that are below in quite a bit of detail because they're
a little more difficult to understand.
{% endcomment %}

{% for layer in layers_list %}
 {{layer}}
{% endfor %}

No thank you:

{{var}}
<div>
{# Maintaining indentation #}
{%if%}<p>this</p>{%else%}<p>that</p>{%endif%}
</div>


{#This is a longer comment that describes all the things that are below in quite a bit of detail because they're a little more difficult to understand. #}
{%for o in layers_list%}{{o}}{%endfor%}

Note:

  • Maintain indentation as you would with other languages
  • White space after '%'
  • Comment blocks for longer comments


Javascript

Yes please:


"use strict";

/* These hold some numbers */
var oneVar = 1;
var twoVar = 2;

var cheesesTypes = {
  cheddar : 1,
  stilton : 2,
  emmental : 3, 
};

function doThingsHere(){
  return 1;
}

/* If one equals two do some other things and make sure that
 * if the the click handler is setup correctly.
 */
if (one === two) {
  var cheese = "cheddar";
  oneVar = doThingsHere();

  $(this).click(function (event){
    alert("Hello");
  });
}

$("#little-mouse").focusout(function(){
  alert("bye")
});

if (oneVar)
  noThingHere();
else
  doThingHere();

No thank you:

// These hold some numbers
oneVar = 1
twoVar = 2

var cheesesTypes = { cheddar : 1, stilton : 2,  emmental : 3, }

function doThingsHere ()
{
return 1;
}

//If one equals two do some other things and make sure that if the the click handler is setup correctly.
if( one === two ) {
var cheese = "cheddar";
oneVar = doThingsHere();

    $(this).click(function(event){ alert("Hello"); });
}

document.getElementById("little-mouse").addEventListener("focusout", function(){
  alert("bye")
});

if (oneVar)
{
  noThingHere();
} else {  doThingHere(); }
  • Variables should be marked with "var"
  • Semicolons should be used
  • Keep as close to 80 cols as possible
  • Use 2 space per indentation
  • Open curly braces after parenthesis for functions and close on a new line
  • Use camelCase for function names and variable names


Make use of running your Javascript through jshint we have a .jshint configuration file in that js directory (toastergui/static/js)

e.g. install jshint and add to your current PATH, then run:

$ npm install jshint; export PATH=$PATH:$PWD/node_modules/.bin/
$ jshint ./toastergui/static/js/base.js

HTML

Yes please:

<div id="something-area">
  <p class="important">This is some text</p>
</div>

<div>
  <p id="important-text>This is some text</p>
</div>


No thank you:

<div id="somethingarea">
    <p class="Important">This is some text</p></div>
<div id="somethingarea">
<p id="ImportantText">This is
some text
</p>

</div>
  • 2 space indentation
  • Lower case, ids hyphenated when multiple words
  • No duplicate ids

Python

Lenient pep8 Ignoring most of the whitespace around character issues (E124,E203,E201,E265,E303,E302,E231) see toaster/.pep8 and error code list

Fix all issues identified by running code through pep8. We have a fairly lenient config file (toaster/.pep8).

e.g.

$ pep8 ./toastergui/urls.py

Run code through pylint and fix identified issues - Some can be reasonably ignored such as doc strings for every function or star-args. No pylintrc config provided here as most issues identified are highly contextual and should be ignored on a case by case basis.

$ pylint ./toastergui/views.py