-
Notifications
You must be signed in to change notification settings - Fork 10
133 lines (114 loc) · 5.12 KB
/
integration-test.yml
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
# 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
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: [ 'stable30', 'stable29', 'stable28' ]
server-versions: [ 'stable30' ]
name: Integration test
steps:
- name: Checkout nextcloud
uses: actions/checkout@v3
with:
path: server
repository: nextcloud/server
ref: ${{ matrix.server-versions }}
- name: Checkout app
uses: actions/checkout@v3
with:
path: server/apps/${{ env.APP_NAME }}
- name: Set up php
uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d # v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
working-directory: server/apps/${{ env.APP_NAME }}
run: composer i
- name: Install nextcloud
working-directory: server/
run: |
git submodule update --init
php occ maintenance:install --verbose --admin-user admin --admin-pass admin
- name: Install app
working-directory: server/
run: |
php occ app:enable integration_dropbox
- name: Run Nextcloud
working-directory: server/
run: php -S localhost:8080 &
- name: Prepare config
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: 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
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
diff result.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