From 4ee23feac53b197dc2e3826cfdac5b1c85d0c0aa Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Tue, 13 Jun 2023 07:08:23 -0700 Subject: [PATCH] Introduce the compatibility workflow (#2) * Introduce the compatibility workflow * We don't need to do this here * It helps if this is put in the right folder * Update php-ci.yml * Also checkout * We can safely ignore this * Update phpstan.neon --- .github/workflows/php-ci.yml | 76 +++++++++++++++++++ README.md | 16 +++- phpstan.neon | 11 +++ {Api => src/Api}/Admin.php | 0 {Api => src/Api}/Client.php | 0 {Api => src/Api}/Guest.php | 0 {Controller => src/Controller}/Admin.php | 0 {Controller => src/Controller}/Client.php | 0 Service.php => src/Service.php | 0 .../html_admin}/mod_example_index.html.twig | 0 .../mod_example_settings.html.twig | 0 .../html_client}/mod_example_index.html.twig | 0 .../html_email}/mod_example_email.html.twig | 0 icon.svg => src/icon.svg | 0 manifest.json => src/manifest.json | 0 15 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/php-ci.yml create mode 100644 phpstan.neon rename {Api => src/Api}/Admin.php (100%) rename {Api => src/Api}/Client.php (100%) rename {Api => src/Api}/Guest.php (100%) rename {Controller => src/Controller}/Admin.php (100%) rename {Controller => src/Controller}/Client.php (100%) rename Service.php => src/Service.php (100%) rename {html_admin => src/html_admin}/mod_example_index.html.twig (100%) rename {html_admin => src/html_admin}/mod_example_settings.html.twig (100%) rename {html_client => src/html_client}/mod_example_index.html.twig (100%) rename {html_email => src/html_email}/mod_example_email.html.twig (100%) rename icon.svg => src/icon.svg (100%) rename manifest.json => src/manifest.json (100%) diff --git a/.github/workflows/php-ci.yml b/.github/workflows/php-ci.yml new file mode 100644 index 0000000..31feb70 --- /dev/null +++ b/.github/workflows/php-ci.yml @@ -0,0 +1,76 @@ +name: Check FOSSBilling Compatibility + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + phpstan: + runs-on: ubuntu-latest + + name: PHPStan - FOSSBilling Preview + steps: + - uses: actions/checkout@v3 + + - name: Checkout FOSSBilling Source Code + uses: actions/checkout@v3 + with: + repository: "FOSSBilling/FOSSBilling" + path: "FOSSBilling" + + - name: Install Composer Dependencies + uses: php-actions/composer@v6 + with: + args: --working-dir=FOSSBilling + dev: no + + - name: Run PHPStan + uses: php-actions/phpstan@v3 + with: + php_version: latest + configuration: phpstan.neon + memory_limit: 512M + + phpstan-release: + runs-on: ubuntu-latest + + name: PHPStan - FOSSBilling Release + steps: + - uses: actions/checkout@v3 + + - name: Get the Latest FOSSBilling Release Tag + uses: oprypin/find-latest-tag@v1 + with: + repository: "FOSSBilling/FOSSBilling" + releases-only: true + id: get_id + + - name: Checkout The Release tag + uses: actions/checkout@v3 + with: + repository: "FOSSBilling/FOSSBilling" + path: "FOSSBilling" + ref: ${{ steps.get_id.outputs.tag }} + + - name: Install Composer Dependencies (<=0.4.x) + if: ${{ hashFiles('FOSSBilling/src/composer.json') }} + uses: php-actions/composer@v6 + with: + args: --working-dir=FOSSBilling/src + dev: no + + - name: Install Composer Dependencies (>=0.5.0) + if: ${{ hashFiles('FOSSBilling/composer.json') }} + uses: php-actions/composer@v6 + with: + args: --working-dir=FOSSBilling/ + dev: no + + - name: Run PHPStan + uses: php-actions/phpstan@v3 + with: + php_version: latest + configuration: phpstan.neon + memory_limit: 512M diff --git a/README.md b/README.md index f6ca672..5adefed 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ In general, we use modules to extend the functionality of FOSSBilling. All modules can communicate with the other modules using their API endpoints. -# Technical requirements about modules +## Technical requirements about modules ## Required @@ -35,8 +35,22 @@ All modules can communicate with the other modules using their API endpoints. We recommend hosting your extensions on a public [GitHub](https://github.com) repository. +### Automated compatibility checking + +As FOSSBilling evolves and matures, its internal functionality changes, which can create compatibility issues between your module and FOSSBilling. +To help developers catch these issues early on, we've designed a workflow that enables you to perform a PHPStan analysis of your module with both the latest FOSSBilling release and its preview builds. +While PHPStan cannot perform live tests, it's a useful tool to verify that your module doesn't reference missing functions, use incorrect types, or have other common low-level issues. + +#### Setup + +More in-depth instructions are planned. For now, check out the required files: + +* [php-ci.yml](https://github.com/FOSSBilling/example-module/blob/main/.github/workflows/php-ci.yml) +* [phpstan.neon](https://github.com/FOSSBilling/example-module/blob/main/phpstan.neon) + ## Licensing This extension is open source software and is released under the Apache v2.0 license. See [LICENSE](LICENSE) for the full license terms. This product includes the following third party work: * Open Source Iconography by [Pictogrammers](https://pictogrammers.com/) licensed under the [Pictogrammers Free License](https://pictogrammers.com/docs/general/license/). +* We recommend hosting your extensions on a public [GitHub](https://github.com) repository. \ No newline at end of file diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..836d44c --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,11 @@ +parameters: + level: 1 + paths: + - src + - FOSSBilling + excludePaths: + analyse: + - src/vendor + - FOSSBilling + ignoreErrors: + - '#^Function __trans not found\.$#' diff --git a/Api/Admin.php b/src/Api/Admin.php similarity index 100% rename from Api/Admin.php rename to src/Api/Admin.php diff --git a/Api/Client.php b/src/Api/Client.php similarity index 100% rename from Api/Client.php rename to src/Api/Client.php diff --git a/Api/Guest.php b/src/Api/Guest.php similarity index 100% rename from Api/Guest.php rename to src/Api/Guest.php diff --git a/Controller/Admin.php b/src/Controller/Admin.php similarity index 100% rename from Controller/Admin.php rename to src/Controller/Admin.php diff --git a/Controller/Client.php b/src/Controller/Client.php similarity index 100% rename from Controller/Client.php rename to src/Controller/Client.php diff --git a/Service.php b/src/Service.php similarity index 100% rename from Service.php rename to src/Service.php diff --git a/html_admin/mod_example_index.html.twig b/src/html_admin/mod_example_index.html.twig similarity index 100% rename from html_admin/mod_example_index.html.twig rename to src/html_admin/mod_example_index.html.twig diff --git a/html_admin/mod_example_settings.html.twig b/src/html_admin/mod_example_settings.html.twig similarity index 100% rename from html_admin/mod_example_settings.html.twig rename to src/html_admin/mod_example_settings.html.twig diff --git a/html_client/mod_example_index.html.twig b/src/html_client/mod_example_index.html.twig similarity index 100% rename from html_client/mod_example_index.html.twig rename to src/html_client/mod_example_index.html.twig diff --git a/html_email/mod_example_email.html.twig b/src/html_email/mod_example_email.html.twig similarity index 100% rename from html_email/mod_example_email.html.twig rename to src/html_email/mod_example_email.html.twig diff --git a/icon.svg b/src/icon.svg similarity index 100% rename from icon.svg rename to src/icon.svg diff --git a/manifest.json b/src/manifest.json similarity index 100% rename from manifest.json rename to src/manifest.json