Files
InvoiceShelf/.github/workflows/docker.yaml
Darko Gjorgjijoski 4ab62b98c6 ci: speed up PHP test jobs (disable Xdebug, drop frontend build, run parallel) (#657)
* ci: speed up the test job (disable Xdebug, drop frontend build, run parallel)

The `tests` job in check.yaml carried three sources of wasted wall-clock,
none of which it actually used:

- `coverage: xdebug` loaded Xdebug into every PHP process, but no step ever
  passes `--coverage` — so it was pure tax (~2-3x slower execution). Switch
  to `coverage: none`. If coverage is wanted later, use pcov + `--coverage`.
- The job ran `npm install` + `npm run build` before the PHP tests. The
  feature suite is API/JSON only (49/56 feature files use getJson/assertJson)
  and nothing renders the Vite blade, so the built assets are never needed.
  Drop the Node/Vite steps; release & docker workflows still build assets.
- Tests ran single-process. brianium/paratest is already installed and the
  runner has 4 cores, so run `php artisan test --parallel`.

Validated locally: full suite passes in parallel (exit 0), including
repeated runs of the two filesystem-writing module tests — no races.

docker.yaml carries the same pattern but only runs on release/nightly cron,
so it is left for a follow-up.

* ci: apply the same test-job speedups to docker.yaml

The release/nightly `tests` job in docker.yaml carried the identical waste
that check.yaml had: Xdebug loaded but never used for coverage, an
unnecessary frontend build before the PHP tests, and serial execution.

Mirror the check.yaml fix: coverage: none, drop the Node/Vite steps
(the suite is API/JSON and the separate release_artifact_build job builds
its own assets), and run php artisan test --parallel.

* ci: run module-scaffolding tests serially under --parallel

The Modules/* tests (module:make ScaffoldProbe + modules_statuses.json
toggles) mutate shared on-disk module state. paratest isolates the DB
per worker but NOT the filesystem, so concurrent workers boot with
ScaffoldProbe enabled and fatal on the un-autoloaded ServiceProvider
(31 failures). Tag them 'modules' (Pest group on Feature/Company/Modules)
and split CI: parallel --exclude-group=modules, then serial --group=modules.

* ci: stub Vite in tests + bump all actions to Node 24 versions

Part A (fixes #657): the customer-portal entrypoint test renders the SPA
shell (app.blade.php → @vite). With the frontend build dropped from CI
there's no manifest, so it 500'd (ViteManifestNotFoundException). Call
$this->withoutVite() in TestCase::setUp() so SPA-shell renders work
without a built manifest; the build stays dropped.

Part B: bump every Node-20 action to its node24 release — checkout v4->v6,
setup-node v4->v6, paths-filter v3->v4, cancel-workflow-action 0.12.1->0.13.1,
softprops/action-gh-release v2->v3, docker/{setup-buildx v3->v4, login v3->v4,
metadata v5->v6, build-push v5->v7}. setup-php@v2, ramsey/composer-install@v2
(composite) and svenstaro/upload-release-action@v2 are already node24.

* ci: bump ramsey/composer-install v2 -> 4.0.0 (node24 internal cache)

composer-install@v2 is composite but internally calls actions/cache@v3
(Node 20), which still trips the deprecation. 4.0.0 uses actions/cache
v5.0.3 (Node 24) and keeps the composer-options input we use.
2026-06-12 12:35:10 +02:00

252 lines
7.0 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Docker Build and Push
on:
release:
types: [published]
schedule:
# Run nightly at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
tag:
description: 'Docker tag'
required: true
default: 'latest'
jobs:
php_syntax_errors:
name: 1⃣ PHP Code Style errors
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
- name: Checkout code
uses: actions/checkout@v6
- name: Install dependencies
uses: ramsey/composer-install@4.0.0
- name: Check source code for syntax errors
run: ./vendor/bin/pint --test
tests:
name: 2⃣ PHP Tests
if: github.event_name == 'release'
needs:
- php_syntax_errors
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- 8.4
env:
extensions: bcmath, curl, dom, gd, imagick, json, libxml, mbstring, pcntl, pdo, pdo_mysql, zip
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: ${{ env.extensions }}
coverage: none
tools: pecl, composer
- name: Install Composer dependencies
uses: ramsey/composer-install@4.0.0
- name: Apply tests ${{ matrix.php-version }} (parallel)
run: php artisan test --parallel --exclude-group=modules
- name: Apply module tests ${{ matrix.php-version }} (serial)
run: php artisan test --group=modules
release_artifact_build:
name: 🏗️ Build / Upload - Release File
if: github.event_name == 'release'
needs:
- tests
runs-on: ubuntu-latest
env:
extensions: bcmath, curl, dom, gd, imagick, json, libxml, mbstring, pcntl, pdo, pdo_mysql, zip
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
extensions: ${{ env.extensions }}
coverage: none
- name: Install Composer dependencies
uses: ramsey/composer-install@4.0.0
with:
composer-options: --no-dev
- name: Use Node.js 24
uses: actions/setup-node@v6
with:
node-version: 24
- name: Install
run: npm install
- name: Compile Front-end
run: npm run build
- name: Build Dist
run: |
make clean dist
- name: Upload package
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ github.token }}
file: InvoiceShelf.zip
asset_name: InvoiceShelf.zip
tag: ${{ github.ref }}
overwrite: true
release_docker_build:
name: 🐳 Release Docker Build
if: github.event_name == 'release'
needs:
- tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: invoiceshelf/invoiceshelf
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
file: docker/production/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
manual_docker_build:
name: 🛠️ Manual Docker Build
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
file: docker/production/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: invoiceshelf/invoiceshelf:${{ github.event.inputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
nightly_build:
name: 🌙 Nightly Docker Build
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
strategy:
matrix:
branch: [master, develop]
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ matrix.branch }}
fetch-depth: 2
- name: Check for recent changes
id: changes
run: |
# Check if there are commits in the last 24 hours
RECENT_COMMITS=$(git log --since="24 hours ago" --oneline | wc -l)
echo "recent_commits=$RECENT_COMMITS" >> $GITHUB_OUTPUT
if [ "$RECENT_COMMITS" -gt 0 ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Set up Docker Buildx
if: steps.changes.outputs.has_changes == 'true'
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
if: steps.changes.outputs.has_changes == 'true'
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Set Docker tag
if: steps.changes.outputs.has_changes == 'true'
id: tag
run: |
if [ "${{ matrix.branch }}" = "master" ]; then
echo "tag=nightly" >> $GITHUB_OUTPUT
elif [ "${{ matrix.branch }}" = "develop" ]; then
echo "tag=alpha" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker image
if: steps.changes.outputs.has_changes == 'true'
uses: docker/build-push-action@v7
with:
context: .
file: docker/production/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: invoiceshelf/invoiceshelf:${{ steps.tag.outputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: No changes detected
if: steps.changes.outputs.has_changes == 'false'
run: |
echo "No commits found in the last 24 hours for ${{ matrix.branch }} branch. Skipping build."