Skip to content

Commit 4781212

Browse files
committed
Merge branch 'ci-update'
Update CI to use newer build systems. See SOCI#1007.
2 parents 86359f4 + 1fd22cf commit 4781212

File tree

10 files changed

+50
-42
lines changed

10 files changed

+50
-42
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ on:
2222

2323
jobs:
2424
build:
25-
runs-on: ${{ matrix.runner || 'ubuntu-18.04' }}
25+
runs-on: ${{ matrix.runner || 'ubuntu-22.04' }}
2626
name: ${{ matrix.name }}
2727
strategy:
2828
fail-fast: false
@@ -31,18 +31,16 @@ jobs:
3131
# Note: the jobs are ordered in the order of decreasing running
3232
# time, as this should minimize the total run-time of all jobs.
3333
- backend: postgresql
34-
runner: macos-10.15
34+
runner: macos-11
3535
name: PostgreSQL macOS
3636
- backend: oracle
3737
name: Oracle 11
3838
no_boost: true
3939
- backend: valgrind
40-
# This one dies under Xenial due to a bug in Valgrind and reports
41-
# errors under Focal in MySQL test, so run it under Bionic where
42-
# it just happens to work.
43-
runner: ubuntu-18.04
4440
name: Valgrind
4541
- backend: odbc
42+
# There are many leak reports under Ubuntu 22.04, see #1008.
43+
runner: ubuntu-18.04
4644
name: ODBC
4745
- backend: firebird
4846
name: Firebird
@@ -51,12 +49,12 @@ jobs:
5149
- backend: mysql
5250
name: MySQL
5351
- backend: sqlite3
54-
runner: macos-10.15
52+
runner: macos-11
5553
name: SQLite3 macOS
5654
- backend: sqlite3
5755
name: SQLite3
5856
- backend: empty
59-
runner: macos-10.15
57+
runner: macos-11
6058
name: Empty macOS
6159
- backend: empty
6260
name: Empty
@@ -77,7 +75,7 @@ jobs:
7775

7876
steps:
7977
- name: Checkout
80-
uses: actions/checkout@v2
78+
uses: actions/checkout@v3
8179

8280
- name: Set environment variables
8381
run: |
@@ -114,8 +112,6 @@ jobs:
114112
115113
- name: Install dependencies under Linux
116114
if: runner.os == 'Linux'
117-
env:
118-
SOCI_CI_PACKAGES: cmake
119115
run: ./scripts/ci/install.sh
120116

121117
- name: Prepare for build

.github/workflows/codeql.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030

3131
steps:
3232
- name: Checkout repository
33-
uses: actions/checkout@v2
33+
uses: actions/checkout@v3
3434

3535
- name: Initialize CodeQL
36-
uses: github/codeql-action/init@v1
36+
uses: github/codeql-action/init@v2
3737
with:
3838
languages: cpp
3939
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -51,8 +51,6 @@ jobs:
5151
set_env_var SOCI_SOURCE_DIR $GITHUB_WORKSPACE
5252
5353
- name: Install dependencies
54-
env:
55-
SOCI_CI_PACKAGES: cmake
5654
run: ./scripts/ci/install.sh
5755

5856
- name: Prepare for build
@@ -62,4 +60,4 @@ jobs:
6260
run: ./scripts/ci/build.sh
6361

6462
- name: Perform CodeQL Analysis
65-
uses: github/codeql-action/analyze@v1
63+
uses: github/codeql-action/analyze@v2

scripts/ci/before_build_mysql.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ mysql --version
1717
mysql -u root ${SOCI_MYSQL_PASSWORD_OPT} -e "CREATE DATABASE soci_test;"
1818
mysql -u root ${SOCI_MYSQL_PASSWORD_OPT} -e "GRANT ALL PRIVILEGES ON soci_test.* TO '${SOCI_MYSQL_USER}'@'%';";
1919

