github.com/leonlxy/hyperledger@v1.0.0-alpha.0.20170427033203-34922035d248/TravisCI_Readme.md (about)

     1  ##Continuous Integration Process:#
     2  
     3  Continuous Integration is a development practice that requires developers to integrate code into a shared repository. Each time developer checks in code into the repository, it is then verified by an automated build process. This process gives flexibility for the developer to detect any build issues early in the build life cycle.
     4  
     5  **hyperledger** build process is fully automated using **Travis CI** Continuous Integration tool, which helps in building a real time solution for all the code check-ins, perform Unit and Functional Tests. Once the build execution completes, developer will get build result notifications on slack, GitHub and email (Depending on configuration settings provided in .travis.yml file)
     6  
     7  **Master Repository** can be found at [**hyperledger**] (https://github.com/hyperledger/fabric.git).
     8  
     9  ##Setting up Continuous Integration Process:
    10  
    11  - Login to [GitHub] (https://github.com) --> Fork and clone the  [**hyperledger**](https://github.com/hyperledger/fabric.git) project into your *GitHub* account, if you weren't already. If you have a forked repository in your GitHub account, please pull **hyperledger/fabric master repository**. So that, updated .travis.yml (`Configuration file for Travis CI`) file will be copied into your repository.
    12  
    13  ###### Perform **Travis CI** integration in **GitHub**:
    14  
    15  - Click on **Settings** tab in forked **fabric** GitHub repository and click on **Webhooks & Services** option. Click on **Add Service** and click on **Travis CI** link in services panel. Provide below details
    16  
    17  - User (GitHub User Name)
    18  - Token (Generate token from profile - settings - Personal access token - click on Generate New Token) - Check on "public_repo" scope and click on generate token button. Copy and paste it in Token field
    19  - Domain (Enter "notify.travis-ci.org")
    20  
    21  - Click on Add Service button
    22  
    23  This will enable integration between Travis CI and GitHub for the selected repository. After successful integration, **Travis CI** service will appear in Services menu.
    24  
    25  ![Webhook_Travis](docs/images/Travis_service.png)
    26  
    27  ###### Sync and Enable fabric repository in Travis:
    28  
    29  - Browse [Travis CI](http://travis-ci.org) and click on **Sign in with GitHub** button and provide GitHub credentials.
    30  
    31  - http://travis-ci.org - for Public Repositories. http://travis-ci.com - for Private repositories.
    32  
    33  - After login to Travis CI --> Click on *Accounts* link under Username (Available at the top of right corner) and click on **Sync account** button. This will sync and display all the repositories available for the logged in user. As a next step user has to flick ON for the required repositories. After successful flick, refresh the Travis home page and you see all the selected repositories available in *My Repositories* section in Travis home page. 
    34   
    35  - In more options menu, click on **Settings** and enable general settings (**Build only if .travis.yml is present** ,  **Build Pushes** ,  **Limit Current jobs**  , **Build pull requests**) for the selected repository. 
    36  
    37  ![Settings](docs/images/Travis_Settings.png) 
    38  
    39  - Disable **Build Pull Requests** option if you don't want to trigger automation build deployment for any `Pull Requests`.
    40  
    41  **Add Build status markdown link in Readme.md file**
    42  
    43  - Copy markdown link from Travis CI home page and place it in Readme.md file of your working branch. Follow [Embedding Status Images](https://docs.travis-ci.com/user/status-images) that helps you to setup the build status in Readme.md file.
    44  
    45  Note: Please make sure **.travis.yml** , **foldercopy.sh** and **containerlogs.sh** are present with below modifications in the master branch or the working branch in GitHub before performing any ` git push ` operations.
    46  
    47  - Change notifications section as per user preferences:
    48  
    49  Follow [Travis Notification Settings](https://docs.travis-ci.com/user/notifications) to setup notifications in .travis.yml file.
    50  
    51  Repository Owner has to provide slack token. Please get in touch with him/her for your Slack Token.
    52  
    53  ```
    54  notifications:
    55  slack:<Slack account name>:<User Slack Token> ex: slack:openchain:<user slack token>
    56   on_success: always
    57   on_failure: always
    58   email:
    59      recipients:
    60        - one@example.com
    61        - other@example.com
    62      on_success: [always|never|change] # default: change
    63      on_failure: [always|never|change] # default: always
    64  ```
    65  
    66  Now you have completed with Travis CI setup process. If you make any changes in your code and push code to remote repository, Travis CI automatically starts the build process and shows you the build results on your notification settings (Slack, email and on GitHub Readme.md).
    67  
    68  ![Build Results](docs/images/BuildStatus.png)
    69  
    70  **Build Process includes below steps:**
    71  
    72  1. git clone on updated git repository into Travis cloud environment from GitHub.
    73  2. Install all dependency software's and libraries
    74  3. Perform go build
    75  4. Start Peer process
    76  5. Perform unit tests (go tests)
    77  6. Perform Behave test suite (behave tests)
    78  7. Provides failed container log files in travis raw log file.
    79  8. Update slack channel (#fabric-ci-status) with build results.
    80  
    81  ## More Information/Troubleshooting:
    82  
    83  - Developer can skip the Travis CI build process by providing ` [ci skip] ` in the git commit message.
    84  ```
    85  git commit -m "Ignore build process [ci skip]"
    86  
    87  ```
    88  - How to skip Travis Build execution for PR's:?
    89    
    90    - Travis CI checks latest commit of PR and if the commit message is tagged with [ci skip], Travis CI ignores build process.
    91    - This will be useful, when you want to open a pull request early for review but you are not necessarily ready to run the tests right away. Also, you can skip Travis build process for document changes.
    92    - Right now, Travis only supports above method to skip build process.
    93  
    94  - What is the slack channel to view build results?
    95    - We are sending build notifications to hyperledger `#fabric-ci-status` slack channel. (User must join in #fabric-ci-status slack channel to receive build notifications)
    96    
    97  - How to restart build without committing any changes to remote GitHub?
    98  
    99    - Apply `git commit --allow-empty -m "Empty commit" ` and do a git push or click on `Restart Job` (only users with push access to repository can do this) button on Travis CI home page.
   100  
   101  - Where can I find Build log files?
   102    - Click on `RAW log` link on Travis CI home page.
   103  
   104  - Where can I find Behave Container log files?
   105    - Click on each container log file link displays bottom of the RAW log file.