diff --git a/.github/workflows/phpunit-extensions.yml b/.github/workflows/phpunit-extensions.yml new file mode 100644 index 00000000..a1bf4abd --- /dev/null +++ b/.github/workflows/phpunit-extensions.yml @@ -0,0 +1,136 @@ +name: PHPUnit Tests - Extensions +on: push +permissions: + contents: read +jobs: + phpunit-extensions: + runs-on: ubuntu-latest + timeout-minutes: 15 + strategy: + matrix: + postgres_version: [ 15, 16, 17 ] + + services: + pgsql_test: + image: postgres:${{ matrix.postgres_version }} + env: + PGPASSWORD: 'root' + POSTGRES_DB: 'laravel' + POSTGRES_USER: 'root' + POSTGRES_PASSWORD: 'root' + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + gotenberg: + image: gotenberg/gotenberg:8 + ports: + - 3000:3000 + options: >- + --health-cmd "curl --silent --fail http://localhost:3000/health" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - name: "Checkout code" + uses: actions/checkout@v7 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv + coverage: pcov + + - uses: actions/setup-node@v7 + with: + node-version: '20.x' + + - name: "Read extension manifest" + id: extension-manifest + run: | + { + echo "billing_repository=$(jq -r '.Billing.repository' extensions/manifest.json)" + echo "billing_ref=$(jq -r '.Billing.ref' extensions/manifest.json)" + echo "services_repository=$(jq -r '.Services.repository' extensions/manifest.json)" + echo "services_ref=$(jq -r '.Services.ref' extensions/manifest.json)" + echo "invoicing_repository=$(jq -r '.Invoicing.repository' extensions/manifest.json)" + echo "invoicing_ref=$(jq -r '.Invoicing.ref' extensions/manifest.json)" + } >> "$GITHUB_OUTPUT" + + - name: "Checkout billing extension" + uses: actions/checkout@v7 + with: + repository: ${{ steps.extension-manifest.outputs.billing_repository }} + ref: ${{ steps.extension-manifest.outputs.billing_ref }} + path: extensions/Billing + ssh-key: ${{ secrets.SSH_PRIVATE_KEY_BILLING_EXTENSION }} + + - name: "Install composer dependencies in billing extension" + working-directory: extensions/Billing + env: + COMPOSER_AUTH: '{"http-basic": {"spark.laravel.com": {"username": "contact@solidtime.io", "password": "${{ secrets.LARAVEL_SPARK_API_KEY }}"}}}' + run: composer install -n --prefer-dist --ignore-platform-reqs + + - name: "Install npm dependencies in billing extension" + run: cd extensions/Billing && npm ci + + - name: "Checkout services extension" + uses: actions/checkout@v7 + with: + repository: ${{ steps.extension-manifest.outputs.services_repository }} + ref: ${{ steps.extension-manifest.outputs.services_ref }} + path: extensions/Services + ssh-key: ${{ secrets.SSH_PRIVATE_KEY_SERVICES_EXTENSION }} + + - name: "Install composer dependencies in services extension" + working-directory: extensions/Services + run: composer install -n --prefer-dist --ignore-platform-reqs + + - name: "Install npm dependencies in services extension" + run: cd extensions/Services && npm ci + + - name: "Checkout invoicing extension" + uses: actions/checkout@v7 + with: + repository: ${{ steps.extension-manifest.outputs.invoicing_repository }} + ref: ${{ steps.extension-manifest.outputs.invoicing_ref }} + path: extensions/Invoicing + ssh-key: ${{ secrets.SSH_PRIVATE_KEY_INVOICING_EXTENSION }} + + - name: "Install composer dependencies in invoicing extension" + working-directory: extensions/Invoicing + run: composer install -n --prefer-dist --ignore-platform-reqs + + - name: "Install npm dependencies in invoicing extension" + run: cd extensions/Invoicing && npm ci + + - name: "Run composer install" + run: composer install -n --prefer-dist --ignore-platform-reqs + + - name: "Activate billing extension" + run: php artisan module:enable Billing + + - name: "Activate services extension" + run: php artisan module:enable Services + + - name: "Activate invoicing extension" + run: php artisan module:enable Invoicing + + - name: "Install dependencies" + run: npm ci + + - name: "Build Frontend" + run: npm run build + + - name: "Prepare Laravel Application" + run: | + cp .env.ci .env + php artisan key:generate + php artisan passport:keys + + - name: "Run PHPUnit" + run: php artisan test extensions/Billing/tests extensions/Services/tests extensions/Invoicing/tests --stop-on-failure diff --git a/extensions/manifest.json b/extensions/manifest.json index 8b6b61db..6323bf39 100644 --- a/extensions/manifest.json +++ b/extensions/manifest.json @@ -1,7 +1,7 @@ { "Billing": { "repository": "solidtime-io/extension-billing", - "ref": "v0.0.6" + "ref": "main" }, "Services": { "repository": "solidtime-io/extension-services",