Skip to content

Commit

Permalink
Add test coverage workflow.
Browse files Browse the repository at this point in the history
Add a new script, `.github/ubuntu/all-apt-prereqs.sh`, to install all apt
packages at once, and teach each of the engine scripts not to install apt
packages when `SKIP_DEPENDS` is set. Also have the Postgres an SQLite scripts
fall back on a default version to install if one is not passed. Remove the old
`prereqs.sh`. And have the SQLite script install SQLite into `/opt/sqlite` to be
more like the other engine installers, and have it and the Oracle script properly
share the `LD_LIBRARY_PATH` variable.

The new workflow, `.github/workflows/coverage.yml`, sets up all of the services
and clients, as well as modules for reporting coverage to Coveralls, and runs
the tests. Now that it uses a script installed in `local/bin`, teach all the
workflows to cache all of `local`, not just `local/lib`.

Get Oracle 21 tests working, too. Thanks to @gvenzl's help in
gvenzl/oci-oracle-xe#45.

Remove `.travis.yml` and references to it. Travis testing has not worked for a
while, and is no more.

Have `prove` run tests in parallel in 4 processes where it runs multiple tests,
so that builds finish more quickly.

Add build and release badges to README.md, and move most links to the bottom of
the text for better plain text legibility. Most of the GitHub badges don't
handle the Emoji correctly, but hopefully that will be addressed before long.

