Skip to content

Commit 12b3eb8

Browse files
Merge pull request #42 from yutaro-sakamoto/coverage
* Make a coverage report of C programs in ocesql/ in CI * Refine workflow files sligtly
2 parents 73ffdf5 + be3218b commit 12b3eb8

File tree

3 files changed

+136
-4
lines changed

3 files changed

+136
-4
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
container:
2828
image: ${{ matrix.os }}
2929

30-
# Start PostgreSQL 9.6 server
3130
services:
31+
# Start PostgreSQL 9.6 server
3232
postgres9_6:
3333
image: postgres:9.6
3434
ports:
@@ -44,7 +44,7 @@ jobs:
4444
--health-timeout 5s
4545
--health-retries 5
4646
47-
# Start PostgreSQL 15 server
47+
# Start PostgreSQL 15 server
4848
postgres15:
4949
image: postgres:15
5050
ports:
@@ -94,7 +94,6 @@ jobs:
9494

9595
# Install JDBC
9696
- name: Install JDBC
97-
if: steps.java_lib_cache_id.outputs.cache-hit != 'true'
9897
run: |
9998
mkdir -p $COBOL4J_LIB_DIR $OCESQL4J_LIB_DIR
10099
curl -L -o $COBOL4J_SQLITE_JDBC_PATH https://github.com/xerial/sqlite-jdbc/releases/download/3.36.0.3/sqlite-jdbc-3.36.0.3.jar
@@ -114,7 +113,6 @@ jobs:
114113
./configure --prefix=/usr/
115114
make
116115
make install
117-
cd ../
118116
119117
# Build and Install Open COBOL ESQL 4J
120118
- name: Install Open COBOL ESQL 4J
@@ -139,6 +137,7 @@ jobs:
139137
cp ../.github/workflows/db-settings/embed_db_info_postgresql_15.sh embed_db_info.sh
140138
make test
141139
140+
# Create an issue if one or more tests fail in scheduled tests
142141
create-issue-on-failure:
143142
needs: Open-COBOL-ESQL-4j-tests
144143
if: failure() && github.event_name == 'schedule'

.github/workflows/coverage.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [opened, reopened, review_requested, synchronize]
7+
workflow_dispatch:
8+
9+
env:
10+
COBOL4J_LIB_DIR: /usr/lib/opensourcecobol4j
11+
COBOL4J_SQLITE_JDBC_PATH: /usr/lib/opensourcecobol4j/sqlite.jar
12+
COBOL4J_LIBCOBJ_JAR_PATH: /usr/lib/opensourcecobol4j/libcobj.jar
13+
OCESQL4J_LIB_DIR: /usr/lib/Open-COBOL-ESQL-4j
14+
OCESQL4J_POSTGRESQL_JDBC_PATH: /usr/lib/Open-COBOL-ESQL-4j/postgresql.jar
15+
OCESQL4J_OCESQL4J_JAR_PATH: /usr/lib/Open-COBOL-ESQL-4j/ocesql4j.jar
16+
CLASSPATH: ":/usr/lib/opensourcecobol4j/sqlite.jar:/usr/lib/opensourcecobol4j/libcobj.jar:/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar:/usr/lib/Open-COBOL-ESQL-4j/ocesql4j.jar"
17+
18+
jobs:
19+
make-coverage-report:
20+
runs-on: ubuntu-latest
21+
22+
# Start PostgreSQL 15 server
23+
services:
24+
postgres15:
25+
image: postgres:15
26+
ports:
27+
- 5432:5432
28+
env:
29+
POSTGRES_PASSWORD: password
30+
POSTGRES_USER: main_user
31+
POSTGRES_DB: testdb
32+
POSTGRES_HOST_AUTH_METHOD: 'trust'
33+
options: >-
34+
--health-cmd pg_isready
35+
--health-interval 10s
36+
--health-timeout 5s
37+
--health-retries 5
38+
39+
steps:
40+
# Install dependencies
41+
- name: Install dependencies on Ubuntu 22.04
42+
run: |
43+
sudo apt update -y
44+
sudo apt install -y build-essential bison flex gettext texinfo automake autoconf curl gcovr
45+
46+
# Setup JDK
47+
- name: Setup JDK
48+
uses: actions/setup-java@v3
49+
with:
50+
distribution: zulu
51+
java-version: 11
52+
53+
# Setup sbt
54+
- name: Setup sbt
55+
uses: olafurpg/setup-scala@v11
56+
with:
57+
java-version: [email protected]
58+
59+
# Checkout
60+
- name: Checkout Open-COBOL-ESQL-4j
61+
uses: actions/checkout@v3
62+
63+
# Install JDBC
64+
- name: Install JDBC
65+
run: |
66+
sudo mkdir -p $COBOL4J_LIB_DIR $OCESQL4J_LIB_DIR
67+
sudo curl -L -o $COBOL4J_SQLITE_JDBC_PATH https://github.com/xerial/sqlite-jdbc/releases/download/3.36.0.3/sqlite-jdbc-3.36.0.3.jar
68+
sudo curl -L -o $OCESQL4J_POSTGRESQL_JDBC_PATH https://jdbc.postgresql.org/download/postgresql-42.2.24.jre6.jar
69+
70+
# Checkout opensource COBOL 4J
71+
- name: Checkout opensourcecobol 4J
72+
uses: actions/checkout@v3
73+
with:
74+
repository: opensourcecobol/opensourcecobol4j
75+
path: opensourcecobol4j
76+
77+
# Install opensource COBOL 4J
78+
- name: Install opensource COBOL 4J
79+
run: |
80+
cd opensourcecobol4j
81+
./configure --prefix=/usr/
82+
make
83+
sudo make install
84+
85+
# Build and Install Open COBOL ESQL 4J
86+
- name: Install Open COBOL ESQL 4J
87+
run: |
88+
cp $OCESQL4J_POSTGRESQL_JDBC_PATH dblibj/lib
89+
cp $COBOL4J_LIBCOBJ_JAR_PATH dblibj/lib
90+
sh configure CFLAGS='-fprofile-arcs -ftest-coverage' --prefix=/usr/
91+
make
92+
sudo make install
93+
94+
# Run Autotest for PostgreSQL 15
95+
- name: Run tests for PostgreSQL 15
96+
run: |
97+
cd tests
98+
cp ../.github/workflows/db-settings/embed_db_info_postgresql_15_coverage.sh embed_db_info.sh
99+
make test
100+
101+
# Make a coverage report
102+
- name: Make a coverage report
103+
run: |
104+
cd ocesql
105+
gcov -l *.gcda
106+
gcovr -r . --html -o report.html
107+
mkdir coverage-report
108+
cp *.gcno *.gcda *.gcov report.html coverage-report
109+
110+
# Upload a coverage report
111+
- name: Archive a coverage report
112+
uses: actions/upload-artifact@v3
113+
with:
114+
name: code-coverage-report
115+
path: ocesql/coverage-report/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Database Settings ----------
2+
DB_NAME=testdb
3+
DB_HOST=localhost
4+
DB_PORT=5432
5+
DB_USER=main_user
6+
DB_PASSWORD=password
7+
# ----------------------------
8+
9+
TEMP_FILE=$(mktemp)
10+
11+
cat $1 |
12+
sed -e "s/<|DB_NAME|>/${DB_NAME}/g" |
13+
sed -e "s/<|DB_HOST|>/${DB_HOST}/g" |
14+
sed -e "s/<|DB_PORT|>/${DB_PORT}/g" |
15+
sed -e "s/<|DB_USER|>/${DB_USER}/g" |
16+
sed -e "s/<|DB_PASSWORD|>/${DB_PASSWORD}/g" > ${TEMP_FILE}
17+
18+
mv ${TEMP_FILE} $1

0 commit comments

Comments
 (0)