Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 13 additions & 52 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
---

name: build

on: # yamllint disable-line rule:truthy
pull_request:
push:
branches: [4.x]
branches:
- 4.x
pull_request: null

permissions:
contents: read
Expand All @@ -13,53 +16,11 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
test:
name: Test PHP ${{ matrix.php-version }} (${{ matrix.dependencies }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.2', '8.3', '8.4', '8.5']
dependencies: [lowest, highest]
steps:
- name: Install ODBC driver.
run: |
sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18

- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Setup DB services
run: |
cd tests
docker compose up -d
cd ..

- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
tools: pecl
extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, pdo_sqlsrv, pdo_mysql

- name: Validate composer.json
run: composer validate --ansi --strict

- name: Install dependencies with composer
uses: ramsey/composer-install@v4
with:
dependency-versions: ${{ matrix.dependencies }}

- name: Execute Tests
run: vendor/bin/phpunit --coverage-clover=coverage.clover

- name: Upload coverage to Codecov
continue-on-error: true # if is fork
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.clover
testo:
name: Testo
uses: cycle/gh-actions/.github/workflows/testo.yml@master
with:
coverage: true
secrets: inherit

...
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,18 @@ composer require --dev llm/skills
```

Querying and persisting the mapped entities is covered by the `cycle-orm` skill that comes with [cycle/orm](https://github.com/cycle/orm).

## Testing

The tests run on [Testo](https://github.com/php-testo/testo) through the shared [cycle/testing](https://github.com/cycle/testing) harness: `tests/Unit` needs no database, and `tests/Feature` runs once per database driver.

```bash
composer test:unit # no database
composer test:sqlite # in-memory SQLite, no docker
composer db:up # MySQL, Postgres and SQL Server in docker
composer test # every suite; a driver whose server is down is skipped
composer db:down
```

`composer test:mysql`, `test:postgres` and `test:sqlserver` run one driver. To reproduce a new issue, generate a case:
`composer test:new-case -- 123` writes `tests/Regression/Issue123`.
26 changes: 22 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"url": "https://github.com/sponsors/cycle"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/cycle/testing"
}
],
"require": {
"php": ">=8.2",
"cycle/database": "^2.23",
Expand All @@ -48,10 +54,11 @@
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8",
"buggregator/trap": "^1.20",
"cycle/testing": "^0.1.1",
"doctrine/annotations": "^2.0.2",
"llm/skills": "^1.20",
"phpunit/phpunit": "^11.5",
"roxblnfk/unpoly": "^1.8"
"roxblnfk/unpoly": "^1.8",
"testo/testo": "^0.10.60"
},
"suggest": {
"llm/skills": "To sync the cycle-orm-attributes AI skill into your project"
Expand All @@ -63,7 +70,7 @@
},
"autoload-dev": {
"psr-4": {
"Cycle\\Annotated\\Tests\\": "tests/Annotated/"
"Cycle\\Annotated\\Tests\\": "tests/"
}
},
"scripts": {
Expand All @@ -72,7 +79,18 @@
"psalm": "psalm -c vendor-bin/psalm/psalm.xml",
"psalm:baseline": "psalm -c vendor-bin/psalm/psalm.xml --set-baseline=vendor-bin/psalm/psalm-baseline.xml",
"psalm:ci": "psalm -c vendor-bin/psalm/psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4",
"test": "phpunit --color=always"
"db:down": "docker compose -f vendor/cycle/testing/resources/docker/compose.yaml down -v",
"db:up": "docker compose -f vendor/cycle/testing/resources/docker/compose.yaml up -d --wait",
"test": "testo",
"test:mysql": "testo --suite=Feature/MySQL --suite=Acceptance/MySQL --suite=Regression/MySQL",
"test:new-case": "cycle-testing new-case --template=orm-attributes",
"test:postgres": "testo --suite=Feature/Postgres --suite=Acceptance/Postgres --suite=Regression/Postgres",
"test:sqlite": "testo --suite=Feature/SQLite --suite=Acceptance/SQLite --suite=Regression/SQLite",
"test:sqlserver": "testo --suite=Feature/SQLServer --suite=Acceptance/SQLServer --suite=Regression/SQLServer",
"test:unit": "testo --suite=Unit"
},
"scripts-descriptions": {
"test:new-case": "Create a regression case for an issue: composer test:new-case -- <issue>"
},
"extra": {
"bamarni-bin": {
Expand Down
23 changes: 0 additions & 23 deletions phpunit.xml

This file was deleted.

17 changes: 17 additions & 0 deletions testo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Cycle\Testing\Config;
use Cycle\Testing\Database\Layout;
use Cycle\Testing\ORM\OrmPlugin;

return Config::forPackage('cycle/annotated', root: __DIR__)
->unit('tests/Unit')
->feature(
'tests/Feature',
layout: Layout::prefixed(['secondary' => 'secondary_']),
plugins: [new OrmPlugin()],
)
->regression('tests/Regression', plugins: [new OrmPlugin()])
->build();
105 changes: 0 additions & 105 deletions tests/Annotated/Fixtures/Fixtures1/TestLogger.php

This file was deleted.

Loading
Loading