debugging codecov build #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Code Coverage workflow | |
| # Builds MPAS with coverage instrumentation, runs test cases, and uploads to Codecov | |
| # | |
| # Note: GCC coverage requires .gcno files (compile-time) and .gcda files (runtime) | |
| # to be in matching locations. We handle this by: | |
| # 1. Building in a known location | |
| # 2. Using GCOV_PREFIX/GCOV_PREFIX_STRIP to redirect .gcda output | |
| # 3. Processing coverage in the same container for gcov compatibility | |
| # | |
| name: Code Coverage | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| test-case: | |
| description: 'Test case to run' | |
| type: choice | |
| default: '240km' | |
| options: | |
| - 240km | |
| push: | |
| branches: | |
| - master | |
| - feature-ci | |
| pull_request: | |
| branches: | |
| - master | |
| - feature-ci | |
| jobs: | |
| #=========================================================================== | |
| # BUILD, RUN, AND GENERATE COVERAGE in single job | |
| # This avoids path mismatches between compile and runtime | |
| #=========================================================================== | |
| coverage: | |
| name: Build, Run, and Generate Coverage | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ncarcisl/cisldev-x86_64-almalinux9-gcc-mpich3:devel | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - name: Install coverage tools | |
| run: | | |
| # Install lcov for coverage report generation | |
| # lcov is in EPEL for AlmaLinux/RHEL 9 | |
| echo "Installing EPEL repository..." | |
| dnf install -y epel-release | |
| echo "Installing lcov..." | |
| dnf install -y lcov | |
| lcov --version | |
| - name: Build MPAS-A with coverage flags | |
| run: | | |
| # Source container environment | |
| if [ -f /container/config_env.sh ]; then | |
| source /container/config_env.sh | |
| fi | |
| # Patch Makefile to add coverage flags to the gfortran target | |
| # This preserves the proper dependency handling for parallel builds | |
| echo "Patching Makefile for coverage instrumentation..." | |
| # Add --coverage to FFLAGS_OPT in gfortran target | |
| sed -i 's/"FFLAGS_OPT = -O3 -ffree-line-length-none/"FFLAGS_OPT = -O0 --coverage -g -ffree-line-length-none/' Makefile | |
| # Add --coverage to CFLAGS_OPT in gfortran target | |
| sed -i 's/"CFLAGS_OPT = -O3"/"CFLAGS_OPT = -O0 --coverage -g"/' Makefile | |
| # Add --coverage to CXXFLAGS_OPT in gfortran target | |
| sed -i 's/"CXXFLAGS_OPT = -O3"/"CXXFLAGS_OPT = -O0 --coverage -g"/' Makefile | |
| # Add --coverage to LDFLAGS_OPT in gfortran target | |
| sed -i 's/"LDFLAGS_OPT = -O3"/"LDFLAGS_OPT = --coverage"/' Makefile | |
| # Verify the patch worked | |
| echo "=== Patched FFLAGS_OPT ===" | |
| grep "FFLAGS_OPT.*coverage" Makefile | head -1 | |
| # Build with parallel jobs (dependency order handled by gfortran target) | |
| make gfortran CORE=atmosphere --jobs $(nproc) | |
| # Verify gcno files were created | |
| echo "=== .gcno files created ===" | |
| find src -name "*.gcno" | wc -l | |
| find src -name "*.gcno" | head -10 | |
| - name: Run 240km test case | |
| run: | | |
| # Source container environment | |
| if [ -f /container/config_env.sh ]; then | |
| source /container/config_env.sh | |
| fi | |
| # Extract test case | |
| tar xzf .github/workflows/240km.tar.gz | |
| cd 240km | |
| # Link executable | |
| ln -sf ../atmosphere_model . | |
| # Configure for a short run | |
| sed -i "s/config_run_duration = '[^']*'/config_run_duration = '0_00:30:00'/" namelist.atmosphere | |
| # Run model - gcda files will be generated in src/ directory | |
| # because that's where the gcno files are | |
| ulimit -s unlimited 2>/dev/null || true | |
| mpirun -n 1 ./atmosphere_model || { | |
| echo "Model run completed (may have warnings)" | |
| } | |
| cd .. | |
| # Verify gcda files were created | |
| echo "=== .gcda files created ===" | |
| find . -name "*.gcda" | wc -l | |
| find . -name "*.gcda" | head -10 | |
| - name: Generate coverage report | |
| run: | | |
| # Source container environment for gcov | |
| if [ -f /container/config_env.sh ]; then | |
| source /container/config_env.sh | |
| fi | |
| # Debug: Show what we have | |
| echo "=== Coverage files summary ===" | |
| echo "gcno files: $(find . -name '*.gcno' | wc -l)" | |
| echo "gcda files: $(find . -name '*.gcda' | wc -l)" | |
| # Check if we have both gcno and gcda files | |
| if [ $(find . -name '*.gcda' | wc -l) -eq 0 ]; then | |
| echo "WARNING: No .gcda files found - model may not have run correctly" | |
| echo "Listing directory structure for debugging:" | |
| ls -la | |
| ls -la 240km/ || true | |
| fi | |
| # Generate lcov report | |
| # Use gcov from the container (matches compiler version) | |
| lcov --capture \ | |
| --directory src \ | |
| --output-file coverage.info \ | |
| --ignore-errors source,gcov,empty \ | |
| || echo "Warning: lcov had some errors (this may be okay)" | |
| # Check if coverage.info has content | |
| if [ -s coverage.info ]; then | |
| # Remove external/system files from coverage | |
| lcov --remove coverage.info \ | |
| '/usr/*' \ | |
| '*/external/*' \ | |
| --output-file coverage.info \ | |
| --ignore-errors unused \ | |
| || true | |
| # Generate summary | |
| echo "=== Coverage Summary ===" | |
| lcov --list coverage.info || true | |
| else | |
| echo "WARNING: coverage.info is empty or missing" | |
| # Create minimal coverage file for debugging | |
| echo "TN:" > coverage.info | |
| echo "SF:src/placeholder.F" >> coverage.info | |
| echo "end_of_record" >> coverage.info | |
| fi | |
| - name: Upload to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: coverage.info | |
| flags: fortran | |
| name: mpas-atmosphere | |
| fail_ci_if_error: false | |
| verbose: true | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload coverage artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-report | |
| path: | | |
| coverage.info | |
| retention-days: 30 |