Skip to content

Commit 9cb3bec

Browse files
Generate code coverage reports (#649)
1 parent b812d71 commit 9cb3bec

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

.github/workflows/coverage.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Coverage
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
CLASSPATH: ":/usr/lib/opensourcecobol4j/libcobj.jar"
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/setup-java@v4
19+
with:
20+
distribution: 'temurin'
21+
java-version: '21'
22+
23+
- name: Install dependencies on Ubuntu
24+
run: |
25+
sudo apt-get update -y
26+
sudo apt-get install -y build-essential gettext autoconf bison flex gcovr
27+
28+
- name: Checkout opensource COBOL 4J
29+
uses: actions/checkout@v4
30+
31+
- name: Install opensource COBOL 4J
32+
run: |
33+
./configure --prefix=/usr/ CFLAGS='-fprofile-arcs -ftest-coverage'
34+
make
35+
sudo make install
36+
37+
- name: Run NIST test
38+
working-directory: tests/cobol85
39+
run: make test || true
40+
41+
- name: Run other tests
42+
working-directory: tests
43+
run: |
44+
tests=("command-line-options" "data-rep" "i18n_sjis" "jp-compat" "run" "syntax" "cobj-idx" "misc")
45+
for test in "${tests[@]}"; do
46+
./"$test" || true
47+
done
48+
49+
- name: Generate a coverage report
50+
working-directory: cobj
51+
run: |
52+
gcov -l ./*.gcda
53+
gcovr -r . \
54+
-e cobj-parser -e cobj-scanner -e cobj-pplex -e cobj-ppparse \
55+
-e parser.c -e parser.y -e scanner.l -e scanner.c -e pplex.l -e pplex.c -e ppparse.y -e ppparse.c \
56+
-e flag-help.def -e warning-help.def -e warning.def \
57+
--html-details --html-self-contained --html -o report.html --txt-metric=branch
58+
mkdir -p coverage-report
59+
cp ./*.html coverage-report
60+
61+
- name: Archive a coverage report
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: code-coverage-report
65+
path: cobj/coverage-report/

.github/workflows/push.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ jobs:
4040
os: ${{ matrix.os }}
4141
configure-args: --enable-utf8
4242

43+
coverage:
44+
needs: check-workflows
45+
if: github.ref == 'refs/heads/develop'
46+
uses: ./.github/workflows/coverage.yml
47+
4348
run-test-other:
4449
needs: build
4550
strategy:

0 commit comments

Comments
 (0)