Merge pull request #1432 from nextcloud/automated/noid/main-update-ne… #1983
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 | |
# | |
# SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors | |
# SPDX-License-Identifier: MIT | |
name: Test | |
on: | |
push: | |
branches: | |
- main | |
- stable* | |
pull_request: | |
permissions: | |
contents: read | |
jobs: | |
test-api: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
version: [min, max] | |
fail-fast: false | |
env: | |
SERVER_BRANCH: master | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
- name: Determine PHP version | |
env: | |
VERSION_MINMAX: ${{ matrix.version }} | |
run: echo "PHP_VERSION=$(php tests/nextcloud-version.php --php-$VERSION_MINMAX)" >> $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: phpunit:9 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- 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 > data/php.log 2>&1 &" | |
- name: Test API | |
run: make test-api | |
- name: Show nextcloud.log | |
if: always() | |
run: "cat ../server/data/nextcloud.log" | |
- name: Show php.log | |
if: always() | |
run: "cat ../server/data/php.log" | |