Skip to content

chore: update CODEOWNERS (#1173) #194

chore: update CODEOWNERS (#1173)

chore: update CODEOWNERS (#1173) #194

Workflow file for this run

# SPDX-FileCopyrightText: 2023-2025 Jankari Tech Pvt. Ltd.
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: PHP Unit & API Tests
on:
workflow_call:
inputs:
branch:
required: true
type: string
nextcloud_versions:
required: true
type: string
php_versions:
required: true
type: string
push:
branches:
- 'master'
- 'release/**'
pull_request:
paths-ignore:
- 'tests/jest/**'
- '**.md'
- '**.txt'
- '**.sh'
- '**.js'
- 'dev/**'
- 'l10n/**'
- 'img/**'
- 'src/**'
- 'package*.json'
concurrency:
group: php-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
NEXTCLOUD_VERSIONS: ${{ inputs.nextcloud_versions || '31 32' }}
PHP_VERSIONS: ${{ inputs.php_versions || '8.2 8.3 8.4' }}
DEFAULT_PHP_VERSION: '8.4'
DEFAULT_DATABASE: 'mysql'
EXTRA_DATABASES: 'pgsql'
jobs:
create-matrix:
runs-on: ubuntu-22.04
steps:
- name: Checkout
if: github.event_name != 'schedule'
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
- name: Checkout (Nightly)
if: github.event_name == 'schedule'
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
with:
ref: ${{ inputs.branch }}
- name: Create matrix
id: create-matrix
env:
NEXTCLOUD_VERSIONS: ${{ env.NEXTCLOUD_VERSIONS }}
PHP_VERSIONS: ${{ env.PHP_VERSIONS }}
DEFAULT_PHP_VERSION: ${{ env.DEFAULT_PHP_VERSION }}
DEFAULT_DATABASE: ${{ env.DEFAULT_DATABASE }}
EXTRA_DATABASES: ${{ env.EXTRA_DATABASES }}
run: |
MATRIX=$(./.github/scripts/generate-matrix.sh)
echo "matrix={\"include\": [$MATRIX]}" >> $GITHUB_OUTPUT
echo "default_php_version=${DEFAULT_PHP_VERSION}" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.create-matrix.outputs.matrix }}
default_php_version: ${{ steps.create-matrix.outputs.default_php_version }}
api-phpunit-tests:
name: PHP Unit & API tests
needs: create-matrix
if: ${{ success() }}
strategy:
matrix: ${{ fromJson(needs.create-matrix.outputs.matrix) }}
runs-on: ubuntu-22.04
defaults:
run:
working-directory: integration_openproject
services:
nextcloud:
image: ghcr.io/juliusknorr/nextcloud-dev-php${{ format('{0}{1}', matrix.phpVersionMajor,matrix.phpVersionMinor) }}:master
env:
SQL: ${{ matrix.database }}
SERVER_BRANCH: ${{ matrix.nextcloudVersion }}
NEXTCLOUD_AUTOINSTALL: 'Yes'
WITH_REDIS: 'YES'
ports:
- 80:80
options: --name=nextcloud
volumes:
- ${{ github.workspace }}:/var/www/html/apps-shared
database-pgsql:
image: ghcr.io/nextcloud/continuous-integration-postgres-18:latest
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: nextcloud
database-mysql:
image: ghcr.io/nextcloud/continuous-integration-mariadb-11.8:latest
env:
MYSQL_ROOT_PASSWORD: 'nextcloud'
MYSQL_PASSWORD: 'nextcloud'
MYSQL_USER: 'nextcloud'
MYSQL_DATABASE: 'nextcloud'
redis:
image: ghcr.io/nextcloud/continuous-integration-redis:latest
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
if: github.event_name != 'schedule'
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
with:
path: integration_openproject
- name: Checkout (Nightly)
if: github.event_name == 'schedule'
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
with:
path: integration_openproject
ref: ${{ inputs.branch }}
- name: Checkout server (for phpunit and psalm)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
with:
submodules: true
repository: nextcloud/server
path: integration_openproject/server
ref: ${{ matrix.nextcloudVersion }}
# activity app cannot be installed using occ command
- name: Checkout (activity)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
with:
repository: nextcloud/activity
ref: ${{ matrix.nextcloudVersion }}
path: activity
- name: Checkout (groupfolders)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
if: ${{ matrix.nextcloudVersion == 'master' }}
with:
repository: nextcloud/groupfolders
path: groupfolders
- name: Checkout (user_oidc)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
if: ${{ matrix.nextcloudVersion == 'master' }}
with:
repository: nextcloud/user_oidc
path: user_oidc
- name: Checkout (oidc)
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
if: ${{ matrix.nextcloudVersion == 'master' }}
with:
repository: h2CK/oidc
path: oidc
- name: Setup PHP ${{ format('{0}.{1}', matrix.phpVersionMajor,matrix.phpVersionMinor) }}
uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d
with:
php-version: ${{ format('{0}.{1}', matrix.phpVersionMajor,matrix.phpVersionMinor) }}
tools: composer, phpunit
coverage: xdebug
extensions: intl, gd, sqlite3
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache PHP dependencies
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('./composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Composer update
if: ${{ matrix.phpVersion == '8.5' }}
run: composer update
- name: Composer install
if: ${{ matrix.phpVersion != '8.5' }}
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Prepare Nextcloud server (for phpunit and psalm)
run: server/occ maintenance:install --admin-pass=admin
- name: PHP code analysis and linting
run: |
make psalm
make phpcs || ( echo 'Please run `make phpcs-fix` to format your code' && exit 1 )
- name: Setup dependent apps
run: |
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader --working-dir=../activity
cp -r ../activity server/apps
if [ "${{matrix.nextcloudVersion}}" == "master" ]; then
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader --working-dir=../user_oidc
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader --working-dir=../oidc
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader --working-dir=../groupfolders
cp -r ../oidc ../user_oidc ../groupfolders server/apps
fi
- name: Enable apps (for phpunit)
run: |
mkdir -p server/apps/integration_openproject
cp -r `ls -A | grep -v 'server'` server/apps/integration_openproject/
cd server
if [ "${{matrix.nextcloudVersion}}" == "master" ]; then
# enable app even if it is not compatible with the master branch
./occ a:e -f activity oidc user_oidc groupfolders integration_openproject
else
./occ a:e activity oidc user_oidc groupfolders integration_openproject
cp -r apps/oidc apps/user_oidc apps/groupfolders ${{ github.workspace }}
fi
- name: PHP Unit Tests
run: |
cd server/apps/integration_openproject
make phpunit || (echo "A few of the unit tests were unsuccessful. Rerunning the unit test once again......" && make phpunit)
- name: Setup .NET Core # this is required to execute Convert PHP cobertura coverage to lcov step
if: ${{ github.event_name == 'pull_request' && matrix.nextcloudVersion == 'stable32' && matrix.phpVersion == needs.create-matrix.outputs.default_php_version && matrix.database == 'mysql' }}
uses: actions/setup-dotnet@baa11fbfe1d6520db94683bd5c7a3818018e4309
with:
dotnet-version: 6.0.101
dotnet-quality: 'ga'
- name: Convert PHP cobertura coverage to lcov
if: ${{ github.event_name == 'pull_request' && matrix.nextcloudVersion == 'stable32' && matrix.phpVersion == needs.create-matrix.outputs.default_php_version && matrix.database == 'mysql' }}
uses: danielpalme/ReportGenerator-GitHub-Action@abaac9fef72e4116bfc69905d51062790bda0335
with:
reports: 'integration_openproject/server/apps/integration_openproject/coverage/php/cobertura.xml' # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
targetdir: 'integration_openproject/server/apps/integration_openproject/coverage/php' # REQUIRED # The directory where the generated report should be saved.
reporttypes: 'lcov' # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, Xml, XmlSummary
sourcedirs: '' # Optional directories which contain the corresponding source code (separated by semicolon). The source directories are used if coverage report contains classes without path information.
historydir: '' # Optional directory for storing persistent coverage information. Can be used in future reports to show coverage evolution.
plugins: '' # Optional plugin files for custom reports or custom history storage (separated by semicolon).
assemblyfilters: '+*' # Optional list of assemblies that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
classfilters: '+*' # Optional list of classes that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
filefilters: '+*' # Optional list of files that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
verbosity: 'Verbose' # The verbosity level of the log messages. Values: Verbose, Info, Warning, Error, Off
title: '' # Optional title.
tag: '${{ github.run_number }}_${{ github.run_id }}' # Optional tag or build version.
customSettings: '' # Optional custom settings (separated by semicolon). See: https://github.com/danielpalme/ReportGenerator/wiki/Settings.
toolpath: 'reportgeneratortool' # Default directory for installing the dotnet tool.
- name: PHP Code Coverage Summary Report
if: ${{ github.event_name == 'pull_request' && matrix.nextcloudVersion == 'stable32' && matrix.phpVersion == needs.create-matrix.outputs.default_php_version && matrix.database == 'mysql' }}
uses: romeovs/lcov-reporter-action@dda1c9b1fa1622b225e9acd87a248751dbcc6ada
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lcov-file: 'integration_openproject/server/apps/integration_openproject/coverage/php/lcov.info'
delete-old-comments: true
title: 'PHP Code Coverage'
- name: PHP coverage check
if: ${{ github.event_name == 'pull_request' && matrix.nextcloudVersion == 'stable32' && matrix.phpVersion == needs.create-matrix.outputs.default_php_version && matrix.database == 'mysql' }}
uses: VeryGoodOpenSource/very_good_coverage@3b475421464c564c0714d92ce02742bd81fa9eda
with:
min_coverage: '56'
path: 'integration_openproject/server/apps/integration_openproject/coverage/php/lcov.info'
- name: Wait for Nextcloud server to be ready
run: |
if ! timeout 5m bash -c '
until curl -s -f http://localhost/status.php | grep '"'"'"installed":true'"'"'; do
echo "[INFO] Waiting for server to be ready..."
sleep 10
done
'; then
echo "[ERROR] Server not ready within 5 minutes."
exit 1
fi
- name: Configure Nextcloud server
run: |
# Disable share rate limit protection
docker exec nextcloud /bin/bash -c 'occ config:system:set ratelimit.protection.enabled --value false --type bool'
# Enable apps
if [ "${{matrix.nextcloudVersion}}" == "master" ]; then
# enable app even if it is not compatible with the master branch
docker exec nextcloud /bin/bash -c 'occ a:e -f activity oidc user_oidc groupfolders integration_openproject'
else
docker exec nextcloud /bin/bash -c 'occ a:e activity oidc user_oidc groupfolders integration_openproject'
fi
- name: API Tests
env:
NEXTCLOUD_BASE_URL: http://localhost
NEXTCLOUD_VERSION: ${{ matrix.nextcloudVersion }}
BEHAT_FILTER_TAGS: '~@skip'
run: make api-test