Skip to content

[#16830] - adding back missing commit for 16830 #3235

[#16830] - adding back missing commit for 16830

[#16830] - adding back missing commit for 16830 #3235

Workflow file for this run

# This file is part of Phalcon.
#
# (c) Phalcon Team <[email protected]>
#
# For the full copyright and license information, please view
# the LICENSE file that was distributed with this source code.
name: Phalcon CI
on:
push:
paths-ignore:
- '**.md'
- '**.txt'
pull_request:
workflow_dispatch:
env:
# All versions should be declared here
PHALCON_VERSION: 5.11.1
ZEPHIR_PARSER_VERSION: 1.8.0
# For tests
LANG: en_US.UTF-8
LANGUAGE: en_US.UTF-8
LC_ALL: en_US.UTF-8
# Windows specific
TOOLS_DIR: 'C:\tools'
CACHE_DIR: 'C:\Downloads'
# PHP extensions required by Composer
EXTENSIONS: apcu, gettext, gd, igbinary, imagick, intl, json, mbstring, msgpack, memcached, pcov, sqlite3, yaml, redis, :memcache, openssl
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
# PHP CodeSniffer - gates build-and-test and database_test
phpcs:
permissions:
contents: read
name: Check code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
- name: Install dependencies
run: composer install --prefer-dist --ignore-platform-reqs
- name: Run PHP_CodeSniffer
run: composer cs
# Validate PIE metadata and source-build from local checkout
pie_smoke_test:
permissions:
contents: read
name: PIE smoke test / PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: [phpcs]
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
php:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
- '8.5'
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: phpize, php-config
- name: Validate PIE metadata
run: |
TYPE=$(php -r 'echo json_decode(file_get_contents("composer.json"))->type;')
EXT_NAME=$(php -r 'echo json_decode(file_get_contents("composer.json"))->{"php-ext"}->{"extension-name"};')
BUILD_PATH=$(php -r 'echo json_decode(file_get_contents("composer.json"))->{"php-ext"}->{"build-path"};')
if [ "$TYPE" != "php-ext" ]; then echo "::error::composer.json type must be php-ext, got: $TYPE"; exit 1; fi
if [ "$EXT_NAME" != "phalcon" ]; then echo "::error::extension-name must be phalcon, got: $EXT_NAME"; exit 1; fi
if [ "$BUILD_PATH" != "build/phalcon" ]; then echo "::error::build-path must be build/phalcon, got: $BUILD_PATH"; exit 1; fi
echo "PIE metadata OK: type=$TYPE, extension-name=$EXT_NAME, build-path=$BUILD_PATH"
- name: Build extension from build/phalcon (same path PIE uses)
run: |
cd build/phalcon
phpize
./configure --enable-phalcon
make -j"$(nproc)"
- name: Validate extension loads
run: php -d extension=build/phalcon/modules/phalcon.so -r 'echo "phalcon " . (new Phalcon\Support\Version())->get() . PHP_EOL;'
# Generate IDE stubs, validate with Psalm, fix code style and store as artifact
stubs:
permissions:
contents: read
name: Stubs
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
tools: pecl
extensions: zephir_parser-${{ env.ZEPHIR_PARSER_VERSION }}
- name: Install System Dependencies
run: |
sudo apt-get update --quiet --yes 1>/dev/null
sudo apt-get install --no-install-recommends -q -y re2c
- run: composer install --prefer-dist --ignore-platform-reqs
- name: Generate and validate stubs
run: |
vendor/bin/zephir stubs
vendor/bin/psalm ide/
- name: Fix code style on generated stubs
# phpcbf exits 1 when it fixes files; passing the path on the CLI overrides
# the <file> entries in phpcs.xml so the PSR12 ruleset is applied to the stubs.
run: vendor/bin/phpcbf --standard=phpcs.xml ide/${{ env.PHALCON_VERSION }}/ || true
- name: Upload IDE stubs artifact
uses: actions/upload-artifact@v7
with:
name: phalcon-ide-stubs
path: ide/${{ env.PHALCON_VERSION }}/Phalcon/
retention-days: 5
# Build Phalcon PECL package (artifact consumed by build-and-test and database_test)
generate_pecl:
name: Build Phalcon PECL package
needs: [phpcs, stubs]
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: zephir_parser-${{ env.ZEPHIR_PARSER_VERSION }}
tools: pecl
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup APT Repositories
run: |
# Remove Microsoft repos — our builds often fail due to
# unstable/offline Microsoft servers.
sudo rm -f /etc/apt/sources.list.d/dotnetdev.list
sudo rm -f /etc/apt/sources.list.d/azure*.list
- name: Install System Dependencies
run: |
sudo apt-get update --quiet --yes 1>/dev/null
sudo apt-get install --no-install-recommends -q -y re2c
- run: composer install --ignore-platform-reqs
- name: Generate C Code
run: |
vendor/bin/zephir fullclean
vendor/bin/zephir generate
(cd build && php gen-build.php)
- name: Upload compile-errors.log
uses: actions/upload-artifact@v7
if: failure()
with:
name: compile-errors
path: compile-errors.log
- name: Create Pecl Package
id: pecl_create
run: |
cp build/phalcon/config.w32 config.w32
cp build/phalcon/phalcon.zep.c phalcon.zep.c
cp build/phalcon/config.m4 config.m4
cp build/phalcon/php_phalcon.h php_phalcon.h
cp build/phalcon/phalcon.zep.h phalcon.zep.h
pecl package
phalcon_package="`ls | grep phalcon-*tgz`"
mv $phalcon_package phalcon-pecl.tgz
- name: Validate Pecl Package
run: pecl package-validate phalcon-pecl.tgz
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: 'phalcon-pecl'
path: phalcon-pecl.tgz
# Verify the extension installs cleanly from the build/ directory
install:
name: Install / PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: [phpcs, stubs]
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
php:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
- '8.5'
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: zephir_parser-${{ env.ZEPHIR_PARSER_VERSION }}
tools: pecl
- name: Install from build/ directory
run: |
cd build/
php gen-build.php
sudo ./install
- name: Validate extension
if: success()
run: php -d extension=phalcon -r 'echo (new Phalcon\Support\Version())->get();' || exit 1
build_extension:
permissions:
contents: read
name: Build / PHP-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}
needs: [generate_pecl, install]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
php:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
- '8.5'
ts:
- 'nts'
- 'ts'
arch:
- 'x64'
name:
- ubuntu-gcc
include:
- { name: ubuntu-gcc, os: ubuntu-22.04, compiler: gcc }
steps:
- uses: actions/checkout@v6
- name: Setup platform specific environment
shell: pwsh
run: |
git config --global core.autocrlf false
$SessionSavePath = if ("${{ runner.os }}" -eq "Windows") { 'C:\temp' } else { '/tmp' }
Write-Output "SESSION_SAVE_PATH=$SessionSavePath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.EXTENSIONS }}
ini-values: apc.enable_cli=on, session.save_path=${{ env.SESSION_SAVE_PATH }}, register_argc_argv=on
tools: pecl, phpize, php-config
env:
PHPTS: ${{ matrix.ts }}
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Phalcon Pecl Package
uses: actions/download-artifact@v8
with:
name: phalcon-pecl
path: ./phalcon-pecl
- name: Build Phalcon Extension (Linux)
if: runner.os == 'Linux'
id: linux-build
uses: ./.github/actions/build-phalcon-linux
with:
pecl: ./phalcon-pecl/phalcon-pecl.tgz
php-version: ${{ matrix.php }}
- name: Upload compiled Phalcon extension (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v7
with:
name: phalcon-so-php${{ matrix.php }}-${{ matrix.ts }}-linux-x64
path: ${{ steps.linux-build.outputs.extension-dir }}/phalcon.so
retention-days: 1
- name: Build Phalcon Extension (macOS)
if: runner.os == 'macOS'
uses: ./.github/actions/build-phalcon-macos
with:
pecl: ./phalcon-pecl/phalcon-pecl.tgz
- name: Build Phalcon Extension (Windows)
if: runner.os == 'Windows'
uses: ./.github/actions/build-phalcon-win
with:
pecl: ./phalcon-pecl/phalcon-pecl.tgz
php-version: ${{ matrix.php }}
ts: ${{ matrix.ts }}
compiler: ${{ matrix.compiler }}
arch: ${{ matrix.arch }}
phalcon-version: ${{ env.PHALCON_VERSION }}
tools-dir: ${{ env.TOOLS_DIR }}
cache-dir: ${{ env.CACHE_DIR }}
os: ${{ matrix.os }}
- name: Pack Phalcon Extension
shell: pwsh
run: |
if ( "${{ runner.os }}" -eq 'Windows' ) {
$ReleaseFolder = if ("${{ matrix.ts }}" -eq "ts") { "Release_TS" } else { "Release" }
$ReleaseFolder = if ("${{ matrix.arch }}" -eq "x64") { "x64\${ReleaseFolder}" } else { "${ReleaseFolder}" }
$ExtPath = "${{ env.TOOLS_DIR }}\pecl\phalcon\phalcon-${{ env.PHALCON_VERSION }}\${ReleaseFolder}\php_phalcon.dll"
} else {
$ExtPath = "$(php-config --extension-dir)/phalcon.so"
}
if ([string]::IsNullOrEmpty($ExtPath) -or -not (Test-Path $ExtPath)) {
Write-Error "Phalcon extension not found at: '$ExtPath'"
exit 1
}
$TargetName = "phalcon-php${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}"
$Destination = "./build-artifacts"
if (-not (Test-Path -Path $Destination -PathType Container)) {
New-Item $Destination -ItemType Directory | Out-Null
}
Copy-Item -Path $ExtPath -Destination $Destination
Copy-Item -Path "./3rdparty/licenses/*.txt" -Destination $Destination
Set-Location $Destination
& 7z a "$TargetName.zip" *
- name: Upload Phalcon Extension Artifact
uses: actions/upload-artifact@v7
with:
name: phalcon-php${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}.zip
path: ./build-artifacts/phalcon*.zip
retention-days: 30
unit_test:
permissions:
contents: read
name: Unit / PHP-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}
needs: [build_extension]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
services:
redis:
image: redis:8-alpine
ports:
- "6379:6379"
memcached:
image: memcached:1.6-alpine
ports:
- "11211:11211"
strategy:
fail-fast: false
matrix:
php:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
- '8.5'
ts:
- 'nts'
- 'ts'
arch:
- 'x64'
name:
- ubuntu-gcc
include:
- { name: ubuntu-gcc, os: ubuntu-22.04, compiler: gcc }
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.EXTENSIONS }}
ini-values: apc.enable_cli=on, session.save_path=/tmp, register_argc_argv=on
tools: pecl, phpize, php-config
coverage: pcov
env:
PHPTS: ${{ matrix.ts }}
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Redis Cluster
uses: vishnudxb/[email protected]
with:
master1-port: 5000
master2-port: 5001
master3-port: 5002
slave1-port: 5003
slave2-port: 5004
slave3-port: 5005
sleep-duration: 5
- name: Download compiled Phalcon extension
uses: actions/download-artifact@v8
with:
name: phalcon-so-php${{ matrix.php }}-${{ matrix.ts }}-linux-x64
path: ./phalcon-so
- name: Install Phalcon extension
shell: bash
run: |
EXT_DIR=$(php-config --extension-dir)
sudo cp ./phalcon-so/phalcon.so "$EXT_DIR/phalcon.so"
echo "extension=phalcon" | sudo tee /etc/php/${{ matrix.php }}/cli/conf.d/99-phalcon.ini
php --ri phalcon
- name: Validate composer
run: composer validate --no-check-all --no-check-publish
- name: Install development dependencies with Composer
uses: ramsey/composer-install@v3
with:
composer-options: "--prefer-dist --ignore-platform-reqs"
- name: Setup Tests
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
./.ci/linux-setup-locales.sh
fi
cp tests/support/_config/.env.default .env
php tests/support/_config/generate-db-schemas.php
- name: Run Unit Tests
if: always()
run: vendor/bin/phpunit -c phpunit.xml.dist
- name: Upload Unit Test Coverage
uses: actions/upload-artifact@v7
if: always()
with:
name: "unit-${{ matrix.php }}.coverage"
path: "tests/_output/coverage.xml"
retention-days: 7
- name: Check Release notes parser
shell: bash
run: |
echo "-- Creating Release Notes"
./.ci/release-notes.sh ./CHANGELOG-5.0.md
database_test:
permissions:
contents: read
name: Db / PHP-${{ matrix.php }}
needs: [build_extension]
runs-on: ubuntu-latest
timeout-minutes: 60
services:
mysql:
image: mysql:8.0
ports:
- "3306:3306"
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_USER: phalcon
MYSQL_DATABASE: phalcon
MYSQL_PASSWORD: secret
options: >-
--health-cmd "mysqladmin ping --silent"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres:18-alpine
ports:
- "5432:5432"
env:
POSTGRES_USER: phalcon
POSTGRES_PASSWORD: secret
POSTGRES_DB: phalcon
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:8-alpine
ports:
- "6379:6379"
memcached:
image: memcached:1.6-alpine
ports:
- "11211:11211"
strategy:
fail-fast: false
matrix:
php:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
- '8.5'
steps:
- uses: actions/checkout@v6
- name: "Setup platform specific environment"
shell: pwsh
run: git config --global core.autocrlf false
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.EXTENSIONS }}
ini-values: apc.enable_cli=on, session.save_path=/tmp, register_argc_argv=on
coverage: pcov
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download compiled Phalcon extension
uses: actions/download-artifact@v8
with:
name: phalcon-so-php${{ matrix.php }}-nts-linux-x64
path: ./phalcon-so
- name: Install Phalcon extension
shell: bash
run: |
EXT_DIR=$(php-config --extension-dir)
sudo cp ./phalcon-so/phalcon.so "$EXT_DIR/phalcon.so"
echo "extension=phalcon" | sudo tee /etc/php/${{ matrix.php }}/cli/conf.d/99-phalcon.ini
php --ri phalcon
- name: Prepare test Environment
run: |
echo "::group::Set up locales"
./.ci/linux-setup-locales.sh
echo "::endgroup::"
- name: Validate composer
run: composer validate --no-check-all --no-check-publish
- name: Install development dependencies with Composer
uses: ramsey/composer-install@v3
with:
composer-options: "--prefer-dist --ignore-platform-reqs"
- name: Setup Tests
run: |
cp tests/support/_config/.env.default .env
php tests/support/_config/generate-db-schemas.php
- name: Run Database Tests (MySQL)
env:
DATA_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
DATA_MYSQL_USER: root
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
run: vendor/bin/phpunit -c phpunit.mysql.xml
- name: Upload Database (MySQL) Coverage
uses: actions/upload-artifact@v7
if: always()
with:
name: "db-mysql-${{ matrix.php }}.coverage"
path: "tests/_output/coverage.xml"
retention-days: 7
# - name: Run Database Tests (Sqlite)
# env:
# DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
# DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
# if: always()
# run: vendor/bin/codecept run --coverage-xml=coverage-database-sqlite-${{ matrix.php }}.xml --ext DotReporter database --env sqlite -g sqlite
#
# - name: Upload Database (Sqlite) Coverage
# uses: actions/upload-artifact@v7
# if: always()
# with:
# name: coverage-database-sqlite-${{ matrix.php }}
# path: tests/_output/coverage-database-sqlite-${{ matrix.php }}.xml
# retention-days: 7
#
# - name: Run Database Tests (Postgres)
# env:
# DATA_POSTGRES_USER: phalcon
# DATA_POSTGRES_PASS: secret
# DATA_POSTGRES_PORT: ${{ job.services.postgres.ports['5432'] }}
# DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
# DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
# if: always()
# run: vendor/bin/codecept run --coverage-xml=coverage-database-pgsql-${{ matrix.php }}.xml --ext DotReporter database --env pgsql -g pgsql
#
# - name: Upload Database (Postgres) Coverage
# uses: actions/upload-artifact@v7
# if: always()
# with:
# name: coverage-database-pgsql-${{ matrix.php }}
# path: tests/_output/coverage-database-pgsql-${{ matrix.php }}.xml
# retention-days: 7
# Disabling this from cphalcon because codecov is not finding the sourceset for the coverage report.
# upload-coverage:
# permissions:
# contents: read
#
# name: "Upload coverage"
# runs-on: ubuntu-latest
# needs: [unit_test]
#
# steps:
# - uses: actions/checkout@v6
# with:
# fetch-depth: 2
#
# - name: "Create download folder"
# run: |
# mkdir -p reports
#
# - name: "Download coverage files"
# uses: actions/download-artifact@v8
# with:
# path: reports
# pattern: coverage-*
#
# - name: "Display structure of downloaded files"
# run: ls -R
# working-directory: reports
#
# - name: "Upload to Codecov"
# uses: codecov/codecov-action@v6
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# directory: reports
# fail_ci_if_error: true
# verbose: true
# name: codecov-umbrella
release:
permissions:
contents: write
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [generate_pecl, build_extension, unit_test, database_test]
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download Phalcon build artifacts
id: download
uses: actions/download-artifact@v8
with:
path: ./build-artifacts
- name: Prepare Release assets
run: |
mkdir -p ./build-artifacts/release
find ./build-artifacts -type f -name phalcon*.zip -exec cp {} ./build-artifacts/release/ ";"
find ./build-artifacts -type f -name phalcon*.tgz -exec cp {} ./build-artifacts/release/ ";"
echo "-- Creating Release Notes"
./.ci/release-notes.sh ./CHANGELOG-5.0.md > ./build-artifacts/release/release-notes.md
- name: Create Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ github.ref_name }}
tag: ${{ github.ref_name }}
bodyFile: "./build-artifacts/release/release-notes.md"
allowUpdates: true
artifacts: "./build-artifacts/release/*.zip,./build-artifacts/release/*.tgz"
artifactContentType: application/octet-stream
publish_stubs:
permissions:
contents: read
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
name: Publish IDE Stubs
runs-on: ubuntu-latest
needs: [release, stubs]
steps:
- uses: actions/checkout@v6
- name: Download IDE stubs artifact
uses: actions/download-artifact@v8
with:
name: phalcon-ide-stubs
path: ./ide-stubs
- name: Checkout phalcon-ide-stubs
uses: actions/checkout@v6
with:
repository: phalcon/ide-stubs
token: ${{ secrets.STUBS_REPO_TOKEN }}
path: phalcon-ide-stubs
- name: Copy stubs into phalcon-ide-stubs
# Copies the contents of ide/<version>/Phalcon/ into the stubs repo src/ folder.
# No files are deleted; other repo files are unaffected.
run: cp -r ./ide-stubs/. phalcon-ide-stubs/src/
- name: Commit and push stubs branch
working-directory: phalcon-ide-stubs
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b stubs/v${{ env.PHALCON_VERSION }}
git add src/
git commit -m "stubs: update to v${{ env.PHALCON_VERSION }}"
git push origin stubs/v${{ env.PHALCON_VERSION }}
- name: Create Pull Request in phalcon-ide-stubs
working-directory: phalcon-ide-stubs
env:
GH_TOKEN: ${{ secrets.STUBS_REPO_TOKEN }}
run: |
gh pr create \
--repo phalcon/ide-stubs \
--head stubs/v${{ env.PHALCON_VERSION }} \
--base master \
--title "stubs: update to v${{ env.PHALCON_VERSION }}" \
--body "v${{ env.PHALCON_VERSION }} Stubs"
- name: Create draft release in phalcon-ide-stubs
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.STUBS_REPO_TOKEN }}
owner: phalcon
repo: phalcon-ide-stubs
tag: v${{ env.PHALCON_VERSION }}
name: v${{ env.PHALCON_VERSION }} Stubs
body: "v${{ env.PHALCON_VERSION }} Stubs"
draft: true
allowUpdates: true
commit: master