Skip to content

Ci workfow improve #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .ci/release-notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

# This file is part of the Zephir Parser.
#
# (c) Zephir Team <team@zephir-lang.com>
#
# 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}"
214 changes: 202 additions & 12 deletions .github/workflows/windows.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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
Loading