Skip to content

Commit

Permalink
Add CodeCov checks (#1)
Browse files Browse the repository at this point in the history
* add CodeCoverage.cmake

* add codecoverage option to cmake file

* add docker file for code coverage

* reorganize the docker folder

* fix bugs in the cmake files

* update docker image with no shell script

* update the CI workflow to add the Codecov checks

* reduce the iteration number for the Codecov checks

---------

Co-authored-by: Jian Sun <sunjian@ucar.edu>
  • Loading branch information
sjsprecious and sjsprecious authored Jun 7, 2024
1 parent 475bfbd commit 544efbe
Show file tree
Hide file tree
Showing 6 changed files with 789 additions and 20 deletions.
50 changes: 36 additions & 14 deletions .github/workflows/CPU_Beltrami_build_run.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
name: Samurai CPU test with Beltrami

on:
workflow_dispatch:
branches: [ "main" ]
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
on: [pull_request, workflow_dispatch]

jobs:
docker-build-and-test:
name: Build and Test - ${{ matrix.dockerfile }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
dockerfile:
- Dockerfile
- Dockerfile.coverage
steps:
- name: Checkout code from a pull request or push
uses: actions/checkout@v3

build_run:
- name: Delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache

runs-on: ubuntu-latest
- name: Build Docker image
run: docker build -f docker/${{ matrix.dockerfile }} -t samurai .

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag samurai_build_run:latest
- name: Running the Docker image for Beltrami case
run: docker run samurai_build_run:latest
# only run this if we are not running codecoverage tests
if: matrix.dockerfile != 'Dockerfile.coverage'
run: docker run --name test-container -t samurai

- name: Run coverage tests in container
if: matrix.dockerfile == 'Dockerfile.coverage'
run: docker run --name test-container -t samurai make coverage

- name: Copy coverage from container
if: matrix.dockerfile == 'Dockerfile.coverage'
run: docker cp test-container:/app/samurai/build/coverage.info .

- name: Upload coverage reports to Codecov
if: matrix.dockerfile == 'Dockerfile.coverage'
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.info
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,18 @@ message("netCDF_INSTALL_PREFIX: ${netCDF_INSTALL_PREFIX}")
message("HDF5_INSTALL_PREFIX: ${HDF5_INSTALL_PREFIX}")
message("HDF5_C_INCLUDE_DIR: ${HDF5_C_INCLUDE_DIR}")

# recurse into src directory for the build
# Enable CodeCoverage analysis
option(ENABLE_COVERAGE "Enable code coverage output" OFF)
if(ENABLE_COVERAGE)
include(CodeCoverage)
append_coverage_compiler_flags()
setup_target_for_coverage_lcov(
NAME coverage
EXECUTABLE "./release/bin/samurai"
EXECUTABLE_ARGS -params /app/samurai/ncar_scripts/TDRP/beltrami.tdrp
BASE_DIRECTORY "${PROJECT_SOURCE_DIR}/src")
endif()

add_subdirectory(src)
# recurse into src directory for the build

add_subdirectory(src)
Loading

0 comments on commit 544efbe

Please sign in to comment.