Add pgmonitor-extension by CrunchyData (#789) #1282
This file contains 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
name: Build, install and publish extensions | |
on: | |
push: | |
branches: | |
- "main" | |
paths: | |
- "contrib/**" | |
pull_request: | |
branches: | |
- "main" | |
paths: | |
- "contrib/**" | |
jobs: | |
find_directories: | |
name: Find changed extensions | |
runs-on: ubuntu-20.04 | |
outputs: | |
directories: ${{ steps.find_directories.outputs.build_matrix }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Find commit to compare with | |
id: versions | |
run: | | |
set -xe | |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) | |
# On main branch, the diff should compare to the previous commit hash. | |
# On PR, the diff should compare with main branch. | |
if [ "${BRANCH_NAME}" == "main" ]; then | |
changed_relative_to_ref=$(git show --quiet HEAD^1 | grep commit | cut -d" " -f2) | |
else | |
changed_relative_to_ref="origin/${{ github.base_ref || 'not-a-branch' }}" | |
fi | |
echo "changed_relative_to_ref=${changed_relative_to_ref}" >> $GITHUB_OUTPUT | |
- name: Check out the coredb repo to reuse some actions | |
uses: actions/checkout@v4 | |
with: | |
repository: tembo-io/tembo | |
path: ./.tembo | |
ref: 21a43bbd64936b6b7fe7b080c2bfbd82df31fe2c | |
- name: Find directories with Dockerfiles that changed | |
id: find_directories | |
uses: ./.tembo/.github/actions/find-changed-directories | |
with: | |
contains_the_file: Trunk.toml | |
changed_relative_to_ref: ${{ steps.versions.outputs.changed_relative_to_ref }} | |
ignore_dirs: ".tembo cli" | |
test: | |
name: Test extensions | |
runs-on: | |
- self-hosted | |
- dind | |
- xlarge-16x16 | |
container: | |
image: quay.io/tembo/trunk-test-tembo:15-5fe737b | |
options: --user root | |
needs: | |
- find_directories | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.find_directories.outputs.directories) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install system dependencies | |
run: | | |
set -xe | |
apt-get update | |
apt-get install -y pkg-config libssl-dev gosu | |
- name: Test the extension within Docker | |
run: cd ${{ matrix.path }} && trunk build --test | |
build: | |
name: Build extensions | |
runs-on: | |
- self-hosted | |
- dind | |
- xlarge-16x16 | |
container: | |
image: quay.io/tembo/trunk-test-tembo:15-5fe737b | |
options: --user root | |
needs: | |
- find_directories | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.find_directories.outputs.directories) }} | |
env: | |
TRUNK_API_TOKEN: ${{ secrets.TRUNK_AUTH_TOKEN }} | |
PGHOST: "localhost" | |
PGPORT: "5432" | |
PGDATABASE: "postgres" | |
PGUSER: "postgres" | |
PGPASSWORD: "postgres" | |
POSTGRES_PASSWORD: "password" | |
TRUNK_AMPLIFY_WEBHOOK: ${{ secrets.TRUNK_AMPLIFY_WEBHOOK }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install system dependencies | |
run: | | |
set -xe | |
apt-get update | |
apt-get install -y pkg-config libssl-dev gosu | |
- name: Build extension for Postgres 15 | |
run: cd ${{ matrix.path }} && trunk build --pg-version 15 | |
- name: Install the extension | |
run: cd ${{ matrix.path }} && EXTENSION=$(basename ${{ matrix.path }}) && trunk install -f .trunk/*.tar.gz $EXTENSION | |
- name: Build extension for Postgres 14 | |
run: cd ${{ matrix.path }} && trunk build --pg-version 14 | |
continue-on-error: true | |
- name: Build extension for Postgres 16 | |
run: cd ${{ matrix.path }} && trunk build --pg-version 16 | |
continue-on-error: true | |
- name: Handle shared_preload_libraries | |
shell: bash -e {0} | |
run: | | |
for val in pg_cron timescaledb pg_search pg_analytics; do | |
if [[ "${{ matrix.path }}" == *"$val"* ]]; then | |
echo handling shared_preload_libraries for $val | |
echo "shared_preload_libraries = '$val'" >> /var/lib/postgresql/data2/postgresql.conf | |
fi | |
done | |
- name: Enable the extension | |
if: ${{ github.ref != 'refs/heads/main' }} | |
run: | | |
su postgres -c '/usr/lib/postgresql/15/bin/postgres &' | |
sleep 5 | |
export EXTENSIONS=$(psql postgres://postgres:postgres@localhost:5432 -tA -c "select name from pg_available_extensions where name NOT IN ('plpgsql', 'plperlu', 'plperl', 'pltcl', 'plpython3u', 'pltclu', 'pg_stat_statements', 'pgml')";) | |
for EXTENSION in $EXTENSIONS; do | |
echo "enabling extension: $EXTENSION" | |
psql postgres://postgres:postgres@localhost:5432 -c "create extension if not exists \"$EXTENSION\" cascade;" | |
done | |
- name: Publish the extension | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: cd ${{ matrix.path }} && trunk publish | |
- name: Re-build Trunk UI | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
sleep 2 | |
curl -X POST -d '{}' \ | |
"${{ secrets.TRUNK_AMPLIFY_WEBHOOK }}" \ | |
-H "Content-Type:application/json" |