Skip to content
Open
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
51 changes: 30 additions & 21 deletions .github/workflows/release-phar.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
name: Append phalcon.phar to release

on:
release:
types:
- created

name: Append phalcon.phar to release
permissions:
contents: write

jobs:
build:
name: Compile and upload Phar
runs-on: ubuntu-18.04
name: Compile and upload PHAR
runs-on: ubuntu-24.04

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Set PHP 7.4
- name: Setup PHP 8.2
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: phalcon-5.1.2
php-version: '8.2'
extensions: mbstring, intl, zip, pdo
coverage: none
tools: composer:v2

- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress --optimize-autoloader

- name: Validate Box configuration
run: vendor/bin/box validate

- name: Compile phalcon.phar
run: |
composer install
wget https://github.com/box-project/box/releases/download/3.9.1/box.phar
php box.phar compile
run: vendor/bin/box compile -v

- name: Check existence of compiled .phar
run: test -e phalcon.phar && exit 0 || exit 10
- name: Verify compiled PHAR
run: test -f phalcon.phar

- name: Upload to Release
uses: actions/upload-release-asset@v1
- name: Smoke test compiled PHAR
run: php phalcon.phar --version

- name: Upload PHAR to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./phalcon.phar
asset_name: phalcon.phar
asset_content_type: application/octet-stream
GH_TOKEN: ${{ github.token }}
run: gh release upload "${{ github.event.release.tag_name }}" phalcon.phar --clobber
219 changes: 127 additions & 92 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,155 +1,190 @@
on: [ push, pull_request ]
name: Tests

name: "Tests"
on:
push:
pull_request:

jobs:
run-tests:
name: PHP ${{ matrix.php-versions }}
name: PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest

env:
extensions: mbstring, intl, json, zip, phalcon-5.2.0, mysql, pgsql, xdebug-2.9.8
key: cache-v2.0~19.03.2020
strategy:
fail-fast: false
matrix:
php-version:
- '8.2'
- '8.3'
- '8.4'

services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: devtools
MYSQL_USER: devtools
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: root
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=5

postgres:
image: postgres:10.8
ports:
- 5432/tcp
image: postgres:13
env:
POSTGRES_DB: devtools
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
POSTGRES_USER: devtools
POSTGRES_PASSWORD: password
ports:
- 5432/tcp
options: >-
--health-cmd="pg_isready -U devtools -d devtools"
--health-interval=10s
--health-timeout=5s
--health-retries=5

strategy:
fail-fast: false
matrix:
php-versions: [ '7.4', '8.0', '8.1', '8.2' ]
steps:
- uses: actions/checkout@v1

- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache extensions
uses: actions/cache@v4
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
tools: pecl
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, zip, pdo_mysql, pdo_pgsql
coverage: xdebug
tools: composer:v2

- name: Get Composer Cache Directory
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache composer dependencies
- 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-
key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-composer-
${{ runner.os }}-composer-

- name: Install Composer dependencies
run: |
composer install --prefer-dist --no-suggest
composer require --dev phpstan/phpstan
run: composer install --prefer-dist --no-interaction --no-progress

- name: Initialise DataBase
- name: Initialise databases
env:
MYSQL_DB_PASSWORD: 'root'
MYSQL_DB_PORT: ${{ job.services.mysql.ports['3306'] }}
MYSQL_DB_PASSWORD: root
POSTGRES_DB_PORT: ${{ job.services.postgres.ports['5432'] }}
PGPASSWORD: password
run: bash tests/_ci/setup_dbs_github.sh

- name: Symbolic link Phalcon devtools
run: sudo ln -s "$(pwd)/phalcon" /usr/local/bin/phalcon
- name: Install Phalcon DevTools command
run: sudo ln -sf "$(pwd)/phalcon" /usr/local/bin/phalcon

- name: Init Webtools and add ports in database setup
- name: Initialise WebTools
env:
MYSQL_DB_PASSWORD: 'root'
MYSQL_DB_HOST: 127.0.0.1
MYSQL_DB_USERNAME: devtools
MYSQL_DB_PASSWORD: password
MYSQL_DB_NAME: devtools
MYSQL_DB_PORT: ${{ job.services.mysql.ports['3306'] }}

