-
Notifications
You must be signed in to change notification settings - Fork 12
277 lines (242 loc) · 9.86 KB
/
Copy pathmigration-test.yml
File metadata and controls
277 lines (242 loc) · 9.86 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
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
270
271
272
273
274
275
276
277
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Migration test
on:
pull_request:
branches:
- main
- stable*
env:
APP_NAME: context_chat
PHP_EXTENSIONS: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite, pgsql, pdo_pgsql, mysql, pdo_mysql, oci8
permissions:
contents: read
concurrency:
group: migration-test-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-latest-low
permissions:
contents: read
pull-requests: read
outputs:
src: ${{ steps.changes.outputs.src }}
steps:
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: changes
continue-on-error: true
with:
filters: |
src:
- '.github/workflows/migration-test.yml'
- 'lib/Migration/**'
- 'lib/Repair/**'
migration-test:
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.src != 'false'
strategy:
fail-fast: false
matrix:
include:
- db: sqlite
db-type: sqlite
db-port: ''
- db: pgsql
db-type: pgsql
db-port: '4445'
- db: mysql
db-type: mysql
db-port: '4444'
- db: mariadb
db-type: mysql
db-port: '4446'
- db: oci21
db-type: oci
db-port: '1521'
oci-version: '21'
oci-flavour: xe
oci-name: XE
- db: oci23
db-type: oci
db-port: '1521'
oci-version: '23'
oci-flavour: free
oci-name: FREE
name: Migration test ${{ matrix.db }}
steps:
- name: Start postgres
if: matrix.db == 'pgsql'
run: |
docker run -d --name db \
-e POSTGRES_USER=root \
-e POSTGRES_PASSWORD=rootpassword \
-e POSTGRES_DB=nextcloud \
-p 4445:5432 \
postgres:17 # zizmor: ignore[unpinned-images]
timeout 60 bash -c 'until docker exec db pg_isready -U root; do sleep 1; done'
- name: Start mysql
if: matrix.db == 'mysql'
run: |
docker run -d --name db \
-e MYSQL_ROOT_PASSWORD=rootpassword \
-p 4444:3306 \
mysql:8.4 # zizmor: ignore[unpinned-images]
timeout 60 bash -c 'until docker exec db mysqladmin ping -prootpassword --silent; do sleep 1; done'
- name: Start mariadb
if: matrix.db == 'mariadb'
run: |
docker run -d --name db \
-e MARIADB_ROOT_PASSWORD=rootpassword \
-p 4446:3306 \
mariadb:11.4 # zizmor: ignore[unpinned-images]
timeout 60 bash -c 'until docker exec db mariadb-admin ping -prootpassword --silent; do sleep 1; done'
- name: Start oracle
if: startsWith(matrix.db, 'oci')
run: |
docker run -d --name db \
-e ORACLE_PASSWORD=oracle \
-p 1521:1521 \
ghcr.io/gvenzl/oracle-${{ matrix.oci-flavour }}:${{ matrix.oci-version }} # zizmor: ignore[unpinned-images]
timeout 300 bash -c 'until docker exec db healthcheck.sh; do sleep 5; done'
- name: Checkout server
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: nextcloud/server
ref: ${{ github.base_ref == 'main' && 'master' || github.base_ref }}
submodules: recursive
persist-credentials: false
- name: Checkout viewer
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: nextcloud/viewer
path: apps/viewer
ref: ${{ github.base_ref == 'main' && 'master' || github.base_ref }}
persist-credentials: false
- name: Set up php 8.3
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1
with:
php-version: '8.3'
extensions: ${{ env.PHP_EXTENSIONS }}
coverage: none
ini-file: development
ini-values: disable_functions=
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout app and fetch all tags
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: nextcloud/${{ env.APP_NAME }}
path: apps/${{ env.APP_NAME }}
fetch-depth: 0
persist-credentials: false
- name: Switch to previous release tag
id: prev-tag
working-directory: apps/${{ env.APP_NAME }}
run: |
PREV_TAG=$(git tag --sort=-version:refname | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
if [ -z "$PREV_TAG" ]; then
echo "No previous release tag found"
exit 1
fi
echo "tag=${PREV_TAG}" >> $GITHUB_OUTPUT
git checkout "$PREV_TAG"
- name: Set up Nextcloud (${{ matrix.db }})
run: |
mkdir -p data
if [ "${{ matrix.db }}" = "sqlite" ]; then
./occ maintenance:install --verbose \
--database=sqlite --database-name=nextcloud \
--admin-user admin --admin-pass admin
elif [ "${{ matrix.db-type }}" = "oci" ]; then
./occ maintenance:install --verbose \
--database=oci \
--database-name=${{ matrix.oci-name }} \
--database-host=127.0.0.1 \
--database-port=${{ matrix.db-port }} \
--database-user=system \
--database-pass=oracle \
--admin-user admin --admin-pass admin
else
./occ maintenance:install --verbose \
--database=${{ matrix.db-type }} \
--database-name=nextcloud \
--database-host=127.0.0.1 \
--database-port=${{ matrix.db-port }} \
--database-user=root \
--database-pass=rootpassword \
--admin-user admin --admin-pass admin
fi
./occ config:system:set debug --value true
./occ config:system:set loglevel --value 1
- name: Enable app (previous version ${{ steps.prev-tag.outputs.tag }})
run: ./occ app:enable --force ${{ env.APP_NAME }}
- name: Check if the previous version installed correctly
run: |
./occ status
./occ app:list --output json | jq -e '.enabled | has("${{ env.APP_NAME }}")'
./occ migrations:status ${{ env.APP_NAME }}
- name: Dump database before upgrade
if: always()
run: |
if [ "${{ matrix.db }}" = "sqlite" ]; then
cp data/nextcloud.db /tmp/${{ matrix.db }}_before.db
elif [ "${{ matrix.db }}" = "pgsql" ]; then
docker exec db pg_dump -U root nextcloud > /tmp/${{ matrix.db }}_before.sql
elif [ "${{ matrix.db }}" = "mysql" ]; then
docker exec db mysqldump -uroot -prootpassword nextcloud > /tmp/${{ matrix.db }}_before.sql
elif [ "${{ matrix.db }}" = "mariadb" ]; then
docker exec db mariadb-dump -uroot -prootpassword nextcloud > /tmp/${{ matrix.db }}_before.sql
elif [[ "${{ matrix.db }}" == oci* ]]; then
docker exec db expdp system/oracle@${{ matrix.oci-name }} directory=DATA_PUMP_DIR dumpfile=${{ matrix.db }}_before.dmp logfile=${{ matrix.db }}_before_expdp.log schemas=NEXTCLOUD || true
docker cp db:/opt/oracle/admin/${{ matrix.oci-name }}/dpdump/${{ matrix.db }}_before.dmp /tmp/ || true
fi
- name: Checkout app at PR version
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: apps/${{ env.APP_NAME }}
persist-credentials: false
- name: Run occ upgrade
run: ./occ upgrade -vvv
- name: Check if the PR version upgraded correctly
run: |
./occ status
./occ app:list --output json | jq -e '.enabled | has("${{ env.APP_NAME }}")'
./occ migrations:status ${{ env.APP_NAME }}
- name: Dump database after upgrade
if: always()
run: |
if [ "${{ matrix.db }}" = "sqlite" ]; then
cp data/nextcloud.db /tmp/${{ matrix.db }}_after.db
elif [ "${{ matrix.db }}" = "pgsql" ]; then
docker exec db pg_dump -U root nextcloud > /tmp/${{ matrix.db }}_after.sql
elif [ "${{ matrix.db }}" = "mysql" ]; then
docker exec db mysqldump -uroot -prootpassword nextcloud > /tmp/${{ matrix.db }}_after.sql
elif [ "${{ matrix.db }}" = "mariadb" ]; then
docker exec db mariadb-dump -uroot -prootpassword nextcloud > /tmp/${{ matrix.db }}_after.sql
elif [[ "${{ matrix.db }}" == oci* ]]; then
docker exec db expdp system/oracle@${{ matrix.oci-name }} directory=DATA_PUMP_DIR dumpfile=${{ matrix.db }}_after.dmp logfile=${{ matrix.db }}_after_expdp.log schemas=NEXTCLOUD || true
docker cp db:/opt/oracle/admin/${{ matrix.oci-name }}/dpdump/${{ matrix.db }}_after.dmp /tmp/ || true
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.db }}-artifacts
path: |
/tmp/${{ matrix.db }}_before.*
/tmp/${{ matrix.db }}_after.*
data/nextcloud.log
data/context_chat.log
if-no-files-found: ignore
summary:
permissions:
contents: none
runs-on: ubuntu-latest-low
needs: [changes, migration-test]
if: always()
name: migration-test-summary
steps:
- name: Summary status
run: if ${{ needs.changes.outputs.src != 'false' && needs.migration-test.result != 'success' }}; then exit 1; fi