20+
# This is necessary for MySQL stored procedure unit test to work.
21+
mysql -u root ${SOCI_MYSQL_PASSWORD_OPT} -e "SET GLOBAL log_bin_trust_function_creators=1";
22+
2023
echo 'Testing connection to the database:'
2124
echo 'SELECT USER();' | mysql --database=soci_test

scripts/ci/build_empty.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ fi
3030
if [[ "$TEST_RELEASE_PACKAGE" == "YES" ]] && [[ "$SOCI_CI_BRANCH" =~ ^release/[3-9]\.[0-9]$ ]]; then
3131
ME=`basename "$0"`
3232

33-
sudo apt-get update -qq -y
34-
sudo apt-get install -qq -y python3-venv
33+
run_apt update
34+
run_apt install python3-venv
3535

3636
SOCI_VERSION=$(cat "$SOCI_SOURCE_DIR/include/soci/version.h" | grep -Po "(.*#define\s+SOCI_LIB_VERSION\s+.+)\K([3-9]_[0-9]_[0-9])" | sed "s/_/\./g")
3737
if [[ ! "$SOCI_VERSION" =~ ^[4-9]\.[0-9]\.[0-9]$ ]]; then

scripts/ci/common.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
#!/usr/bin/env bash
1+
#!/bin/sh
22
# Common definitions used by SOCI build scripts in CI builds
33
#
44
# Copyright (c) 2013 Mateusz Loskot <mateusz@loskot.net>
55
#
6+
# Note that this is a /bin/sh script because it is used from install.sh
7+
# which installs bash under FreeBSD and so we can't rely on bash being
8+
# available yet.
69

710
# Stop on all errors.
811
set -e
912

10-
if [[ "$SOCI_CI" != "true" ]] ; then
13+
if [ "$SOCI_CI" != "true" ] ; then
1114
echo "Running this script is only useful in the CI builds"
1215
exit 1
1316
fi
1417

1518
backend_settings=${SOCI_SOURCE_DIR}/scripts/ci/${SOCI_CI_BACKEND}.sh
1619
if [ -f ${backend_settings} ]; then
17-
source ${backend_settings}
20+
. ${backend_settings}
1821
fi
1922

2023
#
@@ -33,10 +36,6 @@ case `uname` in
3336
num_cpus=1
3437
esac
3538

36-
if [[ ${num_cpus} != 1 ]]; then
37-
((num_cpus++))
38-
fi
39-
4039
# Directory where the build happens.
4140
#
4241
# Note that the existing commands suppose that the build directory is an
@@ -52,7 +51,7 @@ SOCI_COMMON_CMAKE_OPTIONS='
5251
-DSOCI_TESTS=ON
5352
'
5453

55-
if [[ -n ${WITH_BOOST} ]]; then
54+
if [ -n "${WITH_BOOST}" ]; then
5655
SOCI_COMMON_CMAKE_OPTIONS="$SOCI_COMMON_CMAKE_OPTIONS -DWITH_BOOST=${WITH_BOOST}"
5756
fi
5857

@@ -77,6 +76,12 @@ tmstamp()
7776
echo -n "[$(date '+%H:%M:%S')]" ;
7877
}
7978

