Skip to content

Commit

Permalink
Merge pull request #59 from nextcloud/feat/noid/testing
Browse files Browse the repository at this point in the history
feat(tests): Add a demo app for testing
  • Loading branch information
nickvergessen authored Jan 8, 2024
2 parents 25ea366 + 60c0b70 commit a6dc75d
Show file tree
Hide file tree
Showing 11 changed files with 2,350 additions and 24 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# https://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
60 changes: 60 additions & 0 deletions .github/workflows/lint-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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

name: Lint php

on:
pull_request:
push:
branches:
- main
- master
- stable*

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:
matrix:
php-versions: [ "8.1" ]

name: php-lint

steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Lint
run: composer run lint

summary:
permissions:
contents: none
runs-on: ubuntu-latest
needs: php-lint

if: always()

name: php-lint-summary

steps:
- name: Summary status
run: if ${{ needs.php-lint.result != 'success' && needs.php-lint.result != 'skipped' }}; then exit 1; fi
34 changes: 34 additions & 0 deletions .github/workflows/pr-feedback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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

name: 'Ask for feedback on PRs'
on:
schedule:
- cron: '30 1 * * *'

jobs:
pr-feedback:
runs-on: ubuntu-latest
steps:
- name: The get-github-handles-from-website action
uses: marcelklehr/get-github-handles-from-website-action@a739600f6b91da4957f51db0792697afbb2f143c # v1.0.0
id: scrape
with:
website: 'https://nextcloud.com/team/'
- uses: marcelklehr/pr-feedback-action@601109aa729eb4c8d6d0ece7567b9d4901db4aef
with:
feedback-message: |
Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.
We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.
Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6
Thank you for contributing to Nextcloud and we hope to hear from you soon!
days-before-feedback: 14
start-date: "2023-11-08"
exempt-authors: "${{ steps.scrape.outputs.users }},nextcloud-command,nextcloud-android-bot"
exempt-bots: true
75 changes: 75 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# 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

name: Generate OpenAPI

on:
pull_request:
push:
branches:
- main
- master
- stable*

permissions:
contents: read

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

jobs:
openapi:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ "8.1" ]

name: openapi

steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: composer i

- name: Generate OpenAPI
working-directory: tests/
run: ../generate-spec

- name: Check openapi changes
run: |
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)"
- name: Show changes on failure
if: failure()
run: |
git status
git --no-pager diff
exit 1 # make it red to grab attention
summary:
permissions:
contents: none
runs-on: ubuntu-latest
needs: openapi

if: always()

name: openapi-summary

steps:
- name: Summary status
run: if ${{ needs.openapi.result != 'success' && needs.openapi.result != 'skipped' }}; then exit 1; fi
53 changes: 29 additions & 24 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
{
"name": "nextcloud/openapi-extractor",
"require": {
"php": "^8.1",
"ext-simplexml": "*",
"nikic/php-parser": "^4.16",
"adhocore/cli": "^v1.6",
"phpstan/phpdoc-parser": "^1.23"
},
"require-dev": {
"nextcloud/coding-standard": "^1.1"
},
"bin": [
"generate-spec",
"merge-specs"
],
"autoload": {
"psr-4": {
"OpenAPIExtractor\\": "src"
}
},
"scripts": {
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix"
}
"name": "nextcloud/openapi-extractor",
"bin": [
"generate-spec",
"merge-specs"
],
"config": {
"sort-packages": true
},
"autoload": {
"psr-4": {
"OpenAPIExtractor\\": "src"
}
},
"require": {
"php": "^8.1",
"ext-simplexml": "*",
"nikic/php-parser": "^4.16",
"adhocore/cli": "^v1.6",
"phpstan/phpdoc-parser": "^1.23"
},
"require-dev": {
"nextcloud/coding-standard": "^1.1"
},
"scripts": {
"lint": "find . -name \\*.php -not -path './tests/*' -not -path './vendor/*' -not -path './build/*' -print0 | xargs -0 -n1 php -l && php -l generate-spec && php -l merge-specs",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix",
"test:unit": "cd tests && ../generate-spec"
}
}
52 changes: 52 additions & 0 deletions tests/appinfo/info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0"?>
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>notifications</id>
<name>Notifications</name>
<summary><![CDATA[This app provides a backend and frontend for the notification API available in Nextcloud.]]></summary>
<description><![CDATA[This app provides a backend and frontend for the notification API available in Nextcloud.
The API is used by other apps to notify users in the web UI and sync clients about various things. Some examples are:
📬 Federated file sharing: You received a new remote share
📑 Comments: Another user mentioned you in a comment on a file
🚢 Update notification: Available update for an app or nextcloud itself
📣 Announcement center: An announcement was posted by an admin]]></description>

<version>2.16.0</version>
<licence>agpl</licence>
<author>Joas Schilling</author>

<types>
<logging/>
</types>

<category>tools</category>

<website>https://github.com/nextcloud/notifications</website>
<bugs>https://github.com/nextcloud/notifications/issues</bugs>
<repository>https://github.com/nextcloud/notifications.git</repository>

<dependencies>
<nextcloud min-version="28" max-version="28" />
</dependencies>

<background-jobs>
<job>OCA\Notifications\BackgroundJob\GenerateUserSettings</job>
<job>OCA\Notifications\BackgroundJob\SendNotificationMails</job>
</background-jobs>

<commands>
<command>OCA\Notifications\Command\Generate</command>
<command>OCA\Notifications\Command\TestPush</command>
</commands>

<settings>
<admin>OCA\Notifications\Settings\Admin</admin>
<admin-section>OCA\Notifications\Settings\AdminSection</admin-section>
<personal>OCA\Notifications\Settings\Personal</personal>
<personal-section>OCA\Notifications\Settings\PersonalSection</personal-section>
</settings>
</info>
50 changes: 50 additions & 0 deletions tests/appinfo/routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2023, Joas Schilling <[email protected]>
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <[email protected]>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

return [
'ocs' => [
['name' => 'AdminSettings#adminScopeImplicitFromAdminRequired', 'url' => '/api/{apiVersion}/default-admin', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'AdminSettings#movedToDefaultScope', 'url' => '/api/{apiVersion}/default-admin-overwritten', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'AdminSettings#movedToSettingsTag', 'url' => '/api/{apiVersion}/moved-with-tag', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],

['name' => 'Settings#federationByController', 'url' => '/api/{apiVersion}/controller-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#ignoreByDeprecatedAttributeOnMethod', 'url' => '/api/{apiVersion}/ignore-openapi-attribute', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#ignoreByScopeOnMethod', 'url' => '/api/{apiVersion}/ignore-method-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#movedToDefaultScope', 'url' => '/api/{apiVersion}/default-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#movedToAdminScope', 'url' => '/api/{apiVersion}/admin-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#defaultAndAdminScope', 'url' => '/api/{apiVersion}/default-and-admin-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#nestedSchemas', 'url' => '/api/{apiVersion}/nested-schemas', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#listSchemas', 'url' => '/api/{apiVersion}/list-schemas', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#listOfIntParameters', 'url' => '/api/{apiVersion}/list-of-int', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#intParameterWithMinAndMax', 'url' => '/api/{apiVersion}/min-max', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#intParameterWithMin', 'url' => '/api/{apiVersion}/min', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#intParameterWithMax', 'url' => '/api/{apiVersion}/max', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#listOfIntStringAndBool', 'url' => '/api/{apiVersion}/mixed-list', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#booleanParameterRequired', 'url' => '/api/{apiVersion}/boolean', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#booleanParameterDefaultFalse', 'url' => '/api/{apiVersion}/boolean-false', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#booleanParameterDefaultTrue', 'url' => '/api/{apiVersion}/boolean-true', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
],
];
Loading

0 comments on commit a6dc75d

Please sign in to comment.