Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Coverity scan for every Travis pull request build

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: [email protected]
    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

like image 946
gkiko Avatar asked Nov 23 '22 09:11

gkiko


1 Answers

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 enter image description here

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.

like image 192
gkiko Avatar answered Dec 18 '22 10:12

gkiko