Finally, add a call to `disconnect` to `t/oracle.t` to prevent a segfault
that Devel::Cover seems to induce in DBD::Oracle (see perl5-dbi/DBD-Oracle#111).
  • Loading branch information
theory committed Nov 14, 2021
1 parent f0a9ab5 commit 8b38027
Show file tree
Hide file tree
Showing 27 changed files with 286 additions and 360 deletions.
11 changes: 11 additions & 0 deletions .github/ubuntu/all-apt-prereqs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -e

sudo apt-get update -qq
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq \
libicu-dev gettext aspell-en software-properties-common \
curl unixodbc-dev odbcinst unixodbc \
default-jre \
firebird-dev firebird3.0-utils \
mysql-client default-libmysqlclient-dev \
libarchive-tools
cat t/odbc/odbcinst.ini | sudo tee -a /etc/odbcinst.ini
8 changes: 5 additions & 3 deletions .github/ubuntu/exasol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ version=${1:-7}
echo $version

# Download dependencies.
sudo apt-get update -qq
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq curl unixodbc-dev odbcinst unixodbc default-jre
if [ -z "$SKIP_DEPENDS" ]; then
sudo apt-get update -qq
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq curl unixodbc-dev odbcinst unixodbc default-jre
cat t/odbc/odbcinst.ini | sudo tee -a /etc/odbcinst.ini
fi

# Prepare the configuration.
mkdir -p /opt/exasol
cat t/odbc/odbcinst.ini | sudo tee -a /etc/odbcinst.ini

# Download and unpack Exasol ODBC Driver & EXAplus.
if [[ "$version" =~ ^6 ]]; then
Expand Down
11 changes: 9 additions & 2 deletions .github/ubuntu/firebird.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@
set -e

# Download dependencies.
sudo apt-get update -qq
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq firebird-dev firebird3.0-utils
if [ -z "$SKIP_DEPENDS" ]; then
sudo apt-get update -qq
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq firebird-dev firebird3.0-utils
fi

# Tell DBD::Firebird where to find the libraries.
if [[ ! -z "$GITHUB_ENV" ]]; then
echo "FIREBIRD_HOME=/usr" >> $GITHUB_ENV
fi
7 changes: 4 additions & 3 deletions .github/ubuntu/mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e

# Download dependencies.
sudo apt-get update -qq
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq mysql-client default-libmysqlclient-dev

if [ -z "$SKIP_DEPENDS" ]; then
sudo apt-get update -qq
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq mysql-client default-libmysqlclient-dev
fi
12 changes: 9 additions & 3 deletions .github/ubuntu/oracle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ version=21.3.0.0.0
icdr=213000

# Install bsdtar, required to get --strip-components for a zip file.
sudo apt-get update -qq
sudo apt-get install -qq libarchive-tools
if [ -z "$SKIP_DEPENDS" ]; then
sudo apt-get update -qq
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq libarchive-tools
fi

# Download Instant Client.
# https://www.oracle.com/database/technologies/instant-client/downloads.html
Expand All @@ -28,5 +30,9 @@ fi

if [[ ! -z "$GITHUB_ENV" ]]; then
echo "ORACLE_HOME=/opt/instantclient" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/opt/instantclient" >> $GITHUB_ENV
if [[ -z "$LD_LIBRARY_PATH" ]]; then
echo "LD_LIBRARY_PATH=/opt/instantclient" >> $GITHUB_ENV
else
echo "LD_LIBRARY_PATH=/opt/instantclient:$LD_LIBRARY_PATH" >> $GITHUB_ENV
fi
fi
7 changes: 1 addition & 6 deletions .github/ubuntu/pg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

set -e

PGVERSION=${PGVERSION:=$1}
if [[ -z "$PGVERSION" ]]; then
echo "Usage: $0 \$version"
exit 32
fi

PGVERSION=${PGVERSION:=${1:-14}}
[[ $PGVERSION =~ ^[0-9]$ ]] && PGVERSION+=.0

curl -O https://salsa.debian.org/postgresql/postgresql-common/-/raw/master/pgdg/apt.postgresql.org.sh
Expand Down
7 changes: 0 additions & 7 deletions .github/ubuntu/prereqs.sh

This file was deleted.

8 changes: 5 additions & 3 deletions .github/ubuntu/snowflake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
set -e

# Set up Snowflake.
sudo apt-get update -qq
sudo apt-get install -qq unixodbc-dev odbcinst unixodbc
if [ -z "$SKIP_DEPENDS" ]; then
sudo apt-get update -qq
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq unixodbc-dev odbcinst unixodbc
cat t/odbc/odbcinst.ini | sudo tee -a /etc/odbcinst.ini
fi

# https://docs.snowflake.net/manuals/release-notes/client-change-log-snowsql.html
# https://sfc-repo.snowflakecomputing.com/index.html
Expand All @@ -13,7 +16,6 @@ curl -sSLo snowdbc.tgz https://sfc-repo.snowflakecomputing.com/odbc/linux/2.24.2

# Install and configure ODBC.
mkdir -p /opt/snowflake
cat t/odbc/odbcinst.ini | sudo tee -a /etc/odbcinst.ini
sudo tar --strip-components 1 -C /opt/snowflake -xzf snowdbc.tgz
sudo mv /opt/snowflake/ErrorMessages/en-US /opt/snowflake/lib/

Expand Down
22 changes: 10 additions & 12 deletions .github/ubuntu/sqlite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

set -e

DIR=$(pwd)

SQLITE=${SQLITE:=$1}
if [[ -z "$SQLITE" ]]; then
echo "Usage: $0 \$version"
exit 32
fi
SQLITE=${SQLITE:=${1:-3.36.0}}

# Convert to the SQLITE_VERSION_NUMBER format https://sqlite.org/c3ref/c_source_id.html
SQLITE=$(perl -e 'my @v = split /[.]/, shift; printf "%d%02d%02d%02d\n", @v[0..3]' $SQLITE)
Expand All @@ -33,8 +27,8 @@ fi

# Download, compile, and install SQLite.
curl -o sqlite.zip https://sqlite.org/$YEAR/sqlite-amalgamation-$SQLITE.zip
unzip -j sqlite.zip -d sqlite
cd sqlite
unzip -j sqlite.zip -d /opt/sqlite
cd /opt/sqlite
# Build the CLI.
gcc shell.c sqlite3.c -lpthread -ldl -o sqlite3
# Build the shared library
Expand All @@ -47,13 +41,17 @@ URL=https://cpan.metacpan.org/authors/id/${DIST:0:1}/${DIST:0:2}/$DIST
curl -o dbd.tar.gz $URL
tar zxvf dbd.tar.gz --strip-components 1
perl -i -pe 's/^if\s*\(\s*0\s*\)\s\{/if (1) {/' Makefile.PL
perl Makefile.PL SQLITE_INC=$DIR/sqlite SQLITE_LIB=$DIR/sqlite
perl Makefile.PL SQLITE_INC=/opt/sqlite SQLITE_LIB=/opt/sqlite
make && make install

if [[ ! -z "$GITHUB_PATH" ]]; then
echo "$DIR/sqlite" >> $GITHUB_PATH
echo "/opt/sqlite" >> $GITHUB_PATH
fi

if [[ ! -z "$GITHUB_ENV" ]]; then
echo "LD_LIBRARY_PATH=$DIR/sqlite" >> $GITHUB_ENV
if [[ -z "$LD_LIBRARY_PATH" ]]; then
echo "LD_LIBRARY_PATH=/opt/sqlite" >> $GITHUB_ENV
else
echo "LD_LIBRARY_PATH=/opt/sqlite:$LD_LIBRARY_PATH" >> $GITHUB_ENV
fi
fi
8 changes: 5 additions & 3 deletions .github/ubuntu/vertica.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

set -e

sudo apt-get update -qq
sudo apt-get install -qq unixodbc-dev odbcinst unixodbc
if [ -z "$SKIP_DEPENDS" ]; then
sudo apt-get update -qq
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -qq unixodbc-dev odbcinst unixodbc
cat t/odbc/odbcinst.ini | sudo tee -a /etc/odbcinst.ini
fi

cat t/odbc/odbcinst.ini | sudo tee -a /etc/odbcinst.ini
cat t/odbc/vertica.ini | sudo tee -a /etc/vertica.ini

# https://www.vertica.com/download/vertica/client-drivers/
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# This workflow creates the services and installs the clients in order to run
# coverage tests. Each engine must be accessible for a complete coverage report.
# It runs for pushes and pull requests on the main and develop branches.
name: 📈 Coverage
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
Snowflake:
name: 📈 Coverage
runs-on: ubuntu-latest
services:
exasol:
image: exasol/docker-db:latest
ports: [ 8563 ]
options: --privileged
firebird:
image: jacobalberty/firebird:latest
ports: [ 3050 ]
env:
ISC_PASSWORD: nix
FIREBIRD_DATABASE: sqitchtest.db
mysql:
image: mysql:latest
env: { MYSQL_ALLOW_EMPTY_PASSWORD: yes }
ports: [ 3306 ]
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
oracle:
image: gvenzl/oracle-xe:latest
ports: [ 1521 ]
env:
ORACLE_PASSWORD: oracle
APP_USER: sqitchtest
APP_USER_PASSWORD: sqitchtest
options: >-
--health-cmd healthcheck.sh
--health-interval 20s
--health-timeout 10s
--health-retries 10
vertica:
image: vertica/vertica-ce:latest
ports: [ 5433 ]
steps:
- uses: actions/checkout@v2
- name: Setup Clients
env:
SKIP_DEPENDS: true
run: |
.github/ubuntu/all-apt-prereqs.sh
.github/ubuntu/exasol.sh
.github/ubuntu/firebird.sh
.github/ubuntu/mysql.sh
.github/ubuntu/oracle.sh
.github/ubuntu/pg.sh
.github/ubuntu/snowflake.sh
.github/ubuntu/vertica.sh
- name: Setup Perl
id: perl
uses: shogo82148/actions-setup-perl@v1
with: { perl-version: latest }
- name: Cache CPAN Modules
uses: actions/cache@v2
with:
path: local
key: perl-${{ steps.perl.outputs.perl-hash }}
- name: Download cpanfile
uses: carlosperate/download-file-action@v1.0.3
with:
file-url: https://fastapi.metacpan.org/source/DWHEELER/App-Sqitch-v1.1.0/dist/cpanfile
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends --cpanfile cpanfile
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends DBI DBD::ODBC DBD::Firebird DBD::Oracle DBD::mysql DBD::Pg Devel::Cover Devel::Cover::Report::Coveralls Algorithm::Backoff::Exponential
- name: Install SQLite
env: { PERL5LIB: "${{ github.workspace }}/local/lib/perl5" }
run: .github/ubuntu/sqlite.sh
- name: Run Tests
env:
PERL5LIB: "${{ github.workspace }}/local/lib/perl5"
HARNESS_PERL_SWITCHES: -MDevel::Cover=-ignore,^(?:x?t|inc|bin|local)/
LIVE_EXASOL_REQUIRED: true
SQITCH_TEST_EXASOL_URI: db:exasol://sys:exasol@127.0.0.1:${{ job.services.exasol.ports[8563] }}/?Driver=Exasol;SSLCertificate=SSL_VERIFY_NONE
LIVE_FIREBIRD_REQUIRED: true
SQITCH_TEST_FIREBIRD_URI: db:firebird://sysdba:nix@127.0.0.1:${{ job.services.firebird.ports[3050] }}//firebird/data/sqitchtest.db
LIVE_MYSQL_REQUIRED: true
SQITCH_TEST_MYSQL_URI: "db:mysql://root@127.0.0.1:${{ job.services.mysql.ports[3306] }}/information_schema"
LIVE_ORACLE_REQUIRED: true
SQITCH_TEST_ALT_ORACLE_REGISTRY: dbsnmp
SQITCH_TEST_ORACLE_URI: db:oracle://system:oracle@127.0.0.1:${{ job.services.oracle.ports[1521] }}/XE
LIVE_PG_REQUIRED: true
SQITCH_TEST_PG_URI: db:pg://postgres@/postgres
LIVE_SNOWFLAKE_REQUIRED: true
SQITCH_TEST_SNOWFLAKE_URI: db:snowflake://${{ secrets.SNOWFLAKE_USERNAME }}:${{ secrets.SNOWFLAKE_PASSWORD }}@sra81677.us-east-1/sqitchtest?Driver=Snowflake;warehouse=compute_wh
LIVE_SQLITE_REQUIRED: true
LIVE_VERTICA_REQUIRED: true
SQITCH_TEST_VSQL_URI: db:vertica://dbadmin@localhost:${{ job.services.vertica.ports[5433] }}/VMart?Driver=Vertica
run: prove -lrj4 t
- name: Report Coverage
env:
PERL5LIB: "${{ github.workspace }}/local/lib/perl5"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: local/bin/cover -report coveralls
2 changes: 1 addition & 1 deletion .github/workflows/exasol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Cache CPAN Modules
uses: actions/cache@v2
with:
path: local/lib
path: local
key: perl-${{ steps.perl.outputs.perl-hash }}
- name: Download cpanfile
uses: carlosperate/download-file-action@v1.0.3
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/firebird.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,17 @@ jobs:
- name: Cache CPAN Modules
uses: actions/cache@v2
with:
path: local/lib
path: local
key: perl-${{ steps.perl.outputs.perl-hash }}
- name: Download cpanfile
uses: carlosperate/download-file-action@v1.0.3
with:
file-url: https://fastapi.metacpan.org/source/DWHEELER/App-Sqitch-v1.1.0/dist/cpanfile
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends --cpanfile cpanfile
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends DBD::Firebird
env: { FIREBIRD_HOME: /usr }
- name: prove
env:
PERL5LIB: "${{ github.workspace }}/local/lib/perl5"
LIVE_FIREBIRD_REQUIRED: true
FIREBIRD_HOME: /usr
SQITCH_TEST_FIREBIRD_URI: db:firebird://sysdba:nix@127.0.0.1:${{ job.services.firebird.ports[3050] }}//firebird/data/sqitchtest.db
run: prove -lvr t/firebird.t
2 changes: 1 addition & 1 deletion .github/workflows/mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Cache CPAN Modules
uses: actions/cache@v2
with:
path: local/lib
path: local
key: perl-${{ steps.perl.outputs.perl-hash }}
- name: Download cpanfile
uses: carlosperate/download-file-action@v1.0.3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/oracle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ jobs:
# In 11g, APP_USER "sqitchtest" is created in XE, but in more recent
# versions it is created in the XEPDB1 pluggable database, which we
# cannot connect to using a URI. So we use an existing user in those
# versions.
# versions. Uncomment code in skip_unless in t/oracle.t to find other
# user schemas that will work.
# * Image Source: https://github.com/gvenzl/oci-oracle-xe/
# * Image Issue: https://github.com/gvenzl/oci-oracle-xe/issues/46
# * DBD::Oracle Issue: https://github.com/perl5-dbi/DBD-Oracle/issues/131
# - { version: 21c, tag: 21-full, service: XE, altUser: gsmuser }
- { version: 21c, tag: 21, service: XE, altUser: dbsnmp }
- { version: 18c, tag: 18-slim, service: XE, altUser: gsmuser }
- { version: 11g, tag: 11-slim, service: XE, altuser: sqitchtest }
name: "🔮 Oracle ${{ matrix.version }}"
Expand All @@ -38,7 +39,6 @@ jobs:
--health-timeout 10s
--health-retries 10
steps:
- run: "echo Filter: ${{ needs.filter.outputs.oracle }}"
- uses: actions/checkout@v2
- name: Setup Clients
run: .github/ubuntu/oracle.sh
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Cache CPAN Modules
uses: actions/cache@v2
with:
path: local/lib
path: local
key: perl-${{ steps.perl.outputs.perl-hash }}
- name: Download cpanfile
uses: carlosperate/download-file-action@v1.0.3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Cache CPAN Modules
uses: actions/cache@v2
with:
path: local/lib
path: local
key: perl-${{ steps.perl.outputs.perl-hash }}
- name: Download cpanfile
uses: carlosperate/download-file-action@v1.0.3
Expand All @@ -37,4 +37,4 @@ jobs:
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Test::Spelling Test::Pod Test::Pod::Coverage
- name: prove
env: { PERL5LIB: "${{ github.workspace }}/local/lib/perl5" }
run: prove -lr --comments --directives
run: prove -lrj4
4 changes: 2 additions & 2 deletions .github/workflows/perl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Cache CPAN Modules
uses: actions/cache@v2
with:
path: local/lib
path: local
key: perl-${{ steps.perl.outputs.perl-hash }}
- name: Download cpanfile
uses: carlosperate/download-file-action@v1.0.3
Expand All @@ -41,4 +41,4 @@ jobs:
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Test::Spelling Test::Pod Test::Pod::Coverage
- name: prove
env: { PERL5LIB: "${{ github.workspace }}/local/lib/perl5" }
run: prove -lr --comments --directives
run: prove -lrj4
2 changes: 1 addition & 1 deletion .github/workflows/pg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Cache CPAN Modules
uses: actions/cache@v2
with:
path: local/lib
path: local
key: perl-${{ steps.perl.outputs.perl-hash }}
- name: Download cpanfile
uses: carlosperate/download-file-action@v1.0.3
Expand Down
Loading

0 comments on commit 8b38027

Please sign in to comment.