Skip to content

Zephir Parser CI

Zephir Parser CI #1368

Workflow file for this run

# This file is part of the Zephir Parser.
#
# (c) Zephir Team <[email protected]>
#
# For the full copyright and license information, please view
# the LICENSE file that was distributed with this source code.
name: Zephir Parser CI
on:
schedule:
- cron: '0 2 * * *' # Daily at 02:00 runs only on default branch
push:
paths-ignore:
- '**.md'
- '**.txt'
pull_request:
env:
RE2C_VERSION: 2.2
CONFIGURE_COVERAGE: '' # Configure options for overage is empty by default
jobs:
builds:
name: PHP-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
ts: [ 'ts', 'nts' ]
arch: [ 'x64' ]
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-latest, compiler: gcc, ccov: 'ON' }
# macOS
- { name: macos-clang, os: macos-12, compiler: clang, ccov: 'OFF' }
# Windows
- { php: '7.0', ts: 'nts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14', ccov: 'OFF' }
- { php: '7.0', ts: 'ts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14', ccov: 'OFF' }
- { php: '7.1', ts: 'nts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14', ccov: 'OFF' }
- { php: '7.1', ts: 'ts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14', ccov: 'OFF' }
- { php: '7.2', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '7.2', ts: 'ts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '7.3', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '7.3', ts: 'ts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '7.4', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '7.4', ts: 'ts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '8.0', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.0', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.1', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.1', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.2', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.2', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.3', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.3', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
#- { php: '8.4', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
#- { php: '8.4', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
steps:
- uses: actions/checkout@v4
- name: Install PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
coverage: none
env:
PHPTS: ${{ matrix.ts }}
- name: Setup Build System
shell: bash
run: |
echo "::group::Enable Code Coverage Capture"
if [ "${{ matrix.ccov }}" = "ON" ]; then
echo "CONFIGURE_COVERAGE=--enable-coverage" >> $GITHUB_ENV
fi
echo "::endgroup::"
echo "::group::Setup PHP executable for tests"
if [ "${{ runner.os }}" = "Windows" ]; then
echo "TEST_PHP_EXECUTABLE=C:\tools\php\php.exe" >> $GITHUB_ENV
else
echo "TEST_PHP_EXECUTABLE=$(which php)" >> $GITHUB_ENV
fi
echo "::endgroup::"
- name: Build Zephir Parser Extension (Linux)
uses: ./.github/actions/build-linux
if: runner.os == 'Linux'
- name: Build Zephir Parser Extension (macOS)
uses: ./.github/actions/build-mac
if: runner.os == 'macOS'
- name: Build Zephir Parser Extension (Windows)
uses: ./.github/actions/build-win
if: runner.os == 'Windows'
with:
php_version: ${{ matrix.php }}
ts: ${{ matrix.ts }}
msvc: ${{ matrix.compiler }}
arch: ${{ matrix.arch }}
env:
CACHE_DIR: 'C:\Downloads'
TOOLS_DIR: 'C:\tools'
- name: Run Tests for Zephir Parser
shell: bash
run: |
php --ri zephir_parser
php run-tests.php -q; exit $?
env:
NO_INTERACTION: 1
REPORT_EXIT_STATUS: 1
- name: Collect Build Artifacts
shell: bash
run: |
echo "::group::Creating ZIP with Zephir Parser extension"
if [ "${{ runner.os }}" = "Windows" ]; then
EXTENSION="$(find ./x64 -type f -name 'php_zephir_parser.dll')"
else
EXTENSION="$(find ./modules -type f -name 'zephir_parser.so')"
fi
zip -rvj zephir_parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}.zip \
$EXTENSION VERSION LICENSE CREDITS NO_WARRANTY CHANGELOG.md
echo "::endgroup::"
# Artifact names should be in next format:
# zephir_parser-{php-version}-{ts}-{os.name}-{compiler}-{arch}
# example:
# zephir_parser-php-7.3-nts-macos-clang-x64.zip
# zephir_parser-php-7.3-nts-ubuntu-gcc-x64.zip
# zephir_parser-php-7.3-nts-windows2019-vc15-x64.zip
- name: Upload Zephir Parser
uses: actions/upload-artifact@v4
with:
name: zephir_parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}.zip
path: |
${{ github.workspace }}/zephir_parser-*.zip
- name: Check for Errors
if: always()
shell: pwsh
run: |
Get-ChildItem (Get-Item -Path "./" -Verbose).FullName *.log |
ForEach-Object{
$BaseName = $_.BaseName
Write-Output "::group::-- Log details: ${BaseName}.log --"
Get-Content -Path "${env:GITHUB_WORKSPACE}\${BaseName}.log"
Write-Output "::endgroup::"
}
- name: Capture Coverage Data
if: success() && matrix.ccov == 'ON'
run: make coverage-capture
- name: Upload Code Coverage Report
if: matrix.ccov == 'ON'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./lcov.info
flags: unittests,${{ runner.os }}
- name: Upload Info for Debug on Fail
if: failure()
uses: actions/upload-artifact@v4
with:
retention-days: 2
name: debug-zephir_parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}
path: |
${{ github.workspace }}/tests
${{ github.workspace }}/parser
${{ github.workspace }}/Release*
${{ github.workspace }}/**/Release*
pecl:
name: Build PECL package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: pecl
- 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: Build Zephir Parser
run: |
echo "::group::Run phpize"
phpize
echo "::endgroup::"
echo "::group::Run configure"
./configure \
--enable-zephir-parser \
--enable-zephir-parser-debug
echo "::endgroup::"
echo "::group::Compile"
make -j$(getconf _NPROCESSORS_ONLN)
echo "::endgroup::"
- name: Prepare PECL package config
shell: pwsh
run: |
echo "-- Replacing Release data"
$Config = [xml](Get-Content ./package.xml)
$Config.package.date = $(Get-Date -Format "yyyy-MM-dd")
$Config.package.time = $(Get-Date -Format "HH:mm:ss")
$Config.package.version.Item(1).release = $(Get-Content ./VERSION)
$Config.package.version.Item(1).api = $Config.package.version.release
echo "-- Parsing CHANGELOG"
./.ci/release-notes.sh ./CHANGELOG.md > ./release-notes.md
$Config.package.notes = $(Get-Content ./release-notes.md -Encoding UTF8 -Raw)
$Config.Save('./package.xml')
- name: Create PECL package
run: |
pecl package
zephir_parser_package="`ls | grep zephir_parser-*tgz`"
mv $zephir_parser_package zephir_parser-pecl.tgz
- name: Validate PECL Package
run: |
pecl package-validate zephir_parser-pecl.tgz
pecl info zephir_parser-pecl.tgz
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: 'zephir_parser-pecl'
path: zephir_parser-pecl.tgz
release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [ builds, pecl ]
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get the release version
id: get-version
run: |
echo ::set-output name=version::${GITHUB_REF#refs/tags/}
- name: Download Zephir Parser build artifacts
id: download
uses: actions/download-artifact@v4
with:
path: ./build-artifacts
- name: Prepare Release assets
run: |
mkdir -p ./build-artifacts/release
find ./build-artifacts -type f -name zephir_parser*.zip -exec cp {} ./build-artifacts/release/ ";"
echo "-- Creating Release Notes"
./.ci/release-notes.sh ./CHANGELOG.md > ./build-artifacts/release/release-notes.md
- name: Create Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ steps.get-version.outputs.version }}
tag: ${{ steps.get-version.outputs.version }}
bodyFile: "./build-artifacts/release/release-notes.md"
allowUpdates: true
artifacts: "./build-artifacts/release/*.zip"
artifactContentType: application/octet-stream