Last active
January 8, 2022 18:04
-
-
Save peterhirn/64661b30625651521964515d906e3122 to your computer and use it in GitHub Desktop.
Run evolve and pgTAP in Gitlab CI (shared runner ~45sec.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- test | |
test: | |
image: postgres:14.1-bullseye | |
stage: test | |
services: | |
- name: postgres:14.1-bullseye | |
alias: db | |
variables: | |
EVOLVE_VERSION: 3.0.0 | |
GIT_DEPTH: 1 | |
PGHOST: db | |
PGDATABASE: postgres | |
PGUSER: postgres | |
PGPASSWORD: "" | |
CONNECTION: "Server=${PGHOST};Uid=${PGUSER};Pwd=${PGPASSWORD};Database=${PGDATABASE}" | |
POSTGRES_HOST_AUTH_METHOD: trust | |
JUNIT_OUTPUT_FILE: results.xml | |
script: | |
- set -euo pipefail | |
# Enable backports | |
- echo "deb http://deb.debian.org/debian bullseye-backports main contrib non-free" > /etc/apt/sources.list.d/bullseye-backports.list | |
- apt-get update | |
# Install evolve | |
- apt-get install -y --no-install-recommends ca-certificates wget | |
- > | |
wget -q https://github.com/lecaillon/Evolve/releases/download/${EVOLVE_VERSION}/evolve_${EVOLVE_VERSION}_Linux-64bit.tar.gz | |
&& tar -xzvf evolve_${EVOLVE_VERSION}_Linux-64bit.tar.gz -C /usr/local/bin --strip-components 1 | |
&& rm evolve_${EVOLVE_VERSION}_Linux-64bit.tar.gz | |
# Install pgTAP | |
- > | |
apt -t bullseye-backports install -y --no-install-recommends | |
libtap-harness-junit-perl libtap-parser-sourcehandler-pgtap-perl postgresql-14-pgtap | |
- psql -q -f "/usr/share/postgresql/14/extension/pgtap.sql" | |
# Migrate | |
- evolve migrate postgresql -l db/migrations -c "${CONNECTION}" | |
# Test | |
- pg_prove --verbose --harness TAP::Harness::JUnit db/tests | |
artifacts: | |
when: always | |
expire_in: 1 month | |
reports: | |
junit: results.xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment