-
Notifications
You must be signed in to change notification settings - Fork 3
199 lines (173 loc) · 6.79 KB
/
Copy pathci.yaml
File metadata and controls
199 lines (173 loc) · 6.79 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: CI
on:
push:
branches: ["main"]
tags: ["v*"]
paths-ignore:
- "**/*.md"
- "doc/**"
pull_request:
paths-ignore:
- "**/*.md"
- "doc/**"
# Cancel in-progress runs for the same branch (except main)
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ !contains(github.ref, 'main') }}
jobs:
format:
name: "Format check"
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check Rust formatting
run: cargo fmt --all -- --check
test:
name: "Regression tests (PG${{ matrix.pg_version }})"
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
pg_version: [17, 18]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build pg_duckpipe builder image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
target: builder
build-args: PG_VERSION=${{ matrix.pg_version }}
load: true
tags: pg_duckpipe:builder-${{ matrix.pg_version }}
cache-from: type=gha,scope=ci-builder-pg${{ matrix.pg_version }}
cache-to: type=gha,mode=max,scope=ci-builder-pg${{ matrix.pg_version }}
- name: Run regression tests
id: run-tests
run: |
docker run --rm \
-v ${{ github.workspace }}/test:/build/pg_duckpipe/test \
-v /tmp/regression-output-${{ matrix.pg_version }}:/results \
pg_duckpipe:builder-${{ matrix.pg_version }} bash -c '
set -euo pipefail
PG_CONFIG=/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config
PG_LIB=$(${PG_CONFIG} --pkglibdir)
chown -R postgres:postgres /build
# pg_regress refuses to run as root — switch to the postgres user
su postgres -s /bin/bash -c "
export LD_LIBRARY_PATH=${PG_LIB}
make -C /build/pg_duckpipe/test/regression check-regression \
PG_CONFIG=${PG_CONFIG}
" || {
mkdir -p /results
cp /build/pg_duckpipe/test/regression/regression.diffs /results/ 2>/dev/null || true
cp -r /build/pg_duckpipe/test/regression/log/ /results/log/ 2>/dev/null || true
cp -r /tmp/pg_duckpipe_test_log/ /results/pg_log/ 2>/dev/null || true
chmod -R a+rX /results/ 2>/dev/null || true
exit 1
}
'
- name: Upload regression artifacts
if: failure() && steps.run-tests.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: regression-output-pg${{ matrix.pg_version }}
path: /tmp/regression-output-${{ matrix.pg_version }}/
- name: Print logs on failure
if: failure() && steps.run-tests.outcome == 'failure'
run: |
echo "=== regression.diffs ==="
cat /tmp/regression-output-${{ matrix.pg_version }}/regression.diffs || echo "(not found)"
echo ""
for f in /tmp/regression-output-${{ matrix.pg_version }}/log/*; do
[ -f "$f" ] || continue
echo "=== $(basename "$f") (last 100 lines) ==="
tail -100 "$f"
echo ""
done
echo "=== postgresql.log (last 200 lines) ==="
tail -200 /tmp/regression-output-${{ matrix.pg_version }}/pg_log/postgresql.log || echo "(not found)"
echo ""
exit 1
test-daemon:
name: "Daemon E2E tests (PG${{ matrix.pg_version }})"
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
pg_version: [17, 18]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build pg_duckpipe builder image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
target: builder
build-args: PG_VERSION=${{ matrix.pg_version }}
load: true
tags: pg_duckpipe:builder-${{ matrix.pg_version }}
cache-from: type=gha,scope=ci-builder-pg${{ matrix.pg_version }}
cache-to: type=gha,mode=max,scope=ci-builder-pg${{ matrix.pg_version }}
- name: Run daemon E2E tests
id: run-daemon-tests
run: |
docker run --rm \
-v ${{ github.workspace }}/test:/build/pg_duckpipe/test \
-v /tmp/daemon-output-${{ matrix.pg_version }}:/results \
pg_duckpipe:builder-${{ matrix.pg_version }} bash -c '
set -euo pipefail
PG_VERSION=${{ matrix.pg_version }}
PG_CONFIG=/usr/lib/postgresql/${PG_VERSION}/bin/pg_config
PG_LIB=$(${PG_CONFIG} --pkglibdir)
# Build daemon binary
cd /build/pg_duckpipe
DUCKDB_LIB_DIR="${PG_LIB}" \
LD_LIBRARY_PATH="${PG_LIB}" \
cargo build --release -p duckpipe-daemon
chown -R postgres:postgres /build
# Run daemon tests as postgres user
su postgres -s /bin/bash -c "
export LD_LIBRARY_PATH=${PG_LIB}
export PG_CONFIG=${PG_CONFIG}
export DUCKPIPE_BIN=/build/pg_duckpipe/target/release/duckpipe
cd /build/pg_duckpipe/test/daemon
bash run_tests.sh
" || {
mkdir -p /results
cp -r /build/pg_duckpipe/test/daemon/log/ /results/log/ 2>/dev/null || true
cp -r /tmp/pg_duckpipe_daemon_test_log/ /results/pg_log/ 2>/dev/null || true
chmod -R a+rX /results/ 2>/dev/null || true
exit 1
}
'
- name: Upload daemon test artifacts
if: failure() && steps.run-daemon-tests.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: daemon-output-pg${{ matrix.pg_version }}
path: /tmp/daemon-output-${{ matrix.pg_version }}/
- name: Print daemon logs on failure
if: failure() && steps.run-daemon-tests.outcome == 'failure'
run: |
echo "=== Daemon test logs ==="
for f in /tmp/daemon-output-${{ matrix.pg_version }}/log/*; do
[ -f "$f" ] || continue
echo "=== $(basename "$f") (last 100 lines) ==="
tail -100 "$f"
echo ""
done
echo "=== postgresql.log (last 200 lines) ==="
tail -200 /tmp/daemon-output-${{ matrix.pg_version }}/pg_log/postgresql.log || echo "(not found)"
echo ""
exit 1