Run Coverity scan for every Travis pull request build

試著忘記壹切 提交于 2019-12-12 07:27:30

问题


I want to automate student assignment grading system as much as possible. Ideally these steps will be taken when submitting the assignment.

  1. Student forks my Github repository and modifies files
  2. Student pushes the local code to his repository and creates pull request
  3. Travis CI detects pull request and run Pull Request build
  4. If code builds successfully, Coverity runs static code analysis for the pull request
  5. Student gets build status from the Github pull request page

I've successfully set Travis builds for every pull request in my repo. I have successfully run Coverity scan via Travis for every commit on my repo. But I can't trigger Coverity scans for pull request, only Travis builds are run. Can I fix this problem and maintain Coverity scan report for every pull request?

This is my .travis.yml

language: c
compiler: gcc

env:
  global:
   # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
   #   via the "travis encrypt" command using the project repo's public key
   - secure: "WHkT1bLbpz8VA8tl+qyZvWHLg7YvnMPhCNXCEAQQaklcDq8HQ7glIrrs35VnTDfs09tVgkPbgsAfwBuwxqkmmxWaquW0AHdb6cefNpQVj2ovUriQVNBFmjfte9Bbq0NWKoLp+4IY/3IDfLoUOekOIDXuQtkJhNvX1zkkt21lSeo="

addons:
  coverity_scan:
    project:
      name: "Freeuni-CN101-2014/midterm"
      description: "Build submitted via Travis CI"
    notification_email: example@mail.com
    build_command_prepend: ""
    build_command:   "make"
    branch_pattern: "*"

script: make

Travis output of pull request here

Travis output after I merged the pull request with the main branch here


回答1:


I asked Coverity support and they replied

The trigger for Coverity Scan happens for the specific branch and not for the pull request, and specially the branch that is mentioned in .travis.yml

UPDATE

With user @Admaster's help I started playing with Jenkins and cppcheck plugin. Jenkins is scanning pull requests successfully without setting build status to Github commits(Travis does set).

Example

So I continued experimenting with Travis and came over this repo. I changed my .travis.yml file that looks like this

language: c
compiler: gcc

before_install:
  - sudo apt-get install -qq cppcheck

script:
  - cppcheck --error-exitcode=1 --quiet .
  - make

cppcheck may be less effective then Coverity, but it's sufficient for students' assignments.




回答2:


I suggest not using Coverity, because free account has a lots of limits. Better is to use Jenkins. I will try to make configuration espacially for You. Jenkins support pull requests on github



来源:https://stackoverflow.com/questions/26759088/run-coverity-scan-for-every-travis-pull-request-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!