-
Notifications
You must be signed in to change notification settings - Fork 18
147 lines (143 loc) · 5.1 KB
/
extensions.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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: 🧪 ${{ matrix.ext.name }} on 🐘 ${{ matrix.pg }}
runs-on:
- self-hosted
- dind
- xlarge-16x16
container:
image: quay.io/tembo/trunk-test-tembo:b472101-pg15
options: --user root
needs:
- find_directories
strategy:
fail-fast: false
matrix:
ext: ${{ fromJson(needs.find_directories.outputs.directories).include }}
pg: [15]
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.ext.path }} && trunk build --test
build:
name: 📦 ${{ matrix.ext.name }} on 🐘 ${{ matrix.pg }}
runs-on:
- self-hosted
- dind
- xlarge-16x16
container:
image: quay.io/tembo/trunk-test-tembo:b472101-pg15
options: --user root
needs:
- find_directories
strategy:
fail-fast: false
matrix:
ext: ${{ fromJson(needs.find_directories.outputs.directories).include }}
pg: [17, 16, 15, 14]
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
id: build
run: cd ${{ matrix.ext.path }} && trunk build --pg-version ${{ matrix.pg }}
continue-on-error: true
- name: Install the extension
if: matrix.pg == 15
run: cd ${{ matrix.ext.path }} && EXTENSION=${{ matrix.ext.name }} && trunk install -f .trunk/*.tar.gz $EXTENSION
- name: Handle shared_preload_libraries
if: matrix.pg == 15
shell: bash -e {0}
run: |
for val in pg_cron timescaledb pg_search pg_analytics citus; do
if [[ "${{ matrix.ext.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: matrix.pg == 15 && 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: steps.build.outcome == 'success' && github.ref == 'refs/heads/main'
run: cd ${{ matrix.ext.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"