Skip to content

Commit

Permalink
ci: test and release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
markokr committed Jul 7, 2022
1 parent 4147c21 commit 6bf5bdd
Show file tree
Hide file tree
Showing 6 changed files with 452 additions and 1 deletion.
174 changes: 174 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
#
# https://docs.github.com/en/actions
# https://github.com/actions
#
# mac: https://brew.sh/
# win: https://www.msys2.org/docs/package-management/
# win: https://www.archlinux.org/pacman/pacman.8.html
#

name: CI

on:
pull_request: {}
push: {}

jobs:

test:
name: ${{matrix.test.os}}, pg-${{matrix.test.pgver}}
runs-on: ${{matrix.test.os}}
strategy:
matrix:
test:
- {pgver: "12", os: "ubuntu-18.04"}
- {pgver: "13", os: "ubuntu-20.04"}
- {pgver: "14", os: "ubuntu-22.04"}
- {pgver: "14", os: "macos-latest"}
steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
submodules: true

- name: "InstallDB / Linux"
if: ${{runner.os == 'Linux'}}
run: |
echo "::group::apt-get-update"
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main ${{matrix.test.pgver}}" \
| sudo tee /etc/apt/sources.list.d/pgdg.list
sudo -nH apt-get -q update
echo "::endgroup::"
echo "::group::apt-get-install"
# disable new cluster creation
sudo -nH mkdir -p /etc/postgresql-common/createcluster.d
echo "create_main_cluster = false" | sudo -nH tee /etc/postgresql-common/createcluster.d/no-main.conf
sudo -nH apt-get -qyu install \
postgresql-${{matrix.test.pgver}} \
postgresql-server-dev-${{matrix.test.pgver}} \
libevent-dev python3-docutils \
libpq-dev patchutils
echo "::endgroup::"
# tune environment
echo "/usr/lib/postgresql/${{matrix.test.pgver}}/bin" >> $GITHUB_PATH
echo "PGHOST=/tmp" >> $GITHUB_ENV
echo "SED=sed" >> $GITHUB_ENV
echo "RST2MAN=rst2man" >> $GITHUB_ENV
dpkg -l postgres\* libpq\* gcc\* clang\* libevent\*
- name: "InstallDB / Mac"
if: ${{runner.os == 'macOS'}}
run: |
echo "::group::install"
brew install patchutils gnu-sed docutils libevent postgresql@${{matrix.test.pgver}} autoconf automake
echo "::endgroup::"
echo "/usr/local/opt/docutils/bin" >> $GITHUB_PATH
echo "/usr/local/opt/postgresql@${{matrix.test.pgver}}/bin" >> $GITHUB_PATH
echo "SED=gsed" >> $GITHUB_ENV
echo "RST2MAN=rst2man.py" >> $GITHUB_ENV
- name: "Build"
run: |
./autogen.sh
./configure --prefix=${GITHUB_WORKSPACE}/testinstall
make RST2MAN=${{env.RST2MAN}}
make install
- name: "Install PgQ"
run: |
git clone https://github.com/pgq/pgq
make -C pgq
sudo -nH bash -c "PATH='${PATH}' make -C pgq install"
- name: "StartDB"
run: |
mkdir -p log
LANG=C LC_ALL=C initdb --no-locale data
${SED} -r -i -e "s,^[# ]*(unix_socket_directories).*,\\1='/tmp'," data/postgresql.conf
pg_ctl -D data -l log/pg.log start || { cat log/pg.log ; exit 1; }
sleep 2
- name: "Test"
run: make citest

- name: "StopDB"
run: |
pg_ctl -D data stop
rm -rf data log /tmp/.s.PGSQL*
mingw:
name: ${{matrix.test.os}}, ${{matrix.test.mingw}}
runs-on: ${{matrix.test.os}}
strategy:
matrix:
test:
- {os: "windows-2019", arch: i686, mingw: mingw32}
- {os: "windows-2019", arch: x86_64, mingw: mingw64}
steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
submodules: true

- name: "Setup MSYS"
shell: cmd
run: |
echo C:\msys64\usr\bin>> %GITHUB_PATH%
echo C:\msys64\${{matrix.test.mingw}}\bin>> %GITHUB_PATH%
- name: "InstallDB / mingw / ${{matrix.test.arch}}"
shell: bash
run: |
# search package lists
pacman -Ss libevent
pacman -Ss autoconf
pacman -Ss automake
pacman -Ss libtool
# install
pacman -S --noconfirm --needed \
mingw-w64-${{matrix.test.arch}}-postgresql \
mingw-w64-${{matrix.test.arch}}-python-docutils \
mingw-w64-${{matrix.test.arch}}-libevent \
autoconf automake libtool
echo "PATH=$PATH"
- name: "Build"
shell: bash
run: |
./autogen.sh
./configure --prefix=${GITHUB_WORKSPACE}/testinstall
make
make install
./pgqd -V
- name: "Install PgQ"
shell: bash
run: |
git clone https://github.com/pgq/pgq
make -C pgq
make -C pgq install
- name: "StartDB"
shell: bash
run: |
mkdir log
initdb.exe --no-locale -U postgres -D data
pg_ctl -D data -l log/pg.log start || { cat log/pg.log ; exit 1; }
sleep 3
- name: "Test"
if: false
shell: bash
run: make citest

