-
Notifications
You must be signed in to change notification settings - Fork 10
147 lines (127 loc) · 6.18 KB
/
integration-test.yml
File metadata and controls
147 lines (127 loc) · 6.18 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
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
#
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT
name: Integration test
on:
pull_request:
push:
branches:
- master
- main
- stable*
env:
APP_NAME: integration_dropbox
permissions:
contents: read
concurrency:
group: integration-test-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
strategy:
# do not stop on another job's failure
fail-fast: false
matrix:
php-versions: [ '8.1' ]
server-versions: [ 'master', 'stable31', 'stable30' ]
name: Integration test
steps:
- name: Checkout nextcloud
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: server
repository: nextcloud/server
ref: ${{ matrix.server-versions }}
- name: Set up php
uses: shivammathur/setup-php@ccf2c627fe61b1b4d924adfcbd19d661a18133a0 # v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
ini-file: development
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, mysql, pdo_mysql
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install nextcloud
working-directory: server/
run: |
git submodule update --init
php occ maintenance:install --verbose --admin-user admin --admin-pass admin
- name: Prepare config (will be encrypted by migration)
working-directory: server/
env:
DROPBOX_CONFIG: ${{ secrets.DROPBOX_CONFIG }}
OAUTH_CLIENT_ID: ${{ secrets.OAUTH_CLIENT_ID }}
OAUTH_CLIENT_SECRET: ${{ secrets.OAUTH_CLIENT_SECRET }}
run: |
echo $DROPBOX_CONFIG > config.json
sudo apt install jq sqlite3
sqlite3 data/owncloud.db "INSERT INTO oc_preferences ( userid, appid, configkey, configvalue) VALUES ('admin', 'integration_dropbox', 'account_id', $(cat config.json | jq '.config.account_id'));"
sqlite3 data/owncloud.db "INSERT INTO oc_preferences ( userid, appid, configkey, configvalue) VALUES ('admin', 'integration_dropbox', 'token', $(cat config.json | jq '.config.token'));"
sqlite3 data/owncloud.db "INSERT INTO oc_preferences ( userid, appid, configkey, configvalue) VALUES ('admin', 'integration_dropbox', 'refresh_token', $(cat config.json | jq '.config.refresh_token'));"
sqlite3 data/owncloud.db "INSERT INTO oc_preferences ( userid, appid, configkey, configvalue) VALUES ('admin', 'integration_dropbox', 'importing_dropbox', '1');"
sqlite3 data/owncloud.db "INSERT INTO oc_appconfig ( appid, configkey, configvalue) VALUES ('integration_dropbox', 'client_id', '$OAUTH_CLIENT_ID');"
sqlite3 data/owncloud.db "INSERT INTO oc_appconfig ( appid, configkey, configvalue) VALUES ('integration_dropbox', 'client_secret', '$OAUTH_CLIENT_SECRET');"
- name: Checkout app
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: server/apps/${{ env.APP_NAME }}
- name: Install dependencies
working-directory: server/apps/${{ env.APP_NAME }}
run: composer i
- name: Install app
working-directory: server/
run: |
php occ app:enable integration_dropbox -vvv
# for good measure
sed -i '$d' config/config.php && echo " 'debug' => true," >> config/config.php && echo ");" >> config/config.php
php occ migrations:execute integration_dropbox 030002Date20241021105515
- name: Run Nextcloud
working-directory: server/
run: php -S localhost:8080 &
- name: Run import
working-directory: server/
run: |
php occ integration_dropbox:start-import admin
for run in {1..10}; do date; echo "run $run starting"; php cron.php; ls -lh data/admin/files/Dropbox\ import/ ; echo "run $run done"; done
date
du -shc data/admin/files/Dropbox\ import/*
- name: Check import result
if: always()
working-directory: server/
run: |
sqlite3 data/owncloud.db "SELECT * from oc_preferences where configkey = 'nb_imported_files';" > result.txt
sqlite3 data/owncloud.db "SELECT * from oc_preferences where configkey = 'importing_dropbox';" >> result.txt
sqlite3 data/owncloud.db "SELECT * from oc_preferences where configkey = 'last_import_error';" >> result.txt
cat > result.expected.txt <<- EOM
admin|integration_dropbox|nb_imported_files|0
admin|integration_dropbox|importing_dropbox|0
admin|integration_dropbox|last_import_error|
EOM
cat > result.nc31.expected.txt <<- EOM
admin|integration_dropbox|nb_imported_files|0|0|0|0|
admin|integration_dropbox|importing_dropbox|0|0|0|0|
admin|integration_dropbox|last_import_error||0|0|0|
EOM
diff result.expected.txt result.txt || diff result.nc31.expected.txt result.txt
cat > du-sh.expected.txt <<- EOM
1.6G data/admin/files/Dropbox import/
EOM
echo CHECK "du -shc --apparent-size data/admin/files/Dropbox\ import/*"
du -shc --apparent-size data/admin/files/Dropbox\ import/*
echo CHECK "md5sum data/admin/files/Dropbox\ import/*"
md5sum data/admin/files/Dropbox\ import/*
echo END CHECKS
du -sh --apparent-size data/admin/files/Dropbox\ import/ | diff du-sh.expected.txt -
- name: Show log on failure
working-directory: server/
if: always()
run: |
du -sh data/admin/files/Dropbox\ import/
cat result.txt || echo "No result"
tail data/nextcloud.log