Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/phpunit-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT
#
# Unit tests. Deliberately separate from test.yml: these need no Nextcloud
# server, no database and no web server, so they finish in seconds and give
# feedback on every pull request. test.yml remains the place where the HTTP API
# is exercised against a real instance.

name: PHPUnit unit

on: pull_request

permissions:
contents: read

concurrency:
group: phpunit-unit-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
matrix:
runs-on: ubuntu-latest-low
outputs:
php-versions: ${{ steps.versions.outputs.php-versions }}
steps:
- name: Checkout app
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Get version matrix
id: versions
uses: icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.0.0

unit-tests:
runs-on: ubuntu-latest
needs: matrix
strategy:
fail-fast: false
matrix:
php-versions: ${{fromJson(needs.matrix.outputs.php-versions)}}

name: unit-tests (php ${{ matrix.php-versions }})

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, curl, dom, fileinfo, iconv, intl, json, libxml, mbstring, openssl, posix, simplexml, xmlreader, xmlwriter, zip, zlib
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run unit tests
run: composer run test:unit

summary:
permissions:
contents: none
runs-on: ubuntu-latest-low
needs: unit-tests

if: always()

name: unit-tests-summary

steps:
- name: Summary status
run: if ${{ needs.unit-tests.result != 'success' && needs.unit-tests.result != 'skipped' }}; then exit 1; fi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ js/
report
clover.xml
.php-cs-fixer.cache
.phpunit.cache/
.phpunit.result.cache
appinfo/info.xsd

# just sane ignores
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ watch-js:

##### Testing #####

test: test-api
test: test-unit test-api

# No Nextcloud instance required.
test-unit:
composer run test:unit

# Requires a running Nextcloud with the app enabled, see .github/workflows/test.yml
test-api:
phpunit --bootstrap vendor/autoload.php --testdox tests/api/

Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{
"require-dev": {
"doctrine/dbal": "^4",
"guzzlehttp/guzzle": "^8",
"nextcloud/coding-standard": "^1.0",
"nextcloud/ocp": "dev-stable33",
"phan/phan": "^6",
"php-cs-fixer/shim": "3.95.17",
"phpunit/phpunit": "^10",
"psalm/phar": "^5.26",
"squizlabs/php_codesniffer": "^4",
"staabm/annotate-pull-request-from-checkstyle": "^1.1.0"
},
"autoload-dev": {
"psr-4": {
"OCA\\Notes\\": "lib/",
"OCA\\Notes\\Tests\\API\\": "tests/api/",
"OCA\\Notes\\Tests\\Unit\\": "tests/unit/",
"OCP\\": "vendor/nextcloud/ocp/OCP/",
"OC\\": "vendor/nextcloud/ocp/OC/"
}
Expand Down
Loading
Loading