- name: "StopDB"
shell: bash
run: |
pg_ctl -D data stop
74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

name: REL

on:
push:
tags: ["v[0-9]*"]

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:

- name: Checkout code
id: checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Build tarball
id: build
run: |
sudo -nH apt-get -u -y install pandoc autoconf automake libtool \
libevent-dev libpq-dev patchutils python3-docutils
./autogen.sh
./configure
make checkver
make dist
PACKAGE=$(grep ^PACKAGE_NAME config.mak | sed 's/.*= *//')
VERSION=$(grep ^PACKAGE_VERSION config.mak | sed 's/.*= *//')
# default - gh:release
# PRERELEASE - gh:prerelease
# DRAFT - gh:draft,prerelease
PRERELEASE="false"
DRAFT="false"
if echo "${VERSION}" | grep -qE '(a|b|rc)'; then PRERELEASE="true"; fi
if echo "${VERSION}" | grep -qE '(dev)'; then DRAFT="true"; PRERELEASE="true"; fi
test "${{github.ref}}" = "refs/tags/v${VERSION}" || { echo "ERR: tag mismatch"; exit 1; }
echo "PACKAGE=${PACKAGE}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "TGZ=${PACKAGE}-${VERSION}.tar.gz" >> $GITHUB_ENV
echo "PRERELEASE=${PRERELEASE}" >> $GITHUB_ENV
echo "DRAFT=${DRAFT}" >> $GITHUB_ENV
pandoc --version
mkdir -p tmp
make -s shownote > tmp/note.md
cat tmp/note.md
- name: Create release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{github.ref}}
release_name: ${{github.event.repository.name}} v${{env.VERSION}}
body_path: tmp/note.md
draft: ${{env.DRAFT}}
prerelease: ${{env.PRERELEASE}}

- name: Upload source
id: upload
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.release.outputs.upload_url}}
asset_path: ${{env.TGZ}}
asset_name: ${{env.TGZ}}
asset_content_type: application/x-gzip

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ tmp
*.substvars
*-stamp
debian/files
tests/log
33 changes: 32 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ USUAL_DIR = lib
AM_FEATURES = libusual

EXTRA_DIST = pgqd.ini autogen.sh configure.ac Makefile \
README.rst NEWS.rst \
README.rst NEWS.rst tests/test.sh \
lib/find_modules.sh \
lib/mk/antimake.mk lib/mk/amext-libusual.mk \
lib/mk/install-sh lib/mk/std-autogen.sh \
Expand Down Expand Up @@ -63,3 +63,34 @@ xclean: clean
pgqd.1: README.rst
$(RST2MAN) $< > $@

citest: check

check:
./tests/test.sh

# PACKAGE_VERSION
VERSION = $(shell ./configure --version | head -n 1 | sed -e 's/.* //')
RXVERSION = $(shell echo $(VERSION) | sed 's/\./[.]/g')
NEWS = NEWS.rst
TAG = v$(VERSION)

checkver:
@echo "Checking version"
@test -f configure || { echo "need ./configure"; exit 1; }
@grep -q '^pgqd $(RXVERSION)\b' $(NEWS) \
|| { echo "Version '$(VERSION)' not in $(NEWS)"; exit 1; }
@echo "Checking git repo"
@git diff --stat --exit-code || { echo "ERROR: Unclean repo"; exit 1; }

release: checkver
git tag $(TAG)
git push github $(TAG):$(TAG)

unrelease:
git push github :$(TAG)
git tag -d $(TAG)

shownote:
awk -v VER="$(VERSION)" -f etc/note.awk $(NEWS) \
| pandoc -f rst -t gfm --wrap=none

20 changes: 20 additions & 0 deletions etc/note.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# extract version notes for version VER

/^[-_0-9a-zA-Z]+ v?[0-9]/ {
if ($2 == VER) {
good = 1
next
} else {
good = 0
}
}

/^(===|---)/ { next }

{
if (good) {
# also remove sphinx syntax
print gensub(/:(\w+):`~?([^`]+)`/, "``\\2``", "g")
}
}

Loading

0 comments on commit 6bf5bdd

Please sign in to comment.