Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Consolidate unit test rules, codecov pathfix #754

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ coverage:
default:
threshold: 100%
base: parent

fixes:
- "MOM6/::"
14 changes: 4 additions & 10 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,11 @@ jobs:

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

- name: Compile file parser unit tests
run: make -j build/unit/test_MOM_file_parser

- name: Run file parser unit tests
run: make run.cov.unit

- name: Compile unit testing
- name: Compile unit tests
run: make -j build.unit

- name: Run (single processor) unit tests
run: make run.unit
- name: Run unit tests
run: make run.cov.unit

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

- name: Run coverage tests
run: make -j -k run.cov
run: make -k run.cov

- name: Report coverage to CI
run: make report.cov
Expand Down
11 changes: 4 additions & 7 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ build.prof: $(foreach b,opt opt_target,$(BUILD)/$(b)/MOM6)
# Compiler flags

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

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

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

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

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

.PHONY: report.cov.unit
report.cov.unit: $(BUILD)/unit/MOM_file_parser_tests.F90.gcov codecov
report.cov.unit: $(foreach t,$(UNIT_EXECS),$(BUILD)/unit/$(t).F90.gcov) codecov
./codecov $(CODECOV_TOKEN_ARG) -R $(BUILD)/unit -f "*.gcov" -Z -n "Unit tests" \
> $(BUILD)/unit/codecov.out \
2> $(BUILD)/unit/codecov.err \
Expand Down