83 lines
3.1 KiB
YAML
83 lines
3.1 KiB
YAML
name: Test
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- stable*
|
|
pull_request:
|
|
|
|
jobs:
|
|
test-api:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
version: [min, max]
|
|
fail-fast: false
|
|
env:
|
|
SERVER_BRANCH: master
|
|
PHPUNIT: phpunit
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Determine PHP version
|
|
env:
|
|
VERSION_MINMAX: ${{ matrix.version }}
|
|
run: echo "PHP_VERSION=$(php tests/nextcloud-version.php --php-$VERSION_MINMAX)" >> $GITHUB_ENV
|
|
- name: Use compatible PHPUNIT version for old PHP
|
|
if: env.PHP_VERSION == '7.2'
|
|
run: echo "PHPUNIT=phpunit:8.5.14" >> $GITHUB_ENV
|
|
- name: Set up PHP ${{ env.PHP_VERSION }}
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ env.PHP_VERSION }}
|
|
extensions: pdo_mysql, zip, gd
|
|
tools: ${{ env.PHPUNIT }}
|
|
- name: Install latest dev Nextcloud PHP API (max only)
|
|
if: matrix.version == 'max'
|
|
run: composer require --prefer-dist --dev christophwurst/nextcloud:dev-master
|
|
- name: Install Dependencies
|
|
run: composer install --prefer-dist
|
|
- name: Prepare MySQL database
|
|
run: |
|
|
sudo systemctl start mysql
|
|
mysql -u root -proot -e "CREATE DATABASE nextcloud;"
|
|
mysql -u root -proot -e "CREATE USER 'nextcloud'@'localhost' IDENTIFIED WITH mysql_native_password BY '';"
|
|
mysql -u root -proot -e "GRANT ALL ON nextcloud.* TO 'nextcloud'@'localhost';"
|
|
- name: Select stable Nextcloud server branch
|
|
if: matrix.version == 'min'
|
|
run: echo "SERVER_BRANCH=$(php tests/nextcloud-version.php --serverbranch)" >> $GITHUB_ENV
|
|
- name: Prepare Nextcloud server using ${{ env.SERVER_BRANCH }}
|
|
working-directory: ../
|
|
run: |
|
|
git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${SERVER_BRANCH} server
|
|
cp -r notes server/apps/
|
|
- name: Setup Nextcloud server
|
|
working-directory: ../server/
|
|
run: |
|
|
php occ maintenance:install --database-name nextcloud --database-user nextcloud --admin-user admin --admin-pass admin --database mysql --database-pass=''
|
|
php occ -V
|
|
OC_PASS=test php occ user:add --password-from-env --display-name="Test" test
|
|
OC_PASS=test php occ user:add --password-from-env --display-name="QuotaTest" quotatest
|
|
php occ user:setting quotatest files quota "0"
|
|
- name: Setup Notes app
|
|
working-directory: ../server/
|
|
run: php occ app:enable notes
|
|
- name: Create some reference notes
|
|
working-directory: ../
|
|
run: |
|
|
mkdir -p server/data/test/files/
|
|
mkdir -p server/data/quotatest/files/
|
|
cp -r notes/tests/reference-notes server/data/test/files/Notes
|
|
cp -r notes/tests/reference-notes server/data/quotatest/files/Notes
|
|
chmod 444 server/data/test/files/Notes/ReadOnly/ReadOnly-Note.txt
|
|
php server/occ files:scan --all
|
|
- name: Start Nextcloud server
|
|
working-directory: ../server/
|
|
run: "php -S localhost:8080 &"
|
|
- name: Test API
|
|
run: make test-api
|
|
- name: Show nextcloud.log
|
|
if: always()
|
|
run: "cat ../server/data/nextcloud.log"
|
|
|