Skip to content

Commit

Permalink
Replace Travis with GitHub Workflows
Browse files Browse the repository at this point in the history
Travis has not worked in a while, so switch to GitHub workflows. All previous
tests aside from Postgres upgrades have been replicated (and upgrades should be
back soon). In the process, discover missing update SQL, so add it to
`sql/pgtap--1.1.0--1.2.0.sql`. Yay testing!

Also add a workflow for releasing pgTAP with a semantic version tag.
  • Loading branch information
theory committed Nov 13, 2021
1 parent d76abc4 commit 2ccda7f
Show file tree
Hide file tree
Showing 13 changed files with 331 additions and 418 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.gitignore export-ignore
.gitattributes export-ignore
tocgen export-ignore
.travis.yml export-ignore
.release.mmd export-ignore
.github export-ignore
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 🚀 Release
on:
push:
tags: [v*]
jobs:
release:
name: 🚀 Release on GitHub and PGXN
runs-on: ubuntu-latest
container: pgxn/pgxn-tools
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PGXN_USERNAME: ${{ secrets.PGXN_USERNAME }}
PGXN_PASSWORD: ${{ secrets.PGXN_PASSWORD }}
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Bundle the Release
id: bundle
run: pgxn-bundle
- name: Release on PGXN
run: pgxn-release
- name: Generate Release Changes
run: make latest-changes.md
- name: Create GitHub Release
id: release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: latest-changes.md
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./${{ steps.bundle.outputs.bundle }}
asset_name: ${{ steps.bundle.outputs.bundle }}
asset_content_type: application/zip
63 changes: 63 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: 🐘 Test
on:
push:
pull_request:
schedule:
- cron: '0 14 3 * *' # Monthly at 2pm on the third
jobs:
build:
strategy:
matrix:
include:
- { version: 14, upgrade_to: "", update_from: 0.99.0 }
- { version: 13, upgrade_to: 14, update_from: 0.99.0 }
- { version: 12, upgrade_to: 13, update_from: 0.99.0 }
- { version: 11, upgrade_to: 12, update_from: 0.99.0 } # Versions prior to 0.99.0 don't support Postgres 11
- { version: 10, upgrade_to: 11, update_from: 0.95.0 }
- { version: 9.6, upgrade_to: 10, update_from: 0.95.0 }
- { version: 9.5, upgrade_to: 9.6, update_from: 0.95.0 }
- { version: 9.4, upgrade_to: 9.5, update_from: 0.95.0 }
- { version: 9.3, upgrade_to: 9.4, update_from: 0.95.0 }
- { version: 9.2, upgrade_to: 9.3, update_from: "" } # updatecheck is not supported prior to 9.3
- { version: 9.1, upgrade_to: 9.2, update_from: "" }
# Also test pg_upgrade across many versions
# - { version: 9.1, upgrade_to: 14, update_from: 0.99.0 }
# - { version: 9.4, upgrade_to: 14, update_from: 0.99.0 }
name: 🐘 PostgreSQL ${{ matrix.version }}
runs-on: ubuntu-latest
container: pgxn/pgxn-tools
env:
PGUSER: postgres
UPDATE_FROM: "${{ matrix.update_from }}"
steps:
- run: pg-start ${{ matrix.version }}
- uses: actions/checkout@v2

# Basic regression test.
- run: pg-build-test

# Test update.
- run: 'if [ -d "$UPDATE_FROM" ]; then make uninstall clean updatecheck; fi'

# Test upgrade.
# - run: ./test/test_MVU.sh -s 55667 55778 "{{ matrix.version }}" "{{ matrix.upgrade_to }}" "/usr/lib/postgresql/{{ matrix.version }}/bin/" "/usr/lib/postgresql/{{ matrix.upgrade_to }}/bin/"

# Test all, install, test, test-serial, and test-parallel, both from clean
# repo and repeated with existing build, with and without PARALLEL_CONN=1.
- run: make uninstall clean all
- run: make all
- run: make uninstall clean install
- run: make install
- run: "psql -Ec 'CREATE EXTENSION pgtap'"
- run: make uninstall clean test
- run: make test
- run: make uninstall clean test PARALLEL_CONN=1
- run: make test PARALLEL_CONN=1
- run: make uninstall clean test-serial
- run: make test-serial
- run: make uninstall clean test-serial PARALLEL_CONN=1
- run: make test-serial PARALLEL_CONN=1
- run: make uninstall clean test-parallel
- run: make test-parallel
- run: make uninstall clean test-parallel PARALLEL_CONN=1
- run: make test-parallel PARALLEL_CONN=1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bbin
*.sql.orig

test/build
/latest-changes.md

# Misc mac crap
.DS_Store
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

15 changes: 8 additions & 7 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,22 @@ Revision history for pgTAP
* Remove support for PostgreSQL older than 9.1. Note that some automated tests
don't run on versions older than 9.4, so it's recommended you run PostgreSQL
9.4 at minimum.
* Add a `throw_excepton` argument to `finish()`. `finish(true)` will raise an
* Add a `throw_exception` argument to `finish()`. `finish(true)` will raise an
exception if any tests failed. Thanks to Stephen Paul Weber for the idea
(#80), and Rodolphe Quiédeville for most of the work (#104)!
* Make description optional for col_not_null() (#221).
* Make description optional for `col_not_null()` (#221).
* Fix syntax of test_user function example in the docs (#208). Thanks to
PeteDevoy for the patch!
* Fix issue with pgtap-core referencing pg_proc.proisagg on PostgreSQL 11+ (#197)
* Fix issue with `pgtap-core` referencing `pg_proc.proisagg` on PostgreSQL 11+
(#197).
* Add PostgreSQL 12.0 to automated tests (#223).
* Fix pgtap_version(), which incorrectly returned 0.99 when upgrading from
* Fix `pgtap_version()`, which incorrectly returned 0.99 when upgrading from
version 0.99.0 to 1.0.0 (#214).
* Fix issue with using pg_upgrade to PostgreSQL 11+ with pgTap installed (#201,
#215).
* Fix issue with using `pg_upgrade` to PostgreSQL 11+ with pgTAP installed
(#201, #215).
* Start using `DEFAULT` in functions.
* Add automated testing of extension upgrade scripts (#128), as well as testing
of pg_upgrade with pgTap installed (#218, #222).
of `pg_upgrade` with pgTAP installed (#218, #222).

1.0.0 2019-02-21T22:39:42Z
--------------------------
Expand Down
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ MAINEXT = pgtap
EXTENSION = $(MAINEXT)
EXTVERSION = $(shell grep default_version $(MAINEXT).control | \
sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")
DISTVERSION = $(shell grep -m 1 '[[:space:]]\{3\}"version":' META.json | \
sed -e 's/[[:space:]]*"version":[[:space:]]*"\([^"]*\)",\{0,1\}/\1/')
NUMVERSION = $(shell echo $(EXTVERSION) | sed -e 's/\([[:digit:]]*[.][[:digit:]]*\).*/\1/')
VERSION_FILES = sql/$(MAINEXT)--$(EXTVERSION).sql sql/$(MAINEXT)-core--$(EXTVERSION).sql sql/$(MAINEXT)-schema--$(EXTVERSION).sql
BASE_FILES = $(subst --$(EXTVERSION),,$(VERSION_FILES)) sql/uninstall_$(MAINEXT).sql
Expand Down Expand Up @@ -446,9 +448,8 @@ $(B_DIR)/:
pgtap-version-%: $(EXTENSION_DIR)/pgtap--%.sql
@true # Necessary to have a fake action here


# Travis will complain if we reinstall too quickly, so don't run make install
# unless actually necessary.
# CI/CD workflow might complain if we reinstall too quickly, so don't run make
# install unless actually necessary.
$(EXTENSION_DIR)/pgtap--$(EXTVERSION).sql: sql/pgtap--$(EXTVERSION).sql
$(MAKE) install

Expand Down Expand Up @@ -484,6 +485,9 @@ updatecheck_setup: updatecheck_deps
.PHONY: updatecheck_run
updatecheck_run: updatecheck_setup installcheck

latest-changes.md: Changes
perl -e 'while (<>) {last if /^(v?\Q${DISTVERSION}\E)/; } print "Changes for v${DISTVERSION}:\n"; while (<>) { last if /^\s*$$/; s/^\s+//; print }' Changes > $@

#
# STOLEN FROM pgxntool
#
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ documentation in `doc/pgtap.mmd` or
[online](https://pgtap.org/documentation.html "Complete pgTAP Documentation").

[![PGXN version](https://badge.fury.io/pg/pgtap.svg)](https://badge.fury.io/pg/pgtap)
[![Build Status](https://travis-ci.org/theory/pgtap.png)](https://travis-ci.org/theory/pgtap)
[![🐘 Postgres](https://github.com/theory/pgtap/actions/workflows/test.yml/badge.svg)](https://github.com/theory/pgtap/actions/workflows/test.yml)

pgTAP must be installed on a host with PostgreSQL server running; it cannot
be installed remotely.
Expand Down
49 changes: 48 additions & 1 deletion sql/pgtap--1.1.0--1.2.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,53 @@ CREATE OR REPLACE FUNCTION pgtap_version()
RETURNS NUMERIC AS 'SELECT 1.2;'
LANGUAGE SQL IMMUTABLE;

-- isnt_member_of( role, members[], description )
CREATE OR REPLACE FUNCTION isnt_member_of( NAME, NAME[], TEXT )
RETURNS TEXT AS $$
DECLARE
extra text[];
BEGIN
IF NOT _has_role($1) THEN
RETURN fail( $3 ) || E'\n' || diag (
' Role ' || quote_ident($1) || ' does not exist'
);
END IF;

SELECT ARRAY(
SELECT quote_ident($2[i])
FROM generate_series(1, array_upper($2, 1)) s(i)
LEFT JOIN pg_catalog.pg_roles r ON rolname = $2[i]
WHERE r.oid = ANY ( _grolist($1) )
ORDER BY s.i
) INTO extra;
IF extra[1] IS NULL THEN
RETURN ok( true, $3 );
END IF;
RETURN ok( false, $3 ) || E'\n' || diag(
' Members, who should not be in ' || quote_ident($1) || E' role:\n ' ||
array_to_string( extra, E'\n ')
);
END;
$$ LANGUAGE plpgsql;

-- isnt_member_of( role, member, description )
CREATE OR REPLACE FUNCTION isnt_member_of( NAME, NAME, TEXT )
RETURNS TEXT AS $$
SELECT isnt_member_of( $1, ARRAY[$2], $3 );
$$ LANGUAGE SQL;

-- isnt_member_of( role, members[] )
CREATE OR REPLACE FUNCTION isnt_member_of( NAME, NAME[] )
RETURNS TEXT AS $$
SELECT isnt_member_of( $1, $2, 'Should not have members of role ' || quote_ident($1) );
$$ LANGUAGE SQL;

-- isnt_member_of( role, member )
CREATE OR REPLACE FUNCTION isnt_member_of( NAME, NAME )
RETURNS TEXT AS $$
SELECT isnt_member_of( $1, ARRAY[$2] );
$$ LANGUAGE SQL;

-- has_view( schema, view )
CREATE OR REPLACE FUNCTION has_view ( NAME, NAME )
RETURNS TEXT AS $$
Expand Down Expand Up @@ -121,7 +168,7 @@ EXCEPTION
);
END;
$$ LANGUAGE plpgsql;
=======

-- hasnt_operator( left_type, schema, name, right_type, return_type, description )
CREATE OR REPLACE FUNCTION hasnt_operator ( NAME, NAME, NAME, NAME, NAME, TEXT )
RETURNS TEXT AS $$
Expand Down
Loading

0 comments on commit 2ccda7f

Please sign in to comment.