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
74 changes: 74 additions & 0 deletions .github/workflows/phpunit-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT

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 @@ -8,6 +8,8 @@ report
coverage/
clover.xml
.php-cs-fixer.cache
.phpunit.cache/
.phpunit.result.cache
appinfo/info.xsd

# just sane ignores
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app_name=notes
project_dir=$(CURDIR)/../$(app_name)
build_dir=$(CURDIR)/build/artifacts
cert_dir=$(HOME)/.nextcloud/certificates
php_dirs=appinfo/ lib/ tests/api/
php_dirs=appinfo/ lib/ tests/api/ tests/unit/


all: dev-setup build
Expand Down Expand Up @@ -87,7 +87,10 @@ watch-js:

##### Testing #####

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

test-unit:
composer run test:unit

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.23",
"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