POSTGRES_DB_HOST: 127.0.0.1
POSTGRES_DB_USERNAME: devtools
POSTGRES_DB_PASSWORD: password
POSTGRES_DB_NAME: devtools
POSTGRES_DB_PORT: ${{ job.services.postgres.ports['5432'] }}
run: |
rm -rf webtools
phalcon project --name=webtools
sed -i "s/database->charset/database->charset,\n\t\t'port' => \$config->database->port/g" webtools/app/config/services.php
cd webtools
composer install --prefer-dist --no-interaction --no-progress
cd ..
perl -0pi -e "s/'host'\s*=>\s*'[^']*'/'host' => '127.0.0.1'/; s/'username'\s*=>\s*'[^']*'/'username' => 'devtools'/; s/'password'\s*=>\s*'[^']*'/'password' => 'password'/; s/'dbname'\s*=>\s*'[^']*'/'dbname' => 'devtools'/" webtools/app/config/config.php
perl -0pi -e "s/'charset'\s*=>\s*'utf8',/'charset' => 'utf8',\n 'port' => ${MYSQL_DB_PORT},/" webtools/app/config/config.php
sed -i "s/database->charset/database->charset,\n 'port' => \$config->database->port/g" webtools/app/config/services.php
cd webtools
phalcon webtools enable
phalcon serve &
phalcon serve > /tmp/phalcon-webtools.log 2>&1 &
cd ..
for i in {1..30}; do if curl -fsS http://127.0.0.1:8000/ >/dev/null; then exit 0; fi; sleep 1; done
cat /tmp/phalcon-webtools.log
exit 1

- name: Setup tests
run: |
cp tests/.env.test .env

sed -i "s/MYSQL_DB_PORT=3306/MYSQL_DB_PORT=$MYSQL_DB_PORT/g" .env
sed -i "s/MYSQL_DB_PASSWORD=''/MYSQL_DB_PASSWORD='$MYSQL_DB_PASSWORD'/g" .env
sed -i "s/POSTGRES_DB_PORT=5432/POSTGRES_DB_PORT=$POSTGRES_DB_PORT/g" .env

mkdir .phalcon
vendor/bin/codecept build
vendor/bin/phpcs

- name: Run test suites
env:
MYSQL_DB_PASSWORD: 'root'
MYSQL_DB_PORT: ${{ job.services.mysql.ports['3306'] }}
POSTGRES_DB_PORT: ${{ job.services.postgres.ports['5432'] }}
if: success()
run: |
vendor/bin/codecept run --ext DotReporter acceptance -g mysql --env mysql
vendor/bin/codecept run --ext DotReporter acceptance -g pgsql --env pgsql
vendor/bin/codecept run --ext DotReporter acceptance -g common --coverage-xml=coverage-common-${{ matrix.php-versions }}.xml
vendor/bin/codecept run --ext DotReporter unit --coverage-xml=coverage-unit-${{ matrix.php-versions }}.xml
vendor/bin/codecept run --ext DotReporter functional --coverage-xml=coverage-functional-${{ matrix.php-versions }}.xml
vendor/bin/codecept run --ext DotReporter console --coverage-xml=coverage-console-${{ matrix.php-versions }}.xml

- name: If fail - Check Config file
env:
MYSQL_DB_PORT: ${{ job.services.mysql.ports['3306'] }}
POSTGRES_DB_PORT: ${{ job.services.postgres.ports['5432'] }}
sed -i "s/CODECEPTION_URL=nginx/CODECEPTION_URL=127.0.0.1/; s/CODECEPTION_PORT=80/CODECEPTION_PORT=8000/; s/MYSQL_DB_HOST=mysql/MYSQL_DB_HOST=127.0.0.1/; s/MYSQL_DB_PORT=3306/MYSQL_DB_PORT=${MYSQL_DB_PORT}/" tests/.env.test
echo "MYSQL_DB_HOST=127.0.0.1" >> "$GITHUB_ENV"
echo "MYSQL_DB_USERNAME=devtools" >> "$GITHUB_ENV"
echo "MYSQL_DB_PASSWORD=password" >> "$GITHUB_ENV"
echo "MYSQL_DB_NAME=devtools" >> "$GITHUB_ENV"
echo "MYSQL_DB_PORT=${MYSQL_DB_PORT}" >> "$GITHUB_ENV"
echo "POSTGRES_DB_HOST=127.0.0.1" >> "$GITHUB_ENV"
echo "POSTGRES_DB_USERNAME=devtools" >> "$GITHUB_ENV"
echo "POSTGRES_DB_PASSWORD=password" >> "$GITHUB_ENV"
echo "POSTGRES_DB_NAME=devtools" >> "$GITHUB_ENV"
echo "POSTGRES_DB_PORT=${POSTGRES_DB_PORT}" >> "$GITHUB_ENV"
mkdir -p .phalcon
vendor/bin/codecept build
vendor/bin/phpcs

