mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-24 13:28:50 +01:00
cov : add Code Coverage and codecov.io integration (#2928)
* update .gitignore * makefile: add coverage support (lcov, gcovr) * add code-coverage workflow * update code coverage workflow * wun on ubuntu 20.04 * use gcc-8 * check why the job hang * add env vars * add LLAMA_CODE_COVERAGE=1 again * - add CODECOV_TOKEN - add missing make lcov-report * install lcov * update make file -pb flag * remove unused GGML_NITER from workflows * wrap coverage output files in COV_TARGETS
This commit is contained in:
parent
6460f758db
commit
afc43d5f82
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@ -18,7 +18,6 @@ on:
|
|||||||
env:
|
env:
|
||||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||||
GGML_NLOOP: 3
|
GGML_NLOOP: 3
|
||||||
GGML_NITER: 1
|
|
||||||
GGML_N_THREADS: 1
|
GGML_N_THREADS: 1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
36
.github/workflows/code-coverage.yml
vendored
Normal file
36
.github/workflows/code-coverage.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
name: Code Coverage
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
env:
|
||||||
|
GGML_NLOOP: 3
|
||||||
|
GGML_N_THREADS: 1
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install build-essential gcc-8 lcov
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: CC=gcc-8 make -j LLAMA_CODE_COVERAGE=1 tests
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: CC=gcc-8 make test
|
||||||
|
|
||||||
|
- name: Generate coverage report
|
||||||
|
run: |
|
||||||
|
make coverage
|
||||||
|
make lcov-report
|
||||||
|
|
||||||
|
- name: Upload coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
env:
|
||||||
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
with:
|
||||||
|
files: lcov-report/coverage.info
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -6,6 +6,10 @@
|
|||||||
*.exe
|
*.exe
|
||||||
*.dll
|
*.dll
|
||||||
*.log
|
*.log
|
||||||
|
*.gcov
|
||||||
|
*.gcno
|
||||||
|
*.gcda
|
||||||
|
*.dot
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.build/
|
.build/
|
||||||
.cache/
|
.cache/
|
||||||
@ -17,6 +21,9 @@
|
|||||||
.vs/
|
.vs/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
lcov-report/
|
||||||
|
gcovr-report/
|
||||||
|
|
||||||
build*/
|
build*/
|
||||||
out/
|
out/
|
||||||
tmp/
|
tmp/
|
||||||
|
22
Makefile
22
Makefile
@ -4,6 +4,9 @@ BUILD_TARGETS = main quantize quantize-stats perplexity embedding vdot train-tex
|
|||||||
# Binaries only useful for tests
|
# Binaries only useful for tests
|
||||||
TEST_TARGETS = tests/test-llama-grammar tests/test-grammar-parser tests/test-double-float tests/test-grad0 tests/test-opt tests/test-quantize-fns tests/test-quantize-perf tests/test-sampling tests/test-tokenizer-0-llama tests/test-tokenizer-0-falcon tests/test-tokenizer-1
|
TEST_TARGETS = tests/test-llama-grammar tests/test-grammar-parser tests/test-double-float tests/test-grad0 tests/test-opt tests/test-quantize-fns tests/test-quantize-perf tests/test-sampling tests/test-tokenizer-0-llama tests/test-tokenizer-0-falcon tests/test-tokenizer-1
|
||||||
|
|
||||||
|
# Code coverage output files
|
||||||
|
COV_TARGETS = *.gcno tests/*.gcno *.gcda tests/*.gcda *.gcov tests/*.gcov lcov-report gcovr-report
|
||||||
|
|
||||||
default: $(BUILD_TARGETS)
|
default: $(BUILD_TARGETS)
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@ -23,6 +26,18 @@ test:
|
|||||||
|
|
||||||
all: $(BUILD_TARGETS) $(TEST_TARGETS)
|
all: $(BUILD_TARGETS) $(TEST_TARGETS)
|
||||||
|
|
||||||
|
coverage: ## Run code coverage
|
||||||
|
gcov -pb tests/*.cpp
|
||||||
|
|
||||||
|
lcov-report: coverage ## Generate lcov report
|
||||||
|
mkdir -p lcov-report
|
||||||
|
lcov --capture --directory . --output-file lcov-report/coverage.info
|
||||||
|
genhtml lcov-report/coverage.info --output-directory lcov-report
|
||||||
|
|
||||||
|
gcovr-report: coverage ## Generate gcovr report
|
||||||
|
mkdir -p gcovr-report
|
||||||
|
gcovr --root . --html --html-details --output gcovr-report/coverage.html
|
||||||
|
|
||||||
ifndef UNAME_S
|
ifndef UNAME_S
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
endif
|
endif
|
||||||
@ -84,6 +99,11 @@ ifdef LLAMA_SERVER_VERBOSE
|
|||||||
MK_CPPFLAGS += -DSERVER_VERBOSE=$(LLAMA_SERVER_VERBOSE)
|
MK_CPPFLAGS += -DSERVER_VERBOSE=$(LLAMA_SERVER_VERBOSE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
ifdef LLAMA_CODE_COVERAGE
|
||||||
|
CXXFLAGS += -fprofile-arcs -ftest-coverage -dumpbase ''
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef LLAMA_DISABLE_LOGS
|
ifdef LLAMA_DISABLE_LOGS
|
||||||
CFLAGS += -DLOG_DISABLE_LOGS
|
CFLAGS += -DLOG_DISABLE_LOGS
|
||||||
CXXFLAGS += -DLOG_DISABLE_LOGS
|
CXXFLAGS += -DLOG_DISABLE_LOGS
|
||||||
@ -399,7 +419,7 @@ libllama.so: llama.o ggml.o $(OBJS)
|
|||||||
$(CXX) $(CXXFLAGS) -shared -fPIC -o $@ $^ $(LDFLAGS)
|
$(CXX) $(CXXFLAGS) -shared -fPIC -o $@ $^ $(LDFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -vf *.o tests/*.o *.so *.dll benchmark-matmult build-info.h $(BUILD_TARGETS) $(TEST_TARGETS)
|
rm -vrf *.o tests/*.o *.so *.dll benchmark-matmult build-info.h *.dot $(COV_TARGETS) $(BUILD_TARGETS) $(TEST_TARGETS)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Examples
|
# Examples
|
||||||
|
Loading…
Reference in New Issue
Block a user