Phalcon CI #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: | |
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' | |
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 }} | |
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-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 | |
vendor/bin/codecept build | |
- name: "Run Unit Tests" | |
if: always() | |
run: | | |
vendor/bin/codecept run --coverage-xml=coverage.xml --ext DotReporter unit | |
# - name: "Upload coverage file" | |
# run: | | |
# bash <(curl -Ls https://coverage.codacy.com/get.sh) report \ | |
# -l PHP --project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} \ | |
# -r tests/_output/coverage.xml --partial | |
- name: "Upload coverage file artifact" | |
uses: "actions/upload-artifact@v4" | |
with: | |
name: "unit-${{ matrix.php }}.coverage" | |
path: "tests/_output/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 | |
vendor/bin/codecept build | |
- name: "Run CLI Tests" | |
if: always() | |
run: | | |
vendor/bin/codecept run --coverage-xml=coverage.xml --ext DotReporter cli | |
# - name: "Upload coverage file" | |
# run: | | |
# bash <(curl -Ls https://coverage.codacy.com/get.sh) report \ | |
# -l PHP --project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} \ | |
# -r tests/_output/coverage.xml --partial | |
- name: "Upload coverage file artifact" | |
uses: "actions/upload-artifact@v4" | |
with: | |
name: "cli-${{ matrix.php }}.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: Redis Cluster | |
uses: vishnudxb/[email protected] | |
with: | |
redis-node-0-port: 5000 | |
redis-node-1-port: 5001 | |
redis-node-2-port: 5002 | |
redis-node-3-port: 5003 | |
redis-node-4-port: 5004 | |
redis-node-5-port: 5005 | |
sleep-duration: 5 # Define the sleep duration for docker to start and ready for accepting connections (Here we set default to 5seconds) | |
# Running Test | |
- name: Test Redis Cluster | |
run: | | |
sudo apt-get install -y redis-tools | |
docker ps -a | |
redis-cli -h 127.0.0.1 -p 5000 ping | |
redis-cli -h 127.0.0.1 -p 5000 cluster nodes | |
- 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" | |
# run: | | |
# bash <(curl -Ls https://coverage.codacy.com/get.sh) report \ | |
# -l PHP --project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} \ | |
# -r tests/_output/coverage.xml --partial | |
- name: "Upload coverage file artifact" | |
uses: "actions/upload-artifact@v4" | |
with: | |
name: "integration-${{ 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 -g common | |
# - name: "Upload coverage file" | |
# run: | | |
# bash <(curl -Ls https://coverage.codacy.com/get.sh) report \ | |
# -l PHP --project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} \ | |
# -r tests/_output/coverage.xml | |
- name: "Upload coverage file artifact" | |
uses: "actions/upload-artifact@v4" | |
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@v4" | |
# 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@v4" | |
# 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-mysql-tests" | |
# - "db-postgres-tests" | |
# - "db-sqlite-tests" | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v3" | |
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/[email protected] | |
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-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@v4" | |
with: | |
path: "reports" | |
- name: "Display structure of downloaded files" | |
run: ls -R | |
working-directory: reports | |
# - name: "Upload to Codacy" | |
# run: | | |
# bash <(curl -Ls https://coverage.codacy.com/get.sh) report \ | |
# -l php $(find ./reports/ -name '*.xml' | sed 's,^, -r ,' | xargs echo) | |
# - name: "Upload to Codacy" | |
# uses: codacy/[email protected] | |
# with: | |
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
# # or | |
# # api-token: ${{ secrets.CODACY_API_TOKEN }} | |
# coverage-reports: reports | |
# # or a comma-separated list for multiple reports | |
# # coverage-reports: <PATH_TO_REPORT>, <PATH_TO_REPORT> | |
# - 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 |