diff --git a/.ci/release-notes.sh b/.ci/release-notes.sh new file mode 100755 index 00000000..03492db3 --- /dev/null +++ b/.ci/release-notes.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# This file is part of the Zephir Parser. +# +# (c) Zephir Team +# +# For the full copyright and license information, please view +# the LICENSE file that was distributed with this source code. + + +# -e Exit immediately if a command exits with a non-zero status. +# -u Treat unset variables as an error when substituting. + +set -eu +set -o pipefail + +# Get Release notes for the latest release from CHANGELOG.md +# How to use: +# release-notes.sh CHANGELOG.md + +startline=$(cat "$1" | grep -nE '^### ' | head -n 1 | cut -d ":" -f 1) +finishline=$(($(cat "$1" | grep -nE '^## \[[0-9]+' | head -n 2 | tail -n 1 | cut -d ":" -f 1) - 1)) +changelog=$(sed -n "${startline},${finishline}p" "$1"); + + +: "${GITHUB_ACTIONS:=0}" + +if [ "$GITHUB_ACTIONS" = "true" ] +then + changelog="${changelog//'%'/'%25'}" + changelog="${changelog//$'\n'/'%0A'}" + changelog="${changelog//$'\r'/'%0D'}" +fi + +echo "${changelog}" diff --git a/.github/workflows/windows.yml b/.github/workflows/ci.yml similarity index 52% rename from .github/workflows/windows.yml rename to .github/workflows/ci.yml index 97a6e8ed..16570bc0 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/ci.yml @@ -1,28 +1,34 @@ -name: Windows +name: Zephir Parser CI on: + schedule: + - cron: '0 2 * * *' # Daily at 02:00 runs only on default branch push: branches-ignore: - 'wip-*' paths-ignore: - '*.md' - -# pull_request: -# branches: -# - master -# - development - -# schedule: -# - cron: '0 11 * * *' + pull_request: + paths-ignore: + - '*.md' + branches: + - master + - development env: + RE2C_VERSION: 2.2 PHP_SDK_VERSION: 2.2.0 PHP_DEVPACK: C:\tools\php-devpack PHP_SDK_PATH: C:\tools\php-sdk EXTENSION_FILE: php_zephir_parser.dll jobs: - ci: + windows-builds: + # To prevent build a particular commit use + # git commit -m "......... [win skip] - skip Windows builds only" + # git commit -m "......... [ci skip] - skip all builds" + if: "!contains(github.event.head_commit.message, '[win skip]') || !contains(github.event.head_commit.message, '[ci skip]') " + strategy: fail-fast: false @@ -186,7 +192,7 @@ jobs: - name: Upload Zephir Parser uses: actions/upload-artifact@v2 with: - name: zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }} + name: zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}.zip path: | ${{ github.workspace }}\zephir-parser-*.zip @@ -200,7 +206,7 @@ jobs: Get-Content -Path "${env:GITHUB_WORKSPACE}\${BaseName}.log" } - - name: Upload Infor for Debug on Fail + - name: Upload Info for Debug on Fail if: failure() uses: actions/upload-artifact@v2 with: @@ -211,3 +217,187 @@ jobs: ${{ github.workspace }}\parser ${{ github.workspace }}\Release* ${{ github.workspace }}\**\Release* + + unix-builds: + # To prevent build a particular commit use + # git commit -m "......... [unix skip] - skip Linux & macOS builds only" + # git commit -m "......... [ci skip] - skip all builds" + if: "!contains(github.event.head_commit.message, '[unix skip]') || !contains(github.event.head_commit.message, '[ci skip]') " + + strategy: + fail-fast: false + + matrix: + php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + arch: ['x64'] + build_type: ['nts'] + name: + - ubuntu + - macos + + include: + - name: ubuntu + os: ubuntu-18.04 + ccov: ON + compiler: gcc + + - name: macos + os: macos-latest + ccov: OFF + compiler: clang + + name: "PHP-${{ matrix.php }}-${{ matrix.build_type }}-${{ matrix.name }}-${{ matrix.compiler }}-${{ matrix.arch }}" + runs-on: ${{ matrix.os }} + + env: + HOMEBREW_NO_INSTALL_CLEANUP: 1 + ZEND_DONT_UNLOAD_MODULES: 1 + USE_ZEND_ALLOC: 0 + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 5 + + - name: Install PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php }}' + coverage: none + env: + PHPTS: ${{ matrix.build_type }} + + - name: Cache RE2C Downloads + uses: actions/cache@v2 + with: + path: ~/.cache/re2c + key: ${{ runner.os }}-php-${{ matrix.php }}-re2c-${{env.RE2C_VERSION}} + + - name: Setup Prerequisites (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update --quiet --yes 1>/dev/null + sudo apt-get install --no-install-recommends --quiet --yes lcov gdb + + - name: Setup Prerequisites (macOS) + if: runner.os == 'macOS' && matrix.ccov == 'ON' + run: | + brew install lcov + sudo xcode-select -switch /Applications/Xcode.app + + - name: Setup Build System (Generic) + run: | + ulimit -c unlimited -S || true + + mkdir -p $HOME/.cache/re2c + mkdir -p $HOME/.local/opt/re2c + + echo "PATH=$PATH:$HOME/bin:$(brew --prefix lcov)/bin" >> $GITHUB_ENV + echo "MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN)" >> $GITHUB_ENV + echo "CI=true" >> $GITHUB_ENV + echo "ZEPHIR_PARSER_VERSION=$(head -1 VERSION)" >> $GITHUB_ENV + + - name: Setup Core Dump (Linux) + if: runner.os == 'Linux' + run: echo '/tmp/core.%e.%p.%t' | sudo tee /proc/sys/kernel/core_pattern + + - name: Install re2c + run: .ci/install-re2c.sh + + - name: Build extensions + run: | + phpize + + if [ "${{ matrix.ccov }}" = "ON" ]; then + ./configure \ + --enable-zephir-parser \ + --enable-zephir-parser-debug \ + --enable-coverage + else + ./configure \ + --enable-zephir-parser \ + --enable-zephir-parser-debug + fi + + make -j$(getconf _NPROCESSORS_ONLN) + + - name: Preparing to collect coverage data + if: matrix.ccov == 'ON' + run: make coverage-initial + + - name: Run Tests + run: | + php -d extension=./modules/zephir_parser.so --ri 'Zephir Parser' + make test NO_INTERACTION=1 REPORT_EXIT_STATUS=1 + + - name: Print failures + if: failure() && runner.os == 'Linux' + run: .ci/after-failure.sh + + - name: Capture coverage data + if: success() && matrix.ccov == 'ON' + run: make coverage-capture + + - name: Prepare Build Artifacts + working-directory: modules + run: | + echo "-- Creating ZIP with Zephir Parser extension" + zip -rv zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-${{ matrix.name }}-${{ matrix.compiler }}-${{ matrix.arch }}.zip ./*.so + + - name: Upload code coverage report + if: matrix.ccov == 'ON' + uses: codecov/codecov-action@v1 + with: + token: ${{secrets.CODECOV_TOKEN}} + file: ./lcov.info + flags: unittests + fail_ci_if_error: false + + - name: Upload Zephir Parser + uses: actions/upload-artifact@v2 + with: + name: zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-${{ matrix.name }}-${{ matrix.compiler }}-${{ matrix.arch }}.zip + path: | + ${{ github.workspace }}/modules/*.zip + + release: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + + needs: [windows-builds, unix-builds] + name: Create Release + runs-on: ubuntu-20.04 + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + 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@v2 + 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" + GITHUB_ACTIONS=false ./.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 diff --git a/.github/workflows/linux-macos.yml b/.github/workflows/linux-macos.yml deleted file mode 100644 index 5f223ec0..00000000 --- a/.github/workflows/linux-macos.yml +++ /dev/null @@ -1,135 +0,0 @@ -name: Linux and MacOS - -on: - push: - branches-ignore: - - 'wip-*' - paths-ignore: - - '*.md' - pull_request: - branches: - - master - - development - schedule: - - cron: '0 11 * * *' - -jobs: - ci: - strategy: - fail-fast: false - - matrix: - re2c: - - '0.13.6' - - '1.3' - php: - - '7.0' - - '7.1' - - '7.2' - - '7.3' - - '7.4' - - '8.0' - name: - - Ubuntu - - macOS - - include: - - name: Ubuntu - os: ubuntu-18.04 - ccov: ON - - - name: macOS - os: macos-latest - ccov: OFF - - name: "${{ matrix.name }}: PHP ${{ matrix.php }}, re2c ${{ matrix.re2c }}" - runs-on: ${{ matrix.os }} - - env: - ZEND_DONT_UNLOAD_MODULES: 1 - USE_ZEND_ALLOC: 0 - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 5 - - - name: Install PHP ${{ matrix.php }} - uses: shivammathur/setup-php@v2 - with: - php-version: '${{ matrix.php }}' - coverage: none - - - name: Setup Prerequisites (Linux) - if: runner.os == 'Linux' - run: | - sudo apt-get update --quiet --yes 1>/dev/null - sudo apt-get install --no-install-recommends --quiet --yes lcov gdb - - - name: Setup Prerequisites (macOS) - if: runner.os == 'macOS' && matrix.ccov == 'ON' - run: | - brew install lcov - sudo xcode-select -switch /Applications/Xcode.app - - - name: Setup Build System (Generic) - if: runner.os != 'Windows' - run: | - ulimit -c unlimited -S || true - - mkdir -p $HOME/.cache/re2c - mkdir -p $HOME/.local/opt/re2c - - echo "RE2C_VERSION=${{ matrix.re2c }}" >> $GITHUB_ENV - echo "PATH=$PATH:$HOME/bin:$(brew --prefix lcov)/bin" >> $GITHUB_ENV - echo "MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN)" >> $GITHUB_ENV - echo "CI=true" >> $GITHUB_ENV - - - name: Setup Core Dump (Linux) - if: runner.os == 'Linux' - run: echo '/tmp/core.%e.%p.%t' | sudo tee /proc/sys/kernel/core_pattern - - - name: Install re2c ${{ matrix.re2c }} - run: .ci/install-re2c.sh - - - name: Build extensions - run: | - phpize - - if [ "${{ matrix.ccov }}" = "ON" ]; then - ./configure \ - --enable-zephir-parser \ - --enable-zephir-parser-debug \ - --enable-coverage - else - ./configure \ - --enable-zephir-parser \ - --enable-zephir-parser-debug - fi - - make -j$(getconf _NPROCESSORS_ONLN) - - - name: Preparing to collect coverage data - if: matrix.ccov == 'ON' - run: make coverage-initial - - - name: Run Tests - if: runner.os != 'Windows' - run: make test NO_INTERACTION=1 REPORT_EXIT_STATUS=1 - - - name: Print failures - if: failure() && runner.os == 'Linux' - run: .ci/after-failure.sh - - - 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@v1 - with: - token: ${{secrets.CODECOV_TOKEN}} - file: ./lcov.info - flags: unittests - fail_ci_if_error: false diff --git a/README.md b/README.md index a12c44b3..019296c0 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # Zephir Parser [![Actions Status][actions badge]][actions link] -[![Build on Windows][:badge-appveyor:]][:build-appveyor:] [![Coverage Status][:badge-codecov:]][:build-codecov:] [![License][:badge-license:]][:ext-license:] +[![Discord][:badge-discord:]][discord link] The Zephir Parser delivered as a C extension for the PHP language. -Supported PHP versions: **7.0**, **7.1**, **7.2**, **7.3**, **7.4** and **8.0** +Supported PHP versions: **7.0**, **7.1**, **7.2**, **7.3**, **7.4** and **8.0** **NOTE:** The [`development`][:dev-branch:] branch will always contain the latest **unstable** version. If you wish to @@ -145,12 +145,12 @@ Zephir Parser is open source software licensed under the MIT License (MIT). See the [LICENSE][:ext-license:] file for more information. [actions link]: https://github.com/phalcon/php-zephir-parser/actions -[actions badge]: https://github.com/phalcon/php-zephir-parser/workflows/build/badge.svg +[actions badge]: https://github.com/zephir-lang/php-zephir-parser/actions/workflows/ci.yml/badge.svg -[:badge-appveyor:]: https://ci.appveyor.com/api/projects/status/r4k8baw1iy54v2wt/branch/development?svg=true +[discord link]: http://phalcon.io/discord +[:badge-discord:]: https://img.shields.io/discord/310910488152375297?label=Discord&logo=discord [:badge-codecov:]: https://codecov.io/gh/phalcon/php-zephir-parser/branch/development/graph/badge.svg [:badge-license:]: https://img.shields.io/badge/license-MIT-brightgreen.svg -[:build-appveyor:]: https://ci.appveyor.com/project/sergeyklay/php-zephir-parser/branch/master [:build-codecov:]: https://codecov.io/gh/phalcon/php-zephir-parser [:ext-license:]: https://github.com/phalcon/php-zephir-parser/blob/master/LICENSE [:latest-release:]: https://github.com/phalcon/php-zephir-parser/releases/latest