-
Notifications
You must be signed in to change notification settings - Fork 882
269 lines (247 loc) · 10.6 KB
/
windows-build-and-test.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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# Test building the extension on Windows
name: Regression Windows
"on":
schedule:
# run daily 0:00 on main branch
- cron: '0 0 * * *'
push:
branches:
- main
- prerelease_test
- trigger/windows_tests
paths-ignore:
- '**.md'
- 'LICENSE*'
- NOTICE
- 'bootstrap*'
pull_request:
paths-ignore:
- '**.md'
- 'LICENSE*'
- NOTICE
- 'bootstrap*'
jobs:
config:
runs-on: ubuntu-latest
outputs:
build_type: ${{ steps.build_type.outputs.build_type }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Read configuration
id: config
run: python .github/gh_config_reader.py
- name: Set build_type
id: build_type
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "build_type=['Debug']" >>$GITHUB_OUTPUT
else
echo "build_type=['Debug','Release']" >>$GITHUB_OUTPUT
fi
build:
# Change the JOB_NAME variable below when changing the name.
name: PG${{ matrix.pg }} ${{ matrix.build_type }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: config
strategy:
fail-fast: false
matrix:
pg: [ 14, 15, 16, 17 ]
os: [ windows-2022 ]
build_type: ${{ fromJson(needs.config.outputs.build_type) }}
ignores: ["chunk_adaptive metadata telemetry"]
tsl_ignores: ["compression_algos"]
tsl_skips: ["bgw_db_scheduler bgw_db_scheduler_fixed"]
pg_config: ["-cfsync=off -cstatement_timeout=60s"]
env:
# PostgreSQL configuration
PGPORT: 55432
PGDATA: pgdata
TABLESPACE1: D:\tablespace1\
TABLESPACE2: D:\tablespace2\
steps:
- name: Setup WSL
uses: Vampire/[email protected]
with:
additional-packages:
cmake
gawk
gcc
git
gnupg
make
postgresql-client
postgresql-common
tree
- name: Configure git
# Since we want to reuse the checkout in the WSL environment
# we have to prevent git from changing the line ending in the
# shell scripts as that would break them.
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout TimescaleDB source
uses: actions/checkout@v4
# We are going to rebuild Postgres daily, so that it doesn't suddenly break
# ages after the original problem.
- name: Get date for build caching
id: get-date
env:
WSLENV: GITHUB_OUTPUT/p
shell: wsl-bash {0}
run: |
echo "date=$(date +"%d")" >> $GITHUB_OUTPUT
# Use a cache for the PostgreSQL installation to speed things up
# and avoid unnecessary package downloads. Since we only save
# the directory containing the binaries, the runs with a cache
# hit won't have PostgreSQL installed with a running service
# since the installer never runs. We therefore install with
# --extract-only and launch our own test instance, which is
# probably better anyway since it gives us more control.
- name: Cache PostgreSQL installation
uses: actions/cache@v4
id: cache-postgresql
with:
path: ~\PostgreSQL\${{ matrix.pg }}
key: "${{ runner.os }}-build-pg${{ matrix.pkg_version }}\
-${{ steps.get-date.outputs.date }}-${{ hashFiles('.github/**') }}"
# Force install PostgreSQL 17 since the package still on moderation
# https://community.chocolatey.org/packages/postgresql17
- name: Install PostgreSQL ${{ matrix.pg }}
if: steps.cache-postgresql.outputs.cache-hit != 'true'
run: |
choco feature disable --name=usePackageExitCodes
choco feature disable --name=showDownloadProgress
if(${{ matrix.pg }} -eq 17) {
choco install postgresql${{ matrix.pg }} --version 17.0.0 `
--force -y --install-args="'--prefix $HOME\PostgreSQL\${{ matrix.pg }} --extract-only yes'"
} else {
choco install postgresql${{ matrix.pg }} `
--force -y --install-args="'--prefix $HOME\PostgreSQL\${{ matrix.pg }} --extract-only yes'"
}
- name: Configure TimescaleDB
run: cmake -B build_win -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} `
-DPG_PATH="$HOME/PostgreSQL/${{ matrix.pg }}" `
-DOPENSSL_ROOT_DIR="$HOME/PostgreSQL/${{ matrix.pg }}" -DASSERTIONS=ON `
-DTEST_PG_LOG_DIRECTORY="log"
- name: Build TimescaleDB
run: cmake --build build_win --config ${{ matrix.build_type }}
- name: Install TimescaleDB
run: cmake --install build_win --config ${{ matrix.build_type }}
- name: Setup postgres cluster
run: |
~/PostgreSQL/${{ matrix.pg }}/bin/initdb -U postgres -A trust --locale=en_US --encoding=UTF8
mkdir -p ${{ env.TABLESPACE1 }}\_default
mkdir -p ${{ env.TABLESPACE2 }}\_default
icacls ${{ env.TABLESPACE1 }} /grant runneradmin:F /T
icacls ${{ env.TABLESPACE2 }} /grant runneradmin:F /T
copy build_win/test/postgresql.conf ${{ env.PGDATA }}
copy build_win/test/pg_hba.conf ${{ env.PGDATA }}
icacls . /grant runneradmin:F /T
~/PostgreSQL/${{ matrix.pg }}/bin/pg_ctl start -o "${{ matrix.pg_config }}" --log=postmaster.log
~/PostgreSQL/${{ matrix.pg }}/bin/pg_isready -U postgres -d postgres --timeout=60
~/PostgreSQL/${{ matrix.pg }}/bin/psql -U postgres -d postgres -c 'CREATE USER root SUPERUSER LOGIN;'
echo "PG version:"
~/PostgreSQL/${{ matrix.pg }}/bin/psql -U postgres -d postgres -c 'SELECT version();'
echo "Log configuration:"
~/PostgreSQL/${{ matrix.pg }}/bin/psql -U postgres -d postgres -c 'SHOW logging_collector;'
~/PostgreSQL/${{ matrix.pg }}/bin/psql -U postgres -d postgres -c 'SHOW log_filename;'
~/PostgreSQL/${{ matrix.pg }}/bin/psql -U postgres -d postgres -c 'SHOW log_directory;'
~/PostgreSQL/${{ matrix.pg }}/bin/psql -U postgres -d postgres -c 'SELECT pg_current_logfile();'
echo "Data directory:"
~/PostgreSQL/${{ matrix.pg }}/bin/psql -U postgres -d postgres -c 'SHOW data_directory;'
- name: Install postgres for test runner
shell: wsl-bash {0}
run: |
yes | /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh || true
apt-get install -y --force-yes postgresql-server-dev-${{ matrix.pg }}
- name: Run tests
shell: wsl-bash {0}
run: |
export TEST_TABLESPACE1_PREFIX='${{ env.TABLESPACE1 }}'
export TEST_TABLESPACE2_PREFIX='${{ env.TABLESPACE2 }}'
cmake -B build_wsl -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DTEST_PGPORT_LOCAL=${{ env.PGPORT }}
# isolationtester is only packaged with pg14+ so we would have to build our own postgres
# to get it for earlier versions so we skip it for < 14.
if [[ "${{ matrix.pg }}" -ge "14" ]]; then
make -C build_wsl isolationchecklocal | tee -a installcheck.log
fi
make -C build_wsl regresschecklocal IGNORES="${{ matrix.ignores }}" | tee -a installcheck.log
- name: Setup postgres cluster for TSL tests
run: |
~/PostgreSQL/${{ matrix.pg }}/bin/pg_ctl stop
timeout 10
Remove-Item -Recurse ${{ env.PGDATA }}
~/PostgreSQL/${{ matrix.pg }}/bin/initdb -U postgres -A trust --locale=en_US --encoding=UTF8
copy build_win/tsl/test/postgresql.conf ${{ env.PGDATA }}
copy build_win/tsl/test/pg_hba.conf ${{ env.PGDATA }}
~/PostgreSQL/${{ matrix.pg }}/bin/pg_ctl start -o "${{ matrix.pg_config }}" --log="postmaster.log"
~/PostgreSQL/${{ matrix.pg }}/bin/pg_isready -U postgres -d postgres --timeout=30
~/PostgreSQL/${{ matrix.pg }}/bin/psql -U postgres -d postgres -c 'CREATE USER root SUPERUSER LOGIN;'
- name: Run TSL tests
shell: wsl-bash {0}
run: |
export TEST_TABLESPACE1_PREFIX='${{ env.TABLESPACE1 }}'
export TEST_TABLESPACE2_PREFIX='${{ env.TABLESPACE2 }}'
# isolationtester is only packaged with pg14+ so we would have to build our own postgres
# to get it for earlier versions so we skip it for < 14.
if [[ "${{ matrix.pg }}" -ge "14" ]]; then
make -C build_wsl isolationchecklocal-t | tee -a installcheck.log
fi
make -C build_wsl -k regresschecklocal-t \
IGNORES="${{ matrix.tsl_ignores }} ${{ matrix.tsl_ignores_version }}" \
SKIPS="${{ matrix.tsl_skips }} ${{ matrix.tsl_skips_version }}" | tee -a installcheck.log
- name: Show regression diffs
id: collectlogs
if: always()
env:
WSLENV: GITHUB_OUTPUT/p
shell: wsl-bash {0}
run: |
find . -name regression.diffs -exec cat {} + > regression.log
if [[ -s regression.log ]]; then echo "regression_diff=true" >>$GITHUB_OUTPUT; fi
grep -e 'FAILED' -e 'failed (ignored)' -e 'not ok' installcheck.log || true
cat regression.log
- name: Save regression diffs
if: always() && steps.collectlogs.outputs.regression_diff == 'true'
uses: actions/upload-artifact@v4
with:
name: Regression ${{ matrix.pg }} diff ${{ matrix.os }} ${{ matrix.build_type }} Build
path: |
regression.log
installcheck.log
- name: Save PostgreSQL log
if: always()
uses: actions/upload-artifact@v4
with:
name: PostgreSQL ${{ matrix.pg }} log ${{ matrix.os }} ${{ matrix.build_type }} Build
path: ${{ env.PGDATA }}\log\postmaster.log
- name: Upload test results to the database
if: always()
shell: wsl-bash {0}
env:
# Update when adding new variables.
WSLENV: "JOB_NAME:CI_STATS_DB:GITHUB_EVENT_NAME:GITHUB_REF_NAME\
:GITHUB_REPOSITORY:GITHUB_RUN_ATTEMPT:GITHUB_RUN_ID:GITHUB_RUN_NUMBER:JOB_STATUS"
# GitHub Actions allow you neither to use the env context for the job name,
# nor to access the job name from the step context, so we have to
# duplicate it to work around this nonsense.
JOB_NAME: PG${{ matrix.pg }} ${{ matrix.build_type }} ${{ matrix.os }}
CI_STATS_DB: ${{ secrets.CI_STATS_DB }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }}
GITHUB_RUN_ID: ${{ github.run_id }}
GITHUB_RUN_NUMBER: ${{ github.run_number }}
JOB_STATUS: ${{ job.status }}
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]] ;
then
GITHUB_PR_NUMBER="${{ github.event.number }}"
else
GITHUB_PR_NUMBER=0
fi
export GITHUB_PR_NUMBER
scripts/upload_ci_stats.sh