Skip to content

Commit 850296d

Browse files
committed
CI: Consolidate unit test rules, codecov pathfix
This commit contains two changes to gcov report generation and codecov upload. 1. Separation of the file parser unit tests from the others was causing them to be exluded from report.cov.unit. This patch reworks the rules to replace MOM_file_parser_tests.F90.gcov with driver code, build/unit/test_%.F90.gcov. This does assume at all drivers will look the same (test_*.F90) but that part can be reworked if it ever becomes a problem in the future. Thanks to @adcroft for multiple suggestions in this PR. 2. Github appears to internally store all its repositories in another directory with the name as the repo (in this case MOM6/). Normally this is hidden to everyone, but it was causing some confusion with the codecov upload tool, and was unable to match the source code to the .gcov report. The .codecov.yml config file was modified to adjust for this path change, and should now correctly allow coverage to be reported alongside the file. (The GitHub Actions app likely makes this adjustment, but we need to do it manually since we upload directly to Codecov.io.)
1 parent 96a91f5 commit 850296d

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

.codecov.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ coverage:
88
default:
99
threshold: 100%
1010
base: parent
11+
12+
fixes:
13+
- "MOM6/::"

.github/workflows/coverage.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,11 @@ jobs:
1919

2020
- uses: ./.github/actions/testing-setup
2121

22-
- name: Compile file parser unit tests
23-
run: make -j build/unit/test_MOM_file_parser
24-
25-
- name: Run file parser unit tests
26-
run: make run.cov.unit
27-
28-
- name: Compile unit testing
22+
- name: Compile unit tests
2923
run: make -j build.unit
3024

31-
- name: Run (single processor) unit tests
32-
run: make run.unit
25+
- name: Run unit tests
26+
run: make run.cov.unit
3327

3428
- name: Report unit test coverage to CI
3529
run: make report.cov.unit
@@ -40,7 +34,7 @@ jobs:
4034
run: make -j build/cov/MOM6
4135

4236
- name: Run coverage tests
43-
run: make -j -k run.cov
37+
run: make -k run.cov
4438

4539
- name: Report coverage to CI
4640
run: make report.cov

.testing/Makefile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ build.prof: $(foreach b,opt opt_target,$(BUILD)/$(b)/MOM6)
222222
# Compiler flags
223223

224224
# .testing dependencies
225-
# TODO: We should probably build TARGET with the FMS that it was configured
226-
# to use. But for now we use the same FMS over all builds.
227225
FCFLAGS_DEPS = -I$(abspath $(DEPS)/include)
228226
LDFLAGS_DEPS = -L$(abspath $(DEPS)/lib)
229227
PATH_DEPS = PATH="${PATH}:$(abspath $(DEPS)/bin)"
@@ -661,7 +659,7 @@ test.summary:
661659

662660
# NOTE: Using file parser gcov report as a proxy for test completion
663661
.PHONY: run.cov.unit
664-
run.cov.unit: $(BUILD)/unit/MOM_file_parser_tests.F90.gcov
662+
run.cov.unit: $(foreach t,$(UNIT_EXECS),$(BUILD)/unit/$(t).F90.gcov)
665663

666664
.PHONY: build.unit
667665
build.unit: $(foreach f, $(UNIT_EXECS), $(BUILD)/unit/$(f))
@@ -702,6 +700,7 @@ $(WORK)/unit/%.out: $(BUILD)/unit/%
702700
@mkdir -p $(@D)
703701
cd $(@D) ; $(TIME) $(MPIRUN) -n 1 $(abspath $<) 2> >(tee $*.err) > $*.out
704702

703+
# The file parser uses a separate rule to support two-core tests.
705704
$(WORK)/unit/test_MOM_file_parser.out: $(BUILD)/unit/test_MOM_file_parser
706705
if [ $(REPORT_COVERAGE) ]; then \
707706
find $(BUILD)/unit -name *.gcda -exec rm -f '{}' \; ; \
@@ -721,15 +720,13 @@ $(WORK)/unit/test_MOM_file_parser.out: $(BUILD)/unit/test_MOM_file_parser
721720
cat p2.test_MOM_file_parser.err | tail -n 100 ; \
722721
)
723722

724-
# NOTE: .gcov actually depends on .gcda, but .gcda is produced with std.out
725-
# TODO: Replace $(WORK)/unit/std.out with *.gcda?
726-
$(BUILD)/unit/MOM_file_parser_tests.F90.gcov: $(WORK)/unit/test_MOM_file_parser.out
723+
$(BUILD)/unit/test_%.F90.gcov: $(WORK)/unit/test_%.out
727724
cd $(@D) \
728725
&& gcov -b *.gcda > gcov.unit.out
729726
find $(@D) -name "*.gcov" -exec sed -i -r 's/^( *[0-9]*)\*:/ \1:/g' {} \;
730727

731728
.PHONY: report.cov.unit
732-
report.cov.unit: $(BUILD)/unit/MOM_file_parser_tests.F90.gcov codecov
729+
report.cov.unit: $(foreach t,$(UNIT_EXECS),$(BUILD)/unit/$(t).F90.gcov) codecov
733730
./codecov $(CODECOV_TOKEN_ARG) -R $(BUILD)/unit -f "*.gcov" -Z -n "Unit tests" \
734731
> $(BUILD)/unit/codecov.out \
735732
2> $(BUILD)/unit/codecov.err \

0 commit comments

Comments
 (0)