Phalcon CI #65
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@v3" | |
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) | |
services: | |
redis: | |
image: redis:5-alpine | |
ports: | |
- "6379:6379" | |
memcached: | |
image: memcached:1.5-alpine | |
ports: | |
- "11211:11211" | |
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@v3" | |
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" | |
if: always() | |
run: | | |
composer test-unit-coverage | |
- name: "Upload coverage file artifact" | |
uses: "actions/upload-artifact@v4" | |
with: | |
name: "unit-${{ 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@v3" | |
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 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: | | |
composer test-db-mysql-coverage | |
- 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" | |
# | |
upload-coverage: | |
permissions: | |
contents: read | |
name: "Upload coverage" | |
runs-on: "ubuntu-22.04" | |
needs: | |
- "unit-tests" | |
- "db-mysql-tests" | |
# - "db-postgres-tests" | |
# - "db-sqlite-tests" | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v4" | |
with: | |
fetch-depth: 0 | |
- name: "Display structure of downloaded files" | |
run: | | |
mkdir -p coverage | |
- name: "Download coverage files" | |
uses: "actions/download-artifact@v4" | |
with: | |
path: "coverage" | |
- name: "Display structure of downloaded files" | |
run: | | |
mv coverage/db-mysql-8.1.coverage/coverage.xml coverage/db-mysql-8.1-coverage.xml | |
mv coverage/unit-8.1.coverage/coverage.xml coverage/unit-8.1-coverage.xml | |
mv coverage/unit-8.2.coverage/coverage.xml coverage/unit-8.2-coverage.xml | |
mv coverage/unit-8.3.coverage/coverage.xml coverage/unit-8.3-coverage.xml | |
ls -la coverage/ | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
## - 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 |