File tree Expand file tree Collapse file tree 4 files changed +122
-0
lines changed
Expand file tree Collapse file tree 4 files changed +122
-0
lines changed Original file line number Diff line number Diff line change 1+ os :
2+ - linux
3+
4+ sudo : required
5+ dist : trusty
6+
7+ language : c
8+
9+ services :
10+ - docker
11+
12+ install :
13+ - sed -e 's/${CHECK_CODE}/'${CHECK_CODE}/g -e 's/${PG_VERSION}/'${PG_VERSION}/g Dockerfile.tmpl > Dockerfile
14+ - docker-compose build
15+
16+ script :
17+ - docker-compose run tests
18+
19+ env :
20+ - PG_VERSION=9.6 CHECK_CODE=clang
21+ - PG_VERSION=9.6 CHECK_CODE=cppcheck
22+ - PG_VERSION=9.6 CHECK_CODE=false
23+ - PG_VERSION=10 CHECK_CODE=clang
24+ - PG_VERSION=10 CHECK_CODE=cppcheck
25+ - PG_VERSION=10 CHECK_CODE=false
26+ - PG_VERSION=11 CHECK_CODE=clang
27+ - PG_VERSION=11 CHECK_CODE=cppcheck
28+ - PG_VERSION=11 CHECK_CODE=false
Original file line number Diff line number Diff line change 1+ FROM postgres:${PG_VERSION}-alpine
2+
3+ ENV LANG=C.UTF-8 PGDATA=/pg/data
4+
5+ RUN if [ "${CHECK_CODE}" = "clang" ] ; then \
6+ echo 'http://dl-3.alpinelinux.org/alpine/edge/main' > /etc/apk/repositories; \
7+ apk --no-cache add clang-analyzer make musl-dev gcc; \
8+ fi
9+
10+ RUN if [ "${CHECK_CODE}" = "cppcheck" ] ; then \
11+ apk --no-cache add cppcheck --repository http://dl-cdn.alpinelinux.org/alpine/v3.6/community; \
12+ fi
13+
14+ RUN if [ "${CHECK_CODE}" = "false" ] ; then \
15+ echo 'http://dl-3.alpinelinux.org/alpine/edge/main' > /etc/apk/repositories; \
16+ apk --no-cache add curl python3 gcc make musl-dev;\
17+ fi
18+
19+ RUN mkdir -p /pg/data && \
20+ mkdir /pg/src && \
21+ chown postgres:postgres ${PGDATA} && \
22+ chmod a+rwx /usr/local/lib/postgresql && \
23+ chmod a+rwx /usr/local/share/postgresql/extension
24+
25+ ADD . /pg/src
26+ WORKDIR /pg/src
27+ RUN chmod -R go+rwX /pg/src
28+ USER postgres
29+ ENTRYPOINT PGDATA=${PGDATA} CHECK_CODE=${CHECK_CODE} bash run_tests.sh
Original file line number Diff line number Diff line change 1+ tests :
2+ build : .
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # This is a main testing script for:
4+ # * regression tests
5+ # Copyright (c) 2018, Postgres Professional
6+
7+ set -eux
8+
9+ echo CHECK_CODE=$CHECK_CODE
10+
11+ status=0
12+
13+ # perform code analysis if necessary
14+ if [ " $CHECK_CODE " = " clang" ]; then
15+ scan-build --status-bugs make USE_PGXS=1 || status=$?
16+ exit $status
17+
18+ elif [ " $CHECK_CODE " = " cppcheck" ]; then
19+ cppcheck \
20+ --template " {file} ({line}): {severity} ({id}): {message}" \
21+ --enable=warning,portability,performance \
22+ --suppress=redundantAssignment \
23+ --suppress=uselessAssignmentPtrArg \
24+ --suppress=literalWithCharPtrCompare \
25+ --suppress=incorrectStringBooleanError \
26+ --std=c99 * .c * .h 2> cppcheck.log
27+
28+ if [ -s cppcheck.log ]; then
29+ cat cppcheck.log
30+ status=1 # error
31+ fi
32+
33+ exit $status
34+ fi
35+
36+ # don't forget to "make clean"
37+ make USE_PGXS=1 clean
38+
39+ # initialize database
40+ initdb
41+
42+ # build extension
43+ make USE_PGXS=1 install
44+
45+ # check build
46+ status=$?
47+ if [ $status -ne 0 ]; then exit $status ; fi
48+
49+ echo " port = 55435" >> $PGDATA /postgresql.conf
50+ pg_ctl start -l /tmp/postgres.log -w
51+
52+ # check startup
53+ status=$?
54+ if [ $status -ne 0 ]; then cat /tmp/postgres.log; fi
55+
56+ # run regression tests
57+ export PG_REGRESS_DIFF_OPTS=" -w -U3" # for alpine's diff (BusyBox)
58+ PGPORT=55435 make USE_PGXS=1 installcheck || status=$?
59+
60+ # show diff if it exists
61+ if test -f regression.diffs; then cat regression.diffs; fi
62+
63+ exit $status
You can’t perform that action at this time.
0 commit comments