- name: Run MySQL acceptance tests
run: vendor/bin/codecept run --ext DotReporter acceptance -g mysql --env mysql

- name: Run PostgreSQL acceptance tests
run: vendor/bin/codecept run --ext DotReporter acceptance -g pgsql --env pgsql

- name: Run common acceptance tests
run: vendor/bin/codecept run --ext DotReporter acceptance -g common

- name: Run unit tests
run: vendor/bin/codecept run --ext DotReporter unit --coverage-xml=coverage-unit-${{ matrix.php-version }}.xml

- name: Run functional tests
run: vendor/bin/codecept run --ext DotReporter functional --coverage-xml=coverage-functional-${{ matrix.php-version }}.xml

- name: Run console tests
run: vendor/bin/codecept run --ext DotReporter console --coverage-xml=coverage-console-${{ matrix.php-version }}.xml

- name: PHPStan
run: vendor/bin/phpstan analyse

- name: Psalm
run: vendor/bin/psalm --threads=1

- name: Debug failed build
if: failure()
run: |
cat webtools/app/config/config.php
cat webtools/app/config/services.php
echo "<?php print_r(include('webtools/app/config/config.php')) ?>" > content_config.php
php content_config.php
php tests/debug.php

- uses: actions/upload-artifact@v4
echo "=== WebTools config ==="
cat webtools/app/config/config.php || true
echo "=== WebTools services ==="
cat webtools/app/config/services.php || true
echo "=== WebTools server ==="
cat /tmp/phalcon-webtools.log || true
echo "=== PHP ==="
php -v
echo "=== Composer packages ==="
composer show -D || true

- name: Upload Codeception logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: Codeception Logs
name: codeception-logs-php-${{ matrix.php-version }}
path: tests/_output

#- name: Check psalm
# run: vendor/bin/psalm --show-info=false

#- name: Check phpstan
# run: vendor/bin/phpstan analyse -l 5 -c phpstan.neon src -v
if-no-files-found: ignore

- name: Upload coverage to Codecov
if: success()
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v5
with:
token: ${{secrets.CODECOV_TOKEN}}
file: ./tests/_output/coverage-*.xml
token: ${{ secrets.CODECOV_TOKEN }}
files: ./tests/_output/coverage-unit-${{ matrix.php-version }}.xml,./tests/_output/coverage-functional-${{ matrix.php-version }}.xml,./tests/_output/coverage-console-${{ matrix.php-version }}.xml
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
*.iml

# local tests

.local/
.phalcon/
dummy/
default/

# DevTools model generator test fixture
!tests/_data/model-project/.phalcon/
!tests/_data/model-project/.phalcon/.gitkeep

# composer
vendor/
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
# Unreleased

## Added

- Added Phalcon 6 runtime support using the Composer-based `phalcon/phalcon` package.
- Added PHP 8.2, 8.3 and 8.4 CI coverage.
- Added Codeception 5 console coverage for migrations.
- Added PHPStan and Psalm static-analysis coverage for the Phalcon 6 codebase.

## Changed

- Updated runtime requirements to PHP 8.2+ and Phalcon 6.
- Updated project, model, scaffold and WebTools generation for Phalcon 6.
- Updated migration support for `phalcon/migrations` v4.
- Modernized Codeception, PHPUnit, PHPStan, Psalm and PHP_CodeSniffer tooling.
- Reduced runtime dependencies so development-only packages are excluded from consumer installations.
- Updated migrations to use `Phalcon\Migrations\Utils\Config`.
- Updated migration configuration handling for Phalcon Migrations v4.

## Fixed

- Fixed model metadata namespace handling under Phalcon 6.
- Fixed migration `generate`, `run` and `list` compatibility with `phalcon/migrations` v4.
- Fixed migration options loaded from application configuration.
- Fixed compatibility issues exposed by PHP 8.4.

# [4.1.0](https://github.com/phalcon/cphalcon/releases/tag/v4.1.0)
## Fixed
- Fixed column annotation bugs on model creation [1425](https://github.com/phalcon/phalcon-devtools/issues/1425)
Expand Down
Loading
Loading