brenoguim / flexclass

A library for classes with flexible layout
MIT License
56 stars 6 forks source link

Adding codecov.io support #24

Closed eullerborges closed 3 years ago

eullerborges commented 3 years ago

This adds support for coverage tracking under codecov.io. To make this work, just create an account on codecov and merge to master. See here for an example of a generated report.

I ran into some problems in my own fork that shouldn't happen on the clean merge here.

To make this work, we have to disable the bundling of the header libraries into a single shipped library because the code there makes CMake use the merged library for compilation when assembling tests and coverage tools will try to look into the repository for files (and the merged file won't exist on master). You'll see I've added a new FLEXCLASS_BUNDLE option that allows us to control whether we bundle the headers. I've also added code to automatically disable bundling and remove this new option when coverage is enabled (removing the option improves UX when using tools like ccmake).

GitHub actions are quite a pain to test, so we might run into issues here, please reach out if we do.

Side note

We also have Coveralls as an option, but to make it work we need to add the installation of {{lcov}} on the GitHub action and I'd rather avoid that. We can still go that route if we want, we just have to replace the job I've set up here for:

- name: lcov                                                                        
  working-directory: ${{runner.workspace}}/build                                    
  run: |                                                                            
    sudo apt-get install -y lcov                                                    
    lcov --capture --directory . --output-file coverage.info                        
    lcov --remove coverage.info '/usr/*' --output-file coverage.info                
    lcov --remove coverage.info '*/flexclass/external/*' --output-file coverage.info
    lcov --remove coverage.info '*/flexclass/tests/*' --output-file coverage.info   

- name: Coveralls                                                                   
  uses: coverallsapp/github-action@master                                           
  with:                                                                             
    github-token: ${{ secrets.GITHUB_TOKEN }}                                       
    path-to-lcov: ${{runner.workspace}}/build/coverage.info                         

See here an example for the Coveralls report.