Skip to content

Merge pull request #16447 from misantron/redis-timeout-option #2678

Merge pull request #16447 from misantron/redis-timeout-option

Merge pull request #16447 from misantron/redis-timeout-option #2678

name: Phalcon CI
on:
schedule:
- cron: '0 2 * * *' # Daily at 02:00 runs only on default branch
push:
paths-ignore:
- '**.md'
- '**.txt'
pull_request:
jobs:
generate:
# To prevent build a particular commit use
# git commit -m "......... [ci skip]"
if: "!contains(github.event.head_commit.message, 'ci skip')"
runs-on: ubuntu-20.04
name: Build Phalcon Pecl Package
steps:
- name: Setup Environment Variables
run: |
echo "ZEPHIR_PARSER_VERSION=v1.3.6" >> $GITHUB_ENV
echo "ZEPHIR_VERSION=0.13.0-beta-1" >> $GITHUB_ENV
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: mbstring, intl, json, psr
tools: pecl
- name: Common Settings
run: |
# Core dump settings
ulimit -c unlimited -S || true
# Hide "You are in 'detached HEAD' state" message
git config --global advice.detachedHead false
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup APT Repositories
run: |
# We don't need this at all, and our
# builds often fails because Microsoft
# servers are unstable or even offline.
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
- name: Setup Composer Token
run: |
# To increase the Composer rate limit we're use GitHub authentication
if [ -n "${{ secrets.COMPOSER_TOKEN }}" ]; then
composer config github-oauth.github.com "${{ secrets.COMPOSER_TOKEN }}"
fi
- name: Install Zephir
run: .ci/install-zephir.sh
- name: Generate C Code
run: |
$HOME/bin/zephir fullclean
$HOME/bin/zephir generate
(cd build && php gen-build.php)
- name: Create Pecl Package (PHP 8)
id: pecl_create
run: |
cp build/php8/safe/config.w32 config.w32
cp build/php8/safe/phalcon.zep.c phalcon.zep.c
cp build/php8/safe/config.m4 config.m4
cp build/php8/safe/php_phalcon.h php_phalcon.h
cp build/php8/safe/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@v1
with:
name: 'phalcon-pecl'
path: phalcon-pecl.tgz
build-and-test-linux:
# To prevent build a particular commit use
# git commit -m "......... [ci skip]"
if: "!contains(github.event.head_commit.message, 'ci skip')"
needs: generate
services:
mysql:
image: mysql:5.7
ports:
- 3306
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_USER: phalcon
MYSQL_DATABASE: phalcon
MYSQL_PASSWORD: secret
postgres:
image: postgres:12-alpine
ports:
- 5432
env:
POSTGRES_PASSWORD: secret
POSTGRES_DB: phalcon
redis:
image: redis:5-alpine
ports:
- 6379
memcached:
image: memcached:1.5-alpine
ports:
- 11211
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-20.04]
php-versions: ['7.4', '8.0']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup Composer Cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup Composer Token
run: |
# To increase the Composer rate limit we're use GitHub authentication
if [ -n "${{ secrets.COMPOSER_TOKEN }}" ]; then
composer config github-oauth.github.com "${{ secrets.COMPOSER_TOKEN }}"
fi
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: apc.enable_cli=on, session.save_path=/tmp, extension=psr.so, extension=phalcon.so
tools: pecl
extensions: mbstring, intl, json, imagick, redis, igbinary, apcu, msgpack, memcached, yaml
- name: Download Phalcon Pecl Package
uses: actions/download-artifact@v1
with:
name: phalcon-pecl
- name: Install package
run: |
export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"
sudo pecl -v install phalcon-pecl/phalcon-pecl.tgz
- name: Verify Install
run: php --ri phalcon
- name: Install Packages
run: composer install --prefer-dist
- name: Setup Tests
run: |
cp tests/_ci/.env.default .env
php tests/_ci/generate-db-schemas.php
vendor/bin/codecept build
- name: Run Unit Tests
if: always()
run: vendor/bin/codecept run --ext DotReporter unit
- name: Run CLI Tests
if: always()
run: vendor/bin/codecept run --ext DotReporter cli
- name: Run Integration Tests
env:
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
if: always()
run: vendor/bin/codecept run --ext DotReporter integration
- name: Run Database Tests (Common)
env:
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
DATA_MYSQL_USER: root
if: always()
run: vendor/bin/codecept run --ext DotReporter database -g common
- name: Run Database Tests (MySQL)
env:
DATA_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
DATA_MYSQL_USER: root
if: always()
run: vendor/bin/codecept run --ext DotReporter database --env mysql -g mysql
- 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 --ext DotReporter database --env sqlite -g sqlite
- name: Run Database Tests (Postgres)
env:
DATA_POSTGRES_USER: postgres
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 --ext DotReporter database --env pgsql -g pgsql
# - name: Run Database Tests (SQL Server)
# env:
# DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
# DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
# run: vendor/bin/codecept run --ext DotReporter database --env sqlsrv
build-and-test-macos:
# To prevent build a particular commit use
# git commit -m "......... [ci skip]"
if: "!contains(github.event.head_commit.message, 'ci skip')"
needs: generate
runs-on: ${{ matrix.operating-system }}
env:
PHP_EXTENSIONS: mbstring, intl, json, yaml, apcu, imagick, igbinary, msgpack-beta, redis
strategy:
fail-fast: false
matrix:
operating-system: [macos-latest]
php-versions: ['7.4', '8.0']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Get Extension Directory
id: extension-step
run: |
suffix=$(curl -sSL --retry 3 https://raw.githubusercontent.com/php/php-src/PHP-${{ matrix.php-versions }}/main/php.h | grep PHP_API_VERSION | cut -d' ' -f 3)
ext_dir="/usr/local/lib/php/pecl/$suffix"
ext_hash=$(echo -n "${{ env.PHP_EXTENSIONS }}" | shasum -a 256 | cut -d' ' -f 1)
echo "::set-output name=ext_dir::$ext_dir"
echo "::set-output name=ext_hash::$ext_hash"
- name: Cache Extensions
uses: actions/cache@v1
with:
path: ${{ steps.extension-step.outputs.ext_dir }}
key: ${{ runner.os }}-extensions-${{ matrix.php-versions }}-${{ steps.extension-step.outputs.ext_hash }}
restore-keys: ${{ runner.os }}-extensions-${{ matrix.php-versions }}-${{ steps.extension-step.outputs.ext_hash }}
- name: Install Requirements for Imagick
run: brew install pkg-config imagemagick
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: apc.enable_cli=on, session.save_path=/tmp
extensions: ${{ env.PHP_EXTENSIONS }}
- name: Get Composer Cache Directory
id: composer-cache
run: |
# FIXME: This call produces the following warning on maOS:
#
# PHP Warning: Version warning: Imagick was compiled
# against ImageMagick version 1801 but version 1802 is
# loaded. Imagick will run but may behave surprisingly
# in Unknown on line 0
#
# For more see:
# https://github.com/phalcon/cphalcon/pull/14929/checks?check_run_id=534926444
#
# And this seems breaks the output of the following command:
# echo "::set-output name=dir::$(composer config cache-files-dir)"
echo "::set-output name=dir::~/.composer/cache/files"
- name: Setup GitHub Token
run: |
# To increase the GitHub rate limit we're use GitHub authentication
if [ -n "${{ secrets.COMPOSER_TOKEN }}" ]; then
composer config github-oauth.github.com "${{ secrets.COMPOSER_TOKEN }}"
fi
- name: Setup Cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Download Phalcon Pecl Package
uses: actions/download-artifact@v1
with:
name: phalcon-pecl
- name: Install Package
run: |
sudo xcode-select -s /Applications/Xcode_12.app
xcodebuild -version
export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"
sudo pecl -v install phalcon-pecl/phalcon-pecl.tgz
sudo pecl -v install msgpack
- name: Verify Install
run: php --ri phalcon
- name: Install Packages
run: composer install --prefer-dist
- name: Setup Tests
run: |
cp tests/_ci/.env.default .env
vendor/bin/codecept build
- name: Run Unit Tests
run: vendor/bin/codecept run --ext DotReporter unit
- name: Run CLI Tests
run: vendor/bin/codecept run --ext DotReporter cli
build-and-test-windows:
# To prevent build a particular commit use
# git commit -m "......... [ci skip]"
if: "!contains(github.event.head_commit.message, 'ci skip')"
name: PHP ${{ matrix.php-versions }} (${{ matrix.ts }}) Test on ${{ matrix.operating-system }}
needs: generate
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [windows-2016]
php-versions: ['7.4', '8.0']
ts: [ts, nts]
include:
- php-versions: '7.4'
vc_num: 'vc15'
arch: x64
build_type: Win32
- php-versions: '8.0'
vc_num: 'vs16'
arch: x64
build_type: Win32
steps:
- name: Disable Git autocrlf
run: git config --global core.autocrlf false
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: apc.enable_cli=on, session.save_path=C:\temp
tools: pecl
extensions: mbstring, intl, json, yaml, apcu, imagick, gd, redis, igbinary, sqlite3, msgpack
env:
PHPTS: ${{ matrix.ts }}
- name: Setup Environment Variables
run: |
Write-Output "PHP_SDK_VERSION=2.2.0" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "PHP_DEVPACK=C:\tools\php-devpack" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "PHP_SDK_PATH=C:\tools\php-sdk" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "PHP_PECL_PATH=C:\tools\pecl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "PSR_VERSION=1.0.1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# FIXME: phpversion() return 7.4.3 but windows.php.net has only 7.4.4
# We should parse the following file to get the correct version:
# https://windows.php.net/downloads/releases/sha256sum.txt
If ("${{ matrix.php-versions }}" -eq "7.4") {
Write-Output "PHP_VERSION=7.4.4" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
} Else {
Write-Output "PHP_VERSION=$(php -r 'echo phpversion();')" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
Write-Output "PHP_MINOR=${{ matrix.php-versions }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "TEST_PHP_EXECUTABLE=${env:PHPROOT}\php.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "VC_VERSION=${{ matrix.vc_num }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "PHP_ARCH=${{ matrix.arch }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "PACKAGE_PREFIX=phalcon" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "EXTENSION_NAME=phalcon" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "EXTENSION_FILE=php_phalcon.dll" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "PHALCON_VERSION=4.2.0" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Output "PHPTS=${{ matrix.ts }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
If ("${{ matrix.ts }}" -eq "nts") {
Write-Output "BUILD_TYPE=nts-${{ matrix.build_type }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
} Else {
Write-Output "BUILD_TYPE=${{ matrix.build_type }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
- name: Setup Composer Token
run: |
# To increase the Composer rate limit we're use GitHub authentication
if ("${{ secrets.COMPOSER_TOKEN }}" -ne "") {
composer config github-oauth.github.com ${{ secrets.COMPOSER_TOKEN }}
}
- name: Setup Common Environment
run: |
Import-Module .\.ci\win-ci-tools.psm1
SetupCommonEnvironment
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup Cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Download Phalcon Pecl Package
uses: actions/download-artifact@v1
with:
name: phalcon-pecl
- name: Install PHP SDK Binary Tools
run: |
Import-Module .\.ci\win-ci-tools.psm1
InstallPhpSdk
- name: Install PHP Dev pack
run: |
Import-Module .\.ci\win-ci-tools.psm1
InstallPhpDevPack
- name: Getting Details About Installed PHP
run: |
Import-Module .\.ci\win-ci-tools.psm1
Get-Php "${env:PHPROOT}"
- name: Install System Dependencies
run: choco install -y --cache-location=C:\Downloads\Choco re2c
- name: Initialize Release Variables
run: |
Import-Module .\.ci\win-ci-tools.psm1
InitializeReleaseVars
- name: "Setup Visual Studio Command Line for PHP SDK ${{ matrix.arch }}"
run: .ci\vsenv.bat -arch=${{ matrix.arch }} -host_arch=${{ matrix.arch }}
- name: Fix Environment Variables
shell: powershell
run: |
$v = "${env:WindowsSDKVersion}" -replace '\\$', ''
Write-Output "WindowsSDKVersion=$v" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$v = "${env:WindowsSDKLibVersion}" -replace '\\$', ''
Write-Output "WindowsSDKLibVersion=$v" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Unpack Package
run: |
Import-Module .\.ci\win-ci-tools.psm1
Expand-Item7zip "phalcon-pecl\phalcon-pecl.tgz" "${env:Temp}"
Expand-Item7zip "${env:Temp}\phalcon-pecl.tar" "${env:PHP_PECL_PATH}\phalcon"
- name: PSR extension | init, phpize
shell: cmd
run: |
set PATH=%PATH%;%PHP_DEVPACK%
git clone https://github.com/jbboehr/php-psr.git %PHP_PECL_PATH%\psr\psr-%PSR_VERSION%
if not exist "%PHP_DEVPACK%\include\ext\psr" MkDir "%PHP_DEVPACK%\include\ext\psr"
cd /d %PHP_PECL_PATH%\psr\psr-%PSR_VERSION%
phpize
- name: PSR extension | configure
shell: cmd
run: |
set PATH=%PATH%;%PHP_DEVPACK%
cd /d %PHP_PECL_PATH%\psr\psr-%PSR_VERSION%
configure --enable-psr
- name: PSR extension | build
shell: cmd
run: |
set PATH=%PATH%;%PHP_DEVPACK%
cd /d %PHP_PECL_PATH%\psr\psr-%PSR_VERSION%
nmake
nmake install
- name: Run phpize
shell: cmd
run: |
set PATH=%PATH%;%PHP_DEVPACK%
cd /d %PHP_PECL_PATH%\phalcon\phalcon-%PHALCON_VERSION%
phpize
- name: Configure Project
shell: cmd
run: |
set PATH=%PATH%;%PHP_DEVPACK%
cd /d %PHP_PECL_PATH%\phalcon\phalcon-%PHALCON_VERSION%
configure --enable-phalcon
- name: Build Project
shell: cmd
run: |
set PATH=%PATH%;%PHP_DEVPACK%;%PHP_PECL_PATH%\psr\psr-%PSR_VERSION%
cd /d %PHP_PECL_PATH%\phalcon\phalcon-%PHALCON_VERSION%
nmake
- name: Inspecting Phalcon Extension DLL File
run: Get-PhpExtension "${env:RELEASE_DLL_PATH}"
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: ${{ env.RELEASE_ZIPBALL }}
path: ${{ env.RELEASE_DLL_PATH }}
- name: Enable Phalcon
run: |
Import-Module .\.ci\win-ci-tools.psm1
EnablePhalconExtension
- name: Verify Install
run: php --ri phalcon
- name: Install Packages
run: composer install --prefer-dist
- name: Setup Tests
run: |
cp tests/_ci/.env.default .env
vendor/bin/codecept build
- name: Run Unit Tests
run: vendor/bin/codecept run --ext DotReporter unit
- name: Run CLI Tests
run: vendor/bin/codecept run --ext DotReporter cli