-
Notifications
You must be signed in to change notification settings - Fork 9
103 lines (103 loc) · 5.01 KB
/
coverage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
name: coverage
on:
workflow_run:
workflows: ['format']
types:
- completed
jobs:
build:
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- name: coverage-gcc
ar: /usr/bin/ar
cc: /usr/bin/gcc-12
cxx: /usr/bin/g++-12
ranlib: /usr/bin/ranlib
- name: coverage-clang
ar: /usr/bin/llvm-ar-14
cc: /usr/bin/clang-14
cxx: /usr/bin/clang++-14
ranlib: /usr/bin/llvm-ranlib-14
steps:
- name: Stop if format failed
if: ${{ github.event.workflow_run.conclusion != 'success' }}
run: |
echo ${{ github.event.workflow_run.conclusion }}
exit 1
- uses: bansan85/action-workflow_run-status@main
env:
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
- uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_commit.id }}
- name: Install SSH key
if: ${{ github.event.workflow_run.head_branch == 'master' }}
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.GITHUBCI_PRIVATE_KEY }}
known_hosts: localhost ssh-rsa ${{ secrets.GITHUBCI_KNOW_HOSTS }}
- name: Install 3rdparty
run: xargs -a config/apt-get.txt sudo apt-get install -yq
- name: Install gcc
if: contains(matrix.cc, 'gcc')
run: sudo apt-get install -yq g++-12 gcc-12 libdatetime-perl libdatetime-format-w3cdtf-perl libcapture-tiny-perl
- name: Install clang
if: contains(matrix.cc, 'clang')
run: sudo apt-get install -yq clang-14 llvm-14 tidy
- name: cmake
run: |
mkdir build
cmake -S . -B build -DBUILD_COVERAGE:BOOL=ON -DCMAKE_C_COMPILER="${{ matrix.cc }}" -DCMAKE_CXX_COMPILER="${{ matrix.cxx }}" -DCMAKE_AR="${{ matrix.ar }}" -DCMAKE_RANLIB="${{ matrix.ranlib }}"
cmake --build build/ --target all --config Debug
- name: ctest
run: |
cd build || exit 1
ctest -O test-result.xml --output-on-failure --verbose
cd .. || exit 1
- name: Coverage report gcc
if: contains(matrix.cc, 'gcc') && contains('master', github.event.workflow_run.head_branch)
run: |
git clone --depth 1 https://github.com/henry2cox/lcov.git -b diffcov_initial
./lcov/bin/lcov --capture --directory build --gcov-tool /usr/bin/gcov-12 --rc lcov_branch_coverage=1 --output-file build/coverage.info
./lcov/bin/lcov --remove build/coverage.info "/usr/include/*" --rc lcov_branch_coverage=1 -o build/coverage2.info
bash <(curl -s https://codecov.io/bash) -f build/coverage2.info
./lcov/bin/lcov --extract build/coverage.info "*/include/jessica/*" "*/src/backend/*" --rc lcov_branch_coverage=1 -o build/coverage_backend.info
bash <(curl -s https://codecov.io/bash) -f build/coverage_backend.info -F backend
./lcov/bin/genhtml --output-directory build/coverage --demangle-cpp --num-spaces 2 --sort --function-coverage --branch-coverage --legend build/coverage2.info
find build/coverage -name "*.html" -exec sed -i -r "s#headerValue""\>.*-.*-.* .*:.*:.*td#headerValue""></td#g" {} \;
- name: Coverage report clang
shell: bash
if: contains(matrix.cc, 'clang') && contains('master', github.event.workflow_run.head_branch)
run: |
shopt -s globstar dotglob
llvm-profdata-14 merge -output=code.profdata **/*.profraw
mkdir build/coverage
llvm-cov-14 show -use-color --format html -instr-profile=code.profdata ./build/test/backend/calc/geotechnical/test_calc_meyerhof -output-dir=build/coverage
find build/coverage -name "*.html" -exec tidy -i -m --doctype html5 --drop-empty-elements no {} \;
find build/coverage -name "*.html" -exec sed -i -r "s#Created: .*-.*-.* .*:.*h4#</h4#g" {} \;
- name: Publish test
if: ${{ github.event.workflow_run.head_branch == 'master' }}
env:
COMMIT_MESSAGE: ${{ github.event.workflow_run.head_commit.message }}
run: |
eval `ssh-agent`
git clone --depth 1 ssh://[email protected]/bansan85/jessica-ci.git -b ${{ matrix.name }}
rm -Rf jessica-ci/*
cp -R build/coverage jessica-ci/
ssh-add ~/.ssh/id_rsa
gpg --version
gpg --quiet --batch --yes --decrypt --passphrase="${{ secrets.ENCRYPT_PASSWORD }}" --output .github/encrypted/github-ci-private.key .github/encrypted/github-ci-private.key.gpg
gpg --import .github/encrypted/github-ci-private.key
cd jessica-ci || exit 1
git config --global user.name "Github CI"
git config --global user.email "[email protected]"
git add .
if [ -n "$(git diff-index --name-only HEAD --)" ]; \
then \
git commit -S${{ secrets.GPG_KEY_ID }} -m "${COMMIT_MESSAGE//\"/\"\"}" -m "Update from bansan85/jessica@$GITHUB_SHA"; \
git push || { echo "Failure git push" && exit 1; } \
fi
cd .. || exit 1