Skip to content

[#ests] - updating composer, enabling more tests #227

[#ests] - updating composer, enabling more tests

[#ests] - updating composer, enabling more tests #227

# This file is part of Phalcon.
#
# (c) Phalcon Team <team@phalcon.io>
#
# For the full copyright and license information, please view
# the LICENSE file that was distributed with this source code.
name: "Phalcon CI"
on:
schedule:
- cron: '0 2 * * *' # Daily at 02:00 runs only on default branch
push:
paths-ignore:
- '**.md'
- '**.txt'
pull_request:
workflow_dispatch:
env:
fail-fast: true
# All versions should be declared here
PHALCON_VERSION: 6.0.0
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
# For tests
LANG: en_US.UTF-8
LANGUAGE: en_US.UTF-8
LC_ALL: en_US.UTF-8
# Windows specific
TOOLS_DIR: 'C:\tools'
# PHP extensions required by Composer
EXTENSIONS: apcu, gettext, gd, igbinary, imagick, intl, json, mbstring, msgpack, memcached, sqlite3, yaml, redis, phalcon-niden/phalcon-module@master
permissions: { }
jobs:
# PHP CodeSniffer inspection
phpcs:
name: "Validate Tests code style"
if: "!contains(github.event.head_commit.message, 'ci skip')"
permissions:
contents: read
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
php:
- '8.1'
- '8.2'
- '8.3'
# - '8.4'
steps:
- uses: actions/checkout@v4
- 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
tools: pecl
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PHALCON_PATH: ext
- name: "Install development dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
composer-options: "--prefer-dist"
- name: "PHPCS"
run: |
composer cs
- name: "Psalm"
run: |
composer analyze
unit-tests:
needs: phpcs
permissions:
contents: read # to fetch code (actions/checkout)
name: Unit tests / PHP-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}
runs-on: ${{ matrix.os }}
services:
redis:
image: redis:5-alpine
ports:
- "6379:6379"
memcached:
image: memcached:1.5-alpine
ports:
- "11211:11211"
strategy:
fail-fast: true
matrix:
php:
- '8.1'
- '8.2'
- '8.3'
ts:
# - 'nts'
- 'ts'
name:
- ubuntu-gcc
# - macos-clang
# matrix names should be in next format:
# {php}-{ts}-{os.name}-{compiler}-{arch}
include:
# Linux
- { name: ubuntu-gcc, os: ubuntu-20.04, compiler: gcc }
# # macOS
# - { name: macos-clang, os: macos-12, compiler: clang }
# # Windows
# - { php: '8.1', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
# - { php: '8.1', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
steps:
- uses: actions/checkout@v4
- 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 }}
tools: pecl, phpize, php-config, composer:v2
coverage: xdebug
env:
PHPTS: ${{ matrix.ts }}
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PHALCON_PATH: ext
- name: "Validate composer"
run: composer validate --no-check-all --no-check-publish
- name: "Install development dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
composer-options: "--prefer-dist"
- name: "Setup Tests"
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
./config/ci/linux-setup-locales.sh
fi
cp tests/_config/.env.default .env
- name: "Run Unit Tests"
env:
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
if: always()
run: |
./vendor/bin/phpunit tests/unit/ --coverage-php=./tests/support/output/coverage/coverage.xml --display-deprecations
- name: "Upload coverage file artifact"
uses: "actions/upload-artifact@v3"
with:
name: "unit-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}.coverage"
path: "tests/support/output/coverage/coverage.xml"
cli-tests:
name: CLI tests / PHP-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}
needs: phpcs
permissions:
contents: read # to fetch code (actions/checkout)
runs-on: ${{ matrix.os }}
strategy:
matrix:
php:
- '8.1'
# - '8.2'
# - '8.3'
ts:
# - 'nts'
- 'ts'
name:
- ubuntu-gcc
# - macos-clang
# matrix names should be in next format:
# {php}-{ts}-{os.name}-{compiler}-{arch}
include:
# Linux
- { name: ubuntu-gcc, os: ubuntu-20.04, compiler: gcc }
# # macOS
# - { name: macos-clang, os: macos-11, compiler: clang }
# # Windows
# - { php: '8.1', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
# - { php: '8.1', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
steps:
- uses: actions/checkout@v4
- 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 }}
tools: pecl, phpize, php-config, composer:v2
coverage: pcov
env:
PHPTS: ${{ matrix.ts }}
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PHALCON_PATH: ext
- name: "Validate composer"
run: composer validate --no-check-all --no-check-publish
- name: "Install development dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
composer-options: "--prefer-dist"
- name: "Setup Tests"
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
./config/ci/linux-setup-locales.sh
fi
cp tests/_config/.env.default .env
- name: "Run CLI Tests"
if: always()
run: |
./vendor/bin/phpunit tests/cli/ --coverage-php=./tests/support/output/coverage/coverage.xml --display-deprecations
- name: "Upload coverage file artifact"
uses: "actions/upload-artifact@v3"
with:
name: "cli-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}.coverage"
path: "tests/_output/coverage.xml"
integration-tests:
name: "Integration Tests"
needs: phpcs
permissions:
contents: read # to fetch code (actions/checkout)
runs-on: ubuntu-20.04
services:
redis:
image: redis:5-alpine
ports:
- "6379:6379"
memcached:
image: memcached:1.5-alpine
ports:
- "11211:11211"
strategy:
fail-fast: true
matrix:
php:
- '8.1'
# - '8.2'
# - '8.3'
steps:
- uses: actions/checkout@v4
- 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 }}
tools: pecl, phpize, php-config, composer:v2
coverage: pcov
env:
PHPTS: ${{ matrix.ts }}
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PHALCON_PATH: ext
- name: "Validate composer"
run: composer validate --no-check-all --no-check-publish
- name: "Install development dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
composer-options: "--prefer-dist"
- name: "Setup Tests"
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
./config/ci/linux-setup-locales.sh
fi
cp tests/_config/.env.default .env
vendor/bin/codecept build
- 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 --coverage-xml=coverage.xml --ext DotReporter integration
- name: "Upload coverage file artifact"
uses: "actions/upload-artifact@v3"
with:
name: "integration-${{ matrix.php }}.coverage"
path: "tests/_output/coverage.xml"
# db-common-tests:
# name: Database common tests / PHP-${{ matrix.php }}
# needs: phpcs
#
# permissions:
# contents: read # to fetch code (actions/checkout)
#
# runs-on: ubuntu-20.04
#
# strategy:
# fail-fast: true
# matrix:
# php:
# - '8.1'
#
# services:
# mysql:
# image: mysql:5.7
# ports:
# - "3306:3306"
# env:
# MYSQL_ROOT_PASSWORD: secret
# MYSQL_USER: phalcon
# MYSQL_DATABASE: phalcon
# MYSQL_PASSWORD: secret
# postgres:
# image: postgres:12-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:5-alpine
# ports:
# - "6379:6379"
# memcached:
# image: memcached:1.5-alpine
# ports:
# - "11211:11211"
#
# steps:
# - uses: actions/checkout@v4
# - 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=${{ env.SESSION_SAVE_PATH }}
# tools: pecl, phpize, php-config, composer:v2
# coverage: pcov
# env:
# COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# PHALCON_PATH: ext
#
# - name: "Validate composer"
# run: composer validate --no-check-all --no-check-publish
#
# - name: "Install development dependencies with Composer"
# uses: "ramsey/composer-install@v2"
# with:
# composer-options: "--prefer-dist"
#
# - name: "Setup Tests"
# shell: bash
# run: |
# if [ "${{ runner.os }}" = "Linux" ]; then
# ./config/ci/linux-setup-locales.sh
# fi
#
# cp tests/_config/.env.default .env
# vendor/bin/codecept build
#
# - name: "Run Database Tests (Common)"
# env:
# DATA_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
# DATA_MYSQL_USER: root
# 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'] }}
# run: |
# vendor/bin/codecept run --coverage-xml=coverage.xml --ext DotReporter database -g common
#
# - name: "Upload coverage file artifact"
# uses: "actions/upload-artifact@v3"
# with:
# name: "db-common-${{ matrix.php }}.coverage"
# path: "tests/_output/coverage.xml"
#
db-mysql-tests:
name: Database MySQL tests / PHP-${{ matrix.php }}
needs: phpcs
permissions:
contents: read # to fetch code (actions/checkout)
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
php:
- '8.1'
# - '8.2'
# - '8.3'
services:
mysql:
image: mysql:5.7
ports:
- "3306:3306"
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_USER: phalcon
MYSQL_DATABASE: phalcon
MYSQL_PASSWORD: secret
redis:
image: redis:5-alpine
ports:
- "6379:6379"
memcached:
image: memcached:1.5-alpine
ports:
- "11211:11211"
steps:
- uses: actions/checkout@v4
- 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=${{ env.SESSION_SAVE_PATH }}
tools: pecl, phpize, php-config, composer:v2
coverage: pcov
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PHALCON_PATH: ext
- name: "Validate composer"
run: composer validate --no-check-all --no-check-publish
- name: "Install development dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
composer-options: "--prefer-dist"
- name: "Setup Tests"
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
./config/ci/linux-setup-locales.sh
fi
cp tests/_config/.env.default .env
vendor/bin/codecept build
- 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/codecept run --coverage-xml=coverage.xml --ext DotReporter database --env mysql -g mysql
- name: "Upload coverage file artifact"
uses: "actions/upload-artifact@v3"
with:
name: "db-mysql-${{ matrix.php }}.coverage"
path: "tests/_output/coverage.xml"
# db-postgres-tests:
# name: Database PostgreSql tests / PHP-${{ matrix.php }}
# needs: phpcs
#
# permissions:
# contents: read # to fetch code (actions/checkout)
#
# runs-on: ubuntu-20.04
#
# strategy:
# fail-fast: true
# matrix:
# php:
# - '8.1'
#
# services:
# postgres:
# image: postgres:12-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:5-alpine
# ports:
# - "6379:6379"
# memcached:
# image: memcached:1.5-alpine
# ports:
# - "11211:11211"
#
# steps:
# - uses: actions/checkout@v4
# - 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=${{ env.SESSION_SAVE_PATH }}
# tools: pecl, phpize, php-config, composer:v2
# coverage: pcov
# env:
# COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# PHALCON_PATH: ext
#
# - name: "Validate composer"
# run: composer validate --no-check-all --no-check-publish
#
# - name: "Install development dependencies with Composer"
# uses: "ramsey/composer-install@v2"
# with:
# composer-options: "--prefer-dist"
#
# - name: "Setup Tests"
# shell: bash
# run: |
# if [ "${{ runner.os }}" = "Linux" ]; then
# ./config/ci/linux-setup-locales.sh
# fi
#
# cp tests/_config/.env.default .env
# vendor/bin/codecept build
#
# - name: "Run Database Tests (Postgresql)"
# 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'] }}
# run: |
# vendor/bin/codecept run --coverage-xml=coverage.xml --ext DotReporter database --env pgsql -g pgsql
#
# - name: "Upload coverage file artifact"
# uses: "actions/upload-artifact@v3"
# with:
# name: "db-postgres-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}.coverage"
# path: "tests/_output/coverage.xml"
db-sqlite-tests:
name: Database Sqlite tests / PHP-${{ matrix.php }}
needs: phpcs
permissions:
contents: read # to fetch code (actions/checkout)
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
php:
- '8.1'
# - '8.2'
# - '8.3'
steps:
- uses: actions/checkout@v4
- 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=${{ env.SESSION_SAVE_PATH }}
tools: pecl, phpize, php-config, composer:v2
coverage: pcov
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PHALCON_PATH: ext
- name: "Validate composer"
run: composer validate --no-check-all --no-check-publish
- name: "Install development dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
composer-options: "--prefer-dist"
- name: "Setup Tests"
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
./config/ci/linux-setup-locales.sh
fi
cp tests/_config/.env.default .env
vendor/bin/codecept build
- name: "Run Database Tests (Sqlite)"
run: |
vendor/bin/codecept run --coverage-xml=coverage.xml --ext DotReporter database --env sqlite -g sqlite
- name: "Upload coverage file artifact"
uses: "actions/upload-artifact@v3"
with:
name: "db-sqlite-${{ matrix.php }}.coverage"
path: "tests/_output/coverage.xml"
qodana-analysis:
permissions:
contents: read
name: "Qodana Analysis"
runs-on: "ubuntu-22.04"
needs:
- "unit-tests"
- "cli-tests"
- "integration-tests"
# - "db-common-tests"
- "db-mysql-tests"
# - "db-postgres-tests"
- "db-sqlite-tests"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2023.2
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
with:
args: --baseline,qodana.sarif.json
upload-coverage:
permissions:
contents: read
name: "Upload coverage"
runs-on: "ubuntu-22.04"
needs:
- "unit-tests"
- "cli-tests"
- "integration-tests"
# - "db-common-tests"
- "db-mysql-tests"
# - "db-postgres-tests"
- "db-sqlite-tests"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
fetch-depth: 2
- name: "Display structure of downloaded files"
run: |
mkdir -p reports
- name: "Download coverage files"
uses: "actions/download-artifact@v3"
with:
path: "reports"
- name: "Display structure of downloaded files"
run: ls -R
working-directory: reports
- name: "Upload to Codecov"
uses: "codecov/codecov-action@v3"
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: reports
fail_ci_if_error: true
verbose: true
- name: "Upload to Qodana"
run: |
docker run \
-v $(pwd):/data/project/ \
-v ./reports/:/data/coverage \
-e QODANA_TOKEN="${{ secrets.QODANA_TOKEN }}" \
jetbrains/qodana-php