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
49 changes: 49 additions & 0 deletions .github/workflows/lint-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Cheap, high-value check: php -l syntax linting + composer.json validation.
# Adapted from Nextcloud's reusable workflow templates (nextcloud/.github),
# simplified to a fixed PHP matrix instead of deriving one from appinfo/info.xml
# (this app's declared min-version="20" predates PHP 8, which isn't a
# realistic target — see the linked issue for the follow-up on tightening that).
name: Lint PHP

on:
pull_request:
push:
branches: [master]

permissions:
contents: read

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

jobs:
php-lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['8.2', '8.3']

name: php-lint (PHP ${{ matrix.php-versions }})

steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- name: composer validate
run: composer validate

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

- name: Lint (php -l)
run: composer run lint
45 changes: 45 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Unit tests only, against the nextcloud/ocp stub package — no live
# Nextcloud server or database is booted, which keeps this job fast and free
# of external services. tests/Integration (real server + DB) is intentionally
# not run here; see the linked GitHub issue for the multi-database follow-up.
name: PHPUnit

on:
pull_request:
push:
branches: [master]

permissions:
contents: read

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

jobs:
unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['8.2', '8.3']

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

steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

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

- name: PHPUnit
run: composer run test:unit
41 changes: 41 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Static analysis with PHPStan. Existing findings are frozen in
# phpstan-baseline.neon (mostly missing Doctrine DBAL type stubs and a
# runtime class_alias() static analysis can't see through) so this starts
# green; only newly introduced issues fail the build.
name: Static analysis

on:
pull_request:
push:
branches: [master]

permissions:
contents: read

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

jobs:
phpstan:
runs-on: ubuntu-latest

name: static-phpstan-analysis

steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

- name: Set up php
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
with:
php-version: '8.3'
coverage: none

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

- name: PHPStan
run: composer run phpstan
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
js/dist/
js/node_modules/
vendor/
.phpunit.result.cache
64 changes: 0 additions & 64 deletions .travis.yml

This file was deleted.

17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,22 @@ appstore:
--exclude="$(app_name)/js/.*" \
-czf $(appstore_package_name).tar.gz ../$(app_name)

# Installs composer dependencies including require-dev (phpunit, phpstan,
# nextcloud/ocp stubs). Separate from the `composer` target above, which
# passes --no-dev for production/appstore builds.
.PHONY: composer-dev
composer-dev:
composer install --prefer-dist

# Runs the unit test suite, which only needs the nextcloud/ocp stub package
# (no live Nextcloud instance required) — this is what CI runs.
.PHONY: test
test: composer
test: composer-dev
$(CURDIR)/vendor/phpunit/phpunit/phpunit -c phpunit.xml

# Runs the integration test suite. Requires this app to be checked out inside
# a real Nextcloud server's apps/ directory with a working install — not run
# by CI yet (see the linked GitHub issue for the multi-database CI follow-up).
.PHONY: test-integration
test-integration: composer-dev
$(CURDIR)/vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml
24 changes: 23 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@
],
"require": {},
"require-dev": {
"christophwurst/nextcloud": "^24.0"
"nextcloud/ocp": "^34.0",
"phpunit/phpunit": "^10.5",
"phpstan/phpstan": "^1.11"
},
"autoload": {
"psr-4": {
"OCA\\TimeTracker\\": "lib/"
}
},
"autoload-dev": {
"psr-4": {
"OCA\\TimeTracker\\Tests\\": "tests/",
"OCP\\": "vendor/nextcloud/ocp/OCP/",
"NCU\\": "vendor/nextcloud/ocp/NCU/"
}
},
"scripts": {
"lint": "find . -name '*.php' -not -path './vendor/*' -not -path './build/*' -not -path './js/*' -print0 | xargs -0 -n1 php -l",
"phpstan": "phpstan analyse --no-progress",
"test:unit": "phpunit -c phpunit.xml"
},
"config": {
"sort-packages": true
}
}
Loading