79+
run_apt()
80+
{
81+
# Disable some (but not all) output.
82+
sudo apt-get -q -y -o=Dpkg::Use-Pty=0 "$@"
83+
}
84+
8085
run_make()
8186
{
8287
make -j $num_cpus
@@ -86,7 +91,7 @@ run_test()
8691
{
8792
# The example project doesn't have any tests, but otherwise their absence
8893
# is an error and means that something has gone wrong.
89-
if [[ "$BUILD_EXAMPLES" == "YES" ]]; then
94+
if [ "$BUILD_EXAMPLES" == "YES" ]; then
9095
no_tests_action=ignore
9196
else
9297
no_tests_action=error

scripts/ci/install.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
#
44
# Copyright (c) 2013 Mateusz Loskot <mateusz@loskot.net>
55
#
6-
# Note that this is a /bin/sh script because it runs to install bash under
7-
# FreeBSD and so does not include common.sh, which uses bash.
8-
set -e
6+
# Note that this is a /bin/sh script because bash is not installed yet under
7+
# FreeBSD.
8+
. ${SOCI_SOURCE_DIR}/scripts/ci/common.sh
99

1010
case "$(uname)" in
1111
Linux)
12-
packages_to_install="${SOCI_CI_PACKAGES} libc6-dbg"
12+
packages_to_install="cmake libc6-dbg"
1313
if [ "${WITH_BOOST}" != OFF ]; then
1414
packages_to_install="$packages_to_install libboost-dev libboost-date-time-dev"
1515
fi
1616

17+
# Get rid of the repositories that we don't need: not only this takes
18+
# extra time to update, but it also often fails with "Mirror sync in
19+
# progress" errors.
20+
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
21+
1722
codename=$(lsb_release --codename --short)
1823
# Enable the `-dbgsym` repositories.
1924
echo "deb http://ddebs.ubuntu.com ${codename} main restricted universe multiverse
@@ -22,10 +27,10 @@ case "$(uname)" in
2227

2328
# Import the debug symbol archive signing key from the Ubuntu server.
2429
# Note that this command works only on Ubuntu 18.04 LTS and newer.
25-
sudo apt-get install -qq -y ubuntu-dbgsym-keyring
30+
run_apt install ubuntu-dbgsym-keyring
2631

27-
sudo apt-get update -qq -y
28-
sudo apt-get install -qq -y ${packages_to_install}
32+
run_apt update
33+
run_apt install ${packages_to_install}
2934
;;
3035

3136
FreeBSD)

scripts/ci/install_db2.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#
77
set -e
88
sudo bash -c 'echo "deb http://archive.canonical.com/ubuntu precise partner" >> /etc/apt/sources.list'
9-
sudo apt-get update -qq -y
10-
sudo apt-get install -qq -y db2exc
9+
run_apt update
10+
run_apt install db2exc
1111

1212
echo "Running db2profile and db2rmln"
1313
sudo /bin/sh -c '. ~db2inst1/sqllib/db2profile ; $DB2DIR/cfg/db2rmln'

scripts/ci/install_firebird.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#
66
source ${SOCI_SOURCE_DIR}/scripts/ci/common.sh
77

8-
case $(lsb_release -sc) in
8+
codename=$(lsb_release -sc)
9+
case "$codename" in
910
trusty | xenial)
1011
firebird_version=2.5
1112
firebird_server_package=firebird2.5-super
@@ -17,18 +18,18 @@ EOF
1718
)
1819
;;
1920

20-
focal | bionic)
21+
jammy | focal | bionic)
2122
firebird_version=3.0
2223
firebird_server_package=firebird3.0-server
2324
firebird_server_service=firebird3.0
2425
;;
2526

2627
*)
27-
echo "*** Can't install Firebird: unknown Ubuntu version! ***"
28+
echo "*** Can't install Firebird: unknown Ubuntu version $codename! ***"
2829
exit 1
2930
esac
3031

31-
sudo apt-get install -qq expect ${firebird_server_package} firebird-dev
32+
run_apt install expect ${firebird_server_package} firebird-dev
3233

3334
# Default frontend is "noninteractive", which prevents dpkg-reconfigure from
3435
# asking anything at all, so change it. Notice that we must do it via

scripts/ci/install_odbc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
source ${SOCI_SOURCE_DIR}/scripts/ci/common.sh
77

8-
sudo apt-get install -qq \
8+
run_apt install \
99
tar bzip2 \
1010
unixodbc unixodbc-dev \
1111
odbc-postgresql odbc-postgresql-dbgsym

scripts/ci/install_valgrind.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
#
66
source ${SOCI_SOURCE_DIR}/scripts/ci/common.sh
77

8-
sudo apt-get install -qq valgrind
8+
run_apt install valgrind

0 commit comments

Comments
 (0)