Phalcon CI #193
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 <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 | |
# 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: intl, json, mbstring, msgpack | |
permissions: { } | |
jobs: | |
# PHP CodeSniffer inspection | |
phpcs: | |
name: "Validate Tests code style" | |
if: "!contains(github.event.head_commit.message, 'ci skip')" | |
# needs: [ generate ] | |
permissions: | |
contents: read | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: true | |
matrix: | |
php: | |
- '8.0' | |
- '8.1' | |
- '8.2' | |
steps: | |
- uses: actions/checkout@v3 | |
- 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, composer:v2 | |
env: | |
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Install development dependencies with Composer" | |
uses: "ramsey/composer-install@v2" | |
with: | |
composer-options: "--prefer-dist" | |
- name: "PHPCS" | |
run: | | |
vendor/bin/phpcs --standard=./phpcs.xml | |
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.0' | |
- '8.1' | |
- '8.2' | |
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.0', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' } | |
- { php: '8.0', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' } | |
- { 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@v3 | |
- 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, composer:v2 | |
coverage: pcov | |
env: | |
PHPTS: ${{ matrix.ts }} | |
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- 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: | | |
cp config/.env.example .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 artifact" | |
uses: "actions/upload-artifact@v3" | |
with: | |
name: "unit-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}.coverage" | |
path: "tests/_output/coverage.xml" | |
upload-coverage: | |
permissions: | |
contents: read | |
name: "Upload coverage to Codecov/Codacy" | |
runs-on: "ubuntu-22.04" | |
needs: | |
- "unit-tests" | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v3" | |
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 Codacy" | |
uses: codacy/codacy-coverage-reporter-action@v1 | |
with: | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
coverage-reports: reports/unit-8.0-ts-ubuntu-gcc.coverage/coverage.xml, reports/unit-8.1-ts-ubuntu-gcc.coverage/coverage.xml, reports/unit-8.2-ts-ubuntu-gcc.coverage/coverage.xml |