From e65c53ba351a771d3ea6f1219ef9f5b645d40c9e Mon Sep 17 00:00:00 2001 From: Luke Albao Date: Mon, 8 Nov 2021 18:21:32 -0800 Subject: [PATCH] Run tests against multiple versions in CI --- .github/run-tests.sh | 2 -- .github/workflows/pull_request.yml | 58 +++++++++++++++++++++++------- Makefile | 9 ++--- 3 files changed, 51 insertions(+), 18 deletions(-) delete mode 100644 .github/run-tests.sh diff --git a/.github/run-tests.sh b/.github/run-tests.sh deleted file mode 100644 index 23f70c1..0000000 --- a/.github/run-tests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -make all test diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 607e672..9b27883 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,17 +1,51 @@ -# This is a basic workflow to help you get started with Actions - on: pull_request -name: Pull Request + jobs: - test: - name: Run tests + test-pg: runs-on: ubuntu-latest + + strategy: + matrix: + pg-version: [11, 12] + + services: + postgres: + image: postgres:${{ matrix.pg-version }} + ports: + - 5432:5432 + env: + POSTGRES_PASSWORD: unsafe + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: - - uses: actions/checkout@master - - name: Setup perl - uses: shogo82148/actions-setup-perl@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Compile Source + run: make compile + - name: Load Source + run: make execute + env: + PGHOST: postgres + PGPASSWORD: unsafe + PGUSER: postgres + - name: Setup pg_prove on runner + run: sudo cpan TAP::Parser::SourceHandler::pgTAP + env: + SHELL: /bin/bash + - name: Setup pgtap on target + uses: actions/checkout@v2 with: - perl-version: '5.30' - - run: cpan TAP::Parser::SourceHandler::pgTAP - - name: Test - uses: skx/github-action-tester@master + repository: theory/pgtap + path: pgtap + ref: v1.1.0 + - name: Install pgtap on target + working-directory: pgtap + run: make && psql --host localhost --username postgres --dbname postgres --file sql/pgtap.sql + env: + PGPASSWORD: unsafe + - name: Run tests + run: make test + env: + PGHOST: postgres + PGPASSWORD: unsafe + PGUSER: postgres diff --git a/Makefile b/Makefile index 20f2bed..ace2fe8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ -TESTS = $(find tests -name test_\*.sql) +TESTS := $(find tests -name test_\*.sql) +PGHOST := localhost +PGPASSWORD := unsafe +PGUSER := postgres clean: psql -c "DROP SCHEMA IF EXISTS _rrule CASCADE" @@ -19,7 +22,7 @@ casts: find src/casts -name \*.sql | sort | xargs -I % cat % >> postgres-rrule.sql test: - psql -c "CREATE EXTENSION IF NOT EXISTS pgtap;" && pg_prove tests/test_*.sql + pg_prove tests/test_*.sql rm_rules: rm -f postgres-rrule.sql @@ -32,5 +35,3 @@ execute: dev: execute all: compile execute - -