Skip to content

Commit

Permalink
Merge pull request #173 from supermetrics-public/chore/TestVersions
Browse files Browse the repository at this point in the history
Test with PHP 8.3 on Windows, unify naming and formatting in workflow files
  • Loading branch information
crocodele authored Dec 18, 2023
2 parents daba02b + 62fae1c commit 92ac471
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 127 deletions.
101 changes: 51 additions & 50 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
name: Build
name: Build and test on Linux

on:
push:
branches: [main]
pull_request:
release:
types: [created]
push:
branches: [ main ]
pull_request:
release:
types: [ created ]

jobs:
tests:
runs-on: ubuntu-latest
name: Build and test
strategy:
fail-fast: false
matrix:
php: [8.0, 8.1, 8.2, 8.3]
use-opcache: [true, false]

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
coverage: none
tools: pecl

- name: Compile
run: ./.build-scripts/compile.sh

- name: Find PHP
run: |
TEST_PHP_EXECUTABLE=`make findphp`
echo "Found PHP in: $TEST_PHP_EXECUTABLE"
echo "TEST_PHP_EXECUTABLE=$TEST_PHP_EXECUTABLE" >> $GITHUB_ENV
- name: Define PHP arguments
run: |
TEST_PHP_ARGS="-n"
[[ "${{ matrix.use-opcache }}" != "true" ]] || TEST_PHP_ARGS="$TEST_PHP_ARGS -d zend_extension=opcache.so -d opcache.enable=1 -d opcache.enable_cli=1"
TEST_PHP_ARGS="$TEST_PHP_ARGS -d extension=$PWD/modules/jsonpath.so"
echo "Test PHP arguments: $TEST_PHP_ARGS"
echo "TEST_PHP_ARGS=$TEST_PHP_ARGS" >> $GITHUB_ENV
- name: Run tests
run: |
$TEST_PHP_EXECUTABLE $TEST_PHP_ARGS -v
$TEST_PHP_EXECUTABLE -n run-tests.php -q -x --show-diff
- name: Show errors
if: ${{ failure() }}
run: ./.build-scripts/show-errors.sh
tests:
runs-on: ubuntu-latest
name: Build and test
strategy:
fail-fast: false
matrix:
php: [ "8.0", "8.1", "8.2", "8.3" ]
use-opcache: [ "true", "false" ]

steps:
- name: Checkout jsonpath
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
coverage: none
tools: pecl

- name: Compile jsonpath
run: ./.build-scripts/compile.sh

- name: Find PHP
run: |
TEST_PHP_EXECUTABLE=`make findphp`
echo "Found PHP in: $TEST_PHP_EXECUTABLE"
echo "TEST_PHP_EXECUTABLE=$TEST_PHP_EXECUTABLE" >> $GITHUB_ENV
- name: Define PHP arguments
run: |
TEST_PHP_ARGS="-n"
[[ "${{ matrix.use-opcache }}" != "true" ]] || TEST_PHP_ARGS="$TEST_PHP_ARGS -d zend_extension=opcache.so -d opcache.enable=1 -d opcache.enable_cli=1"
TEST_PHP_ARGS="$TEST_PHP_ARGS -d extension=$PWD/modules/jsonpath.so"
echo "Test PHP arguments: $TEST_PHP_ARGS"
echo "TEST_PHP_ARGS=$TEST_PHP_ARGS" >> $GITHUB_ENV
- name: Run jsonpath tests
run: |
$TEST_PHP_EXECUTABLE $TEST_PHP_ARGS -v
$TEST_PHP_EXECUTABLE -n run-tests.php -q -x --show-diff
- name: Show errors
if: ${{ failure() }}
run: ./.build-scripts/show-errors.sh
10 changes: 7 additions & 3 deletions .github/workflows/clang_format_lint.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: Run lint check with clang-format

on: [push]
on:
push:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.12
- name: Checkout jsonpath
uses: actions/checkout@v2

- name: Perform linting
uses: DoozyX/clang-format-lint-action@v0.12
with:
source: './jsonpath.c ./php_jsonpath.h ./src/jsonpath'
extensions: 'c,h'
Expand Down
124 changes: 62 additions & 62 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
name: Calculate code coverage

on:
push:
branches: [main]
push:
branches: [ main ]

jobs:
tests:
runs-on: ubuntu-latest
name: Build, run tests with code coverage, create badge
strategy:
fail-fast: false
matrix:
php: [8.0]
tests:
runs-on: ubuntu-latest
name: Build, run tests with code coverage, create badge
strategy:
fail-fast: false
matrix:
php: [ "8.3" ]

steps:
- uses: actions/checkout@v2
steps:
- uses: actions/checkout@v2

- name: Get branch name (merge)
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
- name: Get branch name (merge)
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV

- name: Get branch name (pull request)
if: github.event_name == 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
- name: Get branch name (pull request)
if: github.event_name == 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV

- name: Install lcov
run: sudo apt-get -y install lcov
- name: Install lcov
run: sudo apt-get -y install lcov

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
coverage: none
tools: pecl
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
coverage: none
tools: pecl

- name: Compile with code coverage support
run: ./.build-scripts/compile-coverage.sh
- name: Compile with code coverage support
run: ./.build-scripts/compile-coverage.sh

- name: Find PHP
run: |
TEST_PHP_EXECUTABLE=`make findphp`
echo "Found PHP in: $TEST_PHP_EXECUTABLE"
echo "TEST_PHP_EXECUTABLE=$TEST_PHP_EXECUTABLE" >> $GITHUB_ENV
- name: Define PHP arguments
run: |
TEST_PHP_ARGS="-n"
TEST_PHP_ARGS="$TEST_PHP_ARGS -d extension=$PWD/modules/jsonpath.so"
echo "Test PHP arguments: $TEST_PHP_ARGS"
echo "TEST_PHP_ARGS=$TEST_PHP_ARGS" >> $GITHUB_ENV
- name: Run tests
run: |
$TEST_PHP_EXECUTABLE $TEST_PHP_ARGS -v
$TEST_PHP_EXECUTABLE -n run-tests.php -q -x --show-diff
- name: Find PHP
run: |
TEST_PHP_EXECUTABLE=`make findphp`
echo "Found PHP in: $TEST_PHP_EXECUTABLE"
echo "TEST_PHP_EXECUTABLE=$TEST_PHP_EXECUTABLE" >> $GITHUB_ENV
- name: Generate code coverage report
run: |
COVERAGE=$(make lcov-summary |& grep 'lines...' | grep -Eo ' [0-9.]+' | xargs | awk '{print $1}' | xargs printf "%.*f\n" 0)
COVERAGE="${COVERAGE}%"
echo "Code coverage (lines): $COVERAGE"
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
- name: Create the badge
uses: schneegans/dynamic-badges-action@v1.0.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 5ceb08845fe95635fc41af2f4c86c631
filename: pecl-jsonpath__${{ env.BRANCH_NAME }}.json
label: Coverage
message: ${{ env.COVERAGE }}
color: green
- name: Define PHP arguments
run: |
TEST_PHP_ARGS="-n"
TEST_PHP_ARGS="$TEST_PHP_ARGS -d extension=$PWD/modules/jsonpath.so"
echo "Test PHP arguments: $TEST_PHP_ARGS"
echo "TEST_PHP_ARGS=$TEST_PHP_ARGS" >> $GITHUB_ENV
- name: Run tests
run: |
$TEST_PHP_EXECUTABLE $TEST_PHP_ARGS -v
$TEST_PHP_EXECUTABLE -n run-tests.php -q -x --show-diff
- name: Generate code coverage report
run: |
COVERAGE=$(make lcov-summary |& grep 'lines...' | grep -Eo ' [0-9.]+' | xargs | awk '{print $1}' | xargs printf "%.*f\n" 0)
COVERAGE="${COVERAGE}%"
echo "Code coverage (lines): $COVERAGE"
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
- name: Create the badge
uses: schneegans/dynamic-badges-action@v1.0.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 5ceb08845fe95635fc41af2f4c86c631
filename: pecl-jsonpath__${{ env.BRANCH_NAME }}.json
label: Coverage
message: ${{ env.COVERAGE }}
color: green
38 changes: 26 additions & 12 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,50 @@
name: Build and Test
on: [push, pull_request]
name: Build and test on Windows

on:
push:
branches: [ main ]
pull_request:
release:
types: [ created ]

jobs:
build:
tests:
runs-on: windows-2019
name: Build and test
defaults:
run:
shell: cmd
strategy:
matrix:
version: ['8.0', '8.1', '8.2']
arch: [x64]
ts: [ts]
runs-on: windows-2019
version: [ "8.0", "8.1", "8.2", "8.3" ]
arch: [ "x64" ]
ts: [ "ts" ]
steps:
- name: Checkout jsonpath
uses: actions/checkout@v2

- name: Setup PHP
id: setup-php
uses: cmb69/setup-php-sdk@v0.6
uses: php/setup-php-sdk@v0.8
with:
version: ${{matrix.version}}
arch: ${{matrix.arch}}
ts: ${{matrix.ts}}

- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{matrix.arch}}
toolset: ${{steps.setup-php.outputs.toolset}}
- name: phpize

- name: Run phpize for jsonpath
run: phpize
- name: configure

- name: Run configure for jsonpath
run: configure --enable-jsonpath --with-prefix=${{steps.setup-php.outputs.prefix}}
- name: make

- name: Compile jsonpath
run: nmake
- name: test

- name: Run jsonpath tests
run: nmake test TESTS="-j2 --show-diff -g FAIL,BORK,WARN,LEAK tests"

0 comments on commit 92ac471

Please sign in to comment.