-
Notifications
You must be signed in to change notification settings - Fork 32
94 lines (81 loc) · 3.54 KB
/
code_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
name: pg_tle code coverage CI
on:
workflow_dispatch:
jobs:
test:
defaults:
run:
shell: sh
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
version: [master, REL_17_STABLE, REL_16_STABLE, REL_15_STABLE, REL_14_STABLE, REL_13_STABLE, REL_12_STABLE, REL_11_STABLE]
runs-on: ${{ matrix.os }}
timeout-minutes: 120
steps:
- name: Checkout pg_tle
uses: actions/checkout@v4
with:
path: pg_tle
- name: Checkout Postgres
run: |
sudo apt-get -y -q install libperl-dev libipc-run-perl lcov libreadline-dev
git clone --branch ${{ matrix.version }} https://github.com/postgres/postgres.git
- name: Build Postgres
run: |
cd postgres
sh configure --prefix=$PWD/inst/ --enable-debug --enable-cassert --enable-tap-tests --with-openssl --with-perl --enable-coverage CFLAGS="-ggdb3 -O0"
make -j4 install
# Install extensions
make -C contrib install
- name: Build pg_tle
run: |
cd pg_tle
export PATH=$GITHUB_WORKSPACE/postgres/inst/bin:"$PATH"
make PROFILE="-Wall -Wmissing-prototypes -Werror=maybe-uninitialized -Werror" -j4 all install
- name: Run pg_tle tests
run: |
export PATH=$GITHUB_WORKSPACE/postgres/inst/bin:"$PATH"
postgres/inst/bin/initdb -D postgres/inst/bin/data
echo "shared_preload_libraries = 'pg_tle'" >> postgres/inst/bin/data/postgresql.conf
postgres/inst/bin/pg_ctl -D postgres/inst/bin/data -l postgres/inst/bin/logfile start
cd pg_tle
PERL5LIB="postgres/src/test/perl:${PERL5LIB}" make installcheck
- name: Show pg_tle core tests diff
if: ${{ failure() }}
run: |
cat pg_tle/regression.diffs
- name: Upload test artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: test-artifact-${{ matrix.os }}-${{ matrix.version }}
path: |
pg_tle/regression.diffs
pg_tle/tmp_check/log
retention-days: 1
- name: Collect code coverage info
if: ${{ always() }}
run: |
export PATH=$GITHUB_WORKSPACE/postgres/inst/bin:"$PATH"
# The steps to run code coverage are referred from
# https://www.postgresql.org/message-id/CAB7nPqQkUyN_A88Rw4iAaYax%3Dm4DwNPwoScBVyb3ihmfks8uDg%40mail.gmail.com
# and https://www.postgresql.org/docs/current/regress-coverage.html
cd pg_tle
make coverage-html abs_top_srcdir=$(pwd)
/usr/bin/lcov --gcov-tool /usr/bin/gcov -q --no-external -c -i -d . -d ./ -o lcov_base.info
/usr/bin/lcov --gcov-tool /usr/bin/gcov -q --no-external -c -d . -d ./ -o lcov_test.info
rm -rf coverage
/usr/bin/genhtml --legend -o coverage-${{ matrix.version }} --title='pg_tle on ${{ matrix.version }}' --num-spaces=4 lcov_base.info lcov_test.info
# Clean up steps. They are here as demonstration for developers
# running code coverage indvidually.
# rm -rf coverage coverage-${{ matrix.version }} coverage-html-stamp
# rm -f src/*.gcda src/*.gcno src/lcov*.info src/*.gcov src/.*.gcov src/*.gcov.out lcov_base.info lcov_test.info
- name: Upload code coverage artifacts
uses: actions/upload-artifact@v4
with:
name: code-coverage-artifact-${{ matrix.os }}-${{ matrix.version }}
path: |
pg_tle/coverage-${{ matrix.version }}
retention-days: 1