Update CI templates and add more links

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling
2022-11-08 12:46:15 +01:00
parent 5a6c15030c
commit 696334f46a

View File

@@ -21,26 +21,9 @@ Linting
info.xml
^^^^^^^^
You can validate the ``info.xml`` :ref:`app metadata<app metadata>` file of an app with a simple github action:
.. code-block:: yaml
name: Lint
on: pull_request
jobs:
xml-linters:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Download schema
run: wget https://apps.nextcloud.com/schema/apps/info.xsd
- name: Lint info.xml
uses: ChristophWurst/xmllint-action@v1
with:
xml-file: ./appinfo/info.xml
xml-schema-file: ./info.xsd
You can validate the ``info.xml`` :ref:`app metadata<app metadata>` file of an app with a
`simple github action <https://github.com/nextcloud/.github/blob/master/workflow-templates/lint-info-xml.yml>`_.
Please refer to our `nextcloud template repository <https://github.com/nextcloud/.github>`_ for an up to date template.
php
^^^
@@ -69,7 +52,10 @@ relevant github actions in our `nextcloud template repository <https://github.co
Static analysis
---------------
`Psalm`_ is a static analysis tool that can check if your app code uses all types correctly, like if classes and methods exist. For the basic setup see the `Psalm`_ website. In order to let Psalm know about Nextcloud interfaces (the OCP namespace), you can install the `API package <https://packagist.org/packages/christophwurst/nextcloud>`_. Afterwards you'll be able to check the app with the following ``psalm.xml`` that should be put into the root of the app.
`Psalm`_ is a static analysis tool that can check if your app code uses all types correctly, like if classes and methods exist.
For the basic setup see the `Psalm`_ website. In order to let Psalm know about Nextcloud interfaces (the OCP namespace),
you can install the `API package <https://packagist.org/packages/nextcloud/ocp>`_.
Afterwards you'll be able to check the app with the following ``psalm.xml`` that should be put into the root of the app.
.. code-block:: xml
@@ -113,37 +99,19 @@ Static analysis
</issueHandlers>
</psalm>
.. Note:: The definition suppresses usages of the global and static class ``OC`` like ``\OC::$server``, which is discouraged but still found in some apps. The doctrine supression is currently necessary as the database mappers and schema abstractions leak some of the 3rd party libraries of Nextcloud that are not known to Psalm.
.. Note:: The definition suppresses usages of the global and static class ``OC`` like ``\OC::$server``, which is
discouraged but still found in some apps. The doctrine suppression is currently necessary as the database mappers and
schema abstractions leak some of the 3rd party libraries of Nextcloud that are not known to Psalm.
You can put this process into a GitHub Action that is run for every pull request.
Check our `simple github action <https://github.com/nextcloud/.github/blob/master/workflow-templates/psalm.yml>`_ from
our `nextcloud template repository <https://github.com/nextcloud/.github>`_.
.. code-block:: yaml
name: Static analysis
on: [push]
jobs:
static-psalm-analysis:
runs-on: ubuntu-latest
strategy:
matrix:
ocp-version: [ 'dev-master', 'v20.0.0' ]
name: Nextcloud ${{ matrix.ocp-version }}
steps:
- name: Checkout
uses: actions/checkout@master
- name: Set up php
uses: shivammathur/setup-php@master
with:
php-version: 7.4
coverage: none
- name: Install dependencies
run: composer i
- name: Install dependencies
run: composer require --dev christophwurst/nextcloud:${{ matrix.ocp-version }}
- name: Run coding standards check
run: composer run psalm
This creates a matrix, where the app is tested against ``dev-master``, the latest version of ``OCP`` found in the main branch of Nextcloud server, as well as ``v20.0.0``, the currently latest stable release. Adjust this to your needs.
If you want to support multiple versions of Nextcloud server with a single app version, checkout this slightly
`more complex action <https://github.com/nextcloud/.github/blob/master/workflow-templates/psalm-matrix.yml>`_.
This creates a matrix, where the app is tested against ``dev-master``, the latest version of ``OCP`` found in the main
branch of Nextcloud server, as well as ``dev-stable25``, ``dev-stable24`` and ``dev-stable23``, the currently supported
stable branches. Adjust this to your needs.
.. _Psalm: https://psalm.dev/docs/