Skip to content

ci: add a test installation job #4

ci: add a test installation job

ci: add a test installation job #4

Workflow file for this run

name: Stochastix CI
on:
push:
branches: [ master ]
tags:
- 'v*.*.*'
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
test:
name: Run Test Suite
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: bcmath, ds, gmp, trader
tools: composer:v2
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run PHPUnit tests
run: composer test
test_installation:
name: Test Project Installation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: bcmath, ds, gmp, trader, pdo_sqlite, zip, curl, libxml, dom
tools: composer:v2, symfony
env:
COMPOSER_ALLOW_PLUGINS: williarin/cook, php-http/discovery, symfony/flex, symfony/runtime
- name: Create new Symfony project
run: symfony new test-project --dir=test-project --no-git
- name: Configure and install Stochastix bundle
working-directory: ./test-project
run: |
composer config repositories.stochastix-core '{"type": "path", "url": "..", "options": {"symlink": false}}'
composer require stochastix/core:"*@dev"
- name: Verify recipe installation
working-directory: ./test-project
run: |
echo "--- Verifying config/packages/stochastix.yaml ---"
test -f config/packages/stochastix.yaml || (echo "File not found!" && exit 1)
echo "Found."
echo "--- Verifying config/routes/stochastix.yaml ---"
test -f config/routes/stochastix.yaml || (echo "File not found!" && exit 1)
echo "Found."
echo "--- Verifying data/.gitkeep ---"
test -f data/.gitkeep || (echo "File not found!" && exit 1)
echo "Found."
echo "--- Verifying Makefile ---"
test -f Makefile || (echo "File not found!" && exit 1)
echo "Found."
echo "--- Verifying src/Strategy/SampleStrategy.php ---"
test -f src/Strategy/SampleStrategy.php || (echo "File not found!" && exit 1)
echo "Found."
echo "--- Verifying .env for DATABASE_URL ---"
grep -q 'DATABASE_URL="sqlite:///%kernel.project_dir%/data/queue_%kernel.environment%.db"' .env || (echo "DATABASE_URL not found or incorrect!" && exit 1)
echo "Found."
- name: Setup Database
working-directory: ./test-project
run: |
php bin/console doctrine:database:create --if-not-exists
php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration