chore: update workflows #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |