Continuous integration with Travis Golang projects

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Although Golang's engineering tools have been perfected, such as testing, code formatting, and so on. But if the development library is open source to GitHub, these things can be done using automated tools, that is Travis

Use steps

1. Develop library and test cases that need to be integrated
2. Create a new file in the project root directory .travis.yml

  Language:gogo:-1.x-' 1.8 '-' 1.9 '-1.10.xscript:-Go test-v./...env:global:secure:kr5jhntys h/jezvk88qp91arb+ud/op/ 5cyofy7unypj6zssjy5fdkyzhjf0vsfmayqjfmpl6ucase9baiepegvbfcy8ai9cnsblzj2ubnjqqypmvygnbjpzp8yknvjkrtitf/ kkwtzzcwimhnpvnghuzxxp/eibejtnwjccrop/qfghlzkblsyfvlwkmryb0dr8rm5mlmgxpzi8q7m+sovro8zjr4qqccybgmhonxlcurhr6ro+ yjjqefojxrufqorx0sgyecgyucc4nupwl5hkdpkqe+mekhz+ rf657swnsn8nxofnnuuwspxe26ak5xf1roecfk2cpwgzut7smjzptw1inxfdiaw+4qllbyxmjkylvfza5icvlt3+/ ekaqc8fg6poxjh0pf3rdtoqvb31cqipwnm1secq6wc64wa/ 5qn4t5oorfpt60bfdaitds62dqgu5lsepcxmwxhxcdqpedm5qce6wjjxurubjmpbm0mpwwcnzhjyrw1g5ttyo25nckxqrlobrjltvwad+ 7oeucsyxqhdptutivy6w3xowt2ec/ Hp0yi7qqummljthuw7lb9zsec4ub5bvwgez5y9bvbknjfpt3ygcxajeedyxwv9g16kos7hmfpzwrqlhbibytiahqarbd4enwqr5ryqpeyetiidlaja4syq0ce =notifications:email:recipients:-1065890063@qq.com on_success:always  

3. Submit to GitHub
4. Open https://www.travis-ci.org/and log in with your GitHub account
5. After logging in, click the "+" sign next to " My repositories" on the left to add the item (click the slider in front of the item)
6. Change the project file, push once to GitHub, and Travis will run the test script automatically

Sensitive data encryption

If your test case needs to use sensitive data (such as some keys, etc.), then you need to encrypt your sensitive data with Travis (for example, Mac)

  1. Terminal executionsudo gem install travis
  2. In the project root directory open terminal execution travis encrypt AMAP_KEY="xxxx" --add amap_key is the environment variable name, program read environment variable can get real KEY,xxxx is sensitive data
  3. After execution, the. Travis.yml will change and the following will be added (secure may not be consistent)

    env:global:    secure: kr5JHNTYsh/jezvk88qP91arb+UD/op/5CyOFY7uNYpJ6ZSsJY5fDKyZHjf0VSFmaYqJFMPl6uCASE9baiepeGvBFcy8aI9CNsbLzj2uBNjqqYPmvYGnBjpzp8yknVJKRTitF/kkWtzZcWImHnpvNGHuzXxp/EIBeJtNwjcCRoP/qfGhlZKbLsYFvlWkmRYb0dr8RM5mlmGXPZi8q7m+soVRO8Zjr4QQccybgmhonxlcUrHr6ro+yjjQefoJXRufqoRX0sGyecGYucC4nUpWl5hkDPkQE+Mekhz+rF657SwNsn8nXOFnnUuwsPXE26ak5xF1roEcFk2CpwGZuT7smJZPtw1inXFdIaW+4qllbyxMJkylvFZa5IcvLT3+/eKaQc8Fg6PoxJH0PF3RdtoQVB31cQiPWNm1SecQ6wC64WA/5qN4T5OoRfpt60BFDAITdS62dQGu5LSepcXMWXhxCdQPeDm5Qce6wjJXURubJMpBm0mPWwCNZhJyRw1G5TTyO25NckXQRlObrjltvwAd+7OEUcsYXqhdPtUTIVy6w3XOwT2eC/hP0Yi7qqUMMlJTHUW7Lb9zsEc4UB5BVwgeZ5Y9bVbknJfpt3ygcXAJeeDYxwV9g16KoS7HMFPzwrqlHbiBytIahqarBd4enwqR5RYQPEyetiIDLaJA4SyQ0cE=
  4. Upload to GitHub

Receive test result notifications

If you need to get notification of Travis execution results, you can add a mailbox configuration, and the mailbox will be notified when the Travis finishes executing.

1. Open the . Travis.yml
2. Add the following:

notifications:  email:    recipients:        - 邮箱地址    on_success: change    on_failure: always

3. Submit to GitHub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.