From 2b11960988cb7bf4f662b5e99b57c44181fbba3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Djupsj=C3=B6backa?= Date: Mon, 18 Dec 2023 13:51:21 +0200 Subject: [PATCH 1/5] Test with PHP 8.4 (nightly) on Linux, 8.3 on Windows, unify naming and formatting in workflow files --- .github/workflows/build.yml | 101 +++++++++---------- .github/workflows/clang_format_lint.yml | 10 +- .github/workflows/code_coverage.yml | 124 ++++++++++++------------ .github/workflows/windows.yml | 41 +++++--- 4 files changed, 146 insertions(+), 130 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a89f0bf..37789e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 \ No newline at end of file + tests: + runs-on: ubuntu-latest + name: Build and test + strategy: + fail-fast: false + matrix: + php: [ 8.0, 8.1, 8.2, 8.3, 8.4 ] + 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 diff --git a/.github/workflows/clang_format_lint.yml b/.github/workflows/clang_format_lint.yml index 535647c..b174d6c 100644 --- a/.github/workflows/clang_format_lint.yml +++ b/.github/workflows/clang_format_lint.yml @@ -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' diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml index 7f6f020..5f0726d 100644 --- a/.github/workflows/code_coverage.yml +++ b/.github/workflows/code_coverage.yml @@ -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 \ No newline at end of file + - 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 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index fc7e653..aa62ce4 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,36 +1,47 @@ -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 - run: phpize - - name: configure - run: configure --enable-jsonpath --with-prefix=${{steps.setup-php.outputs.prefix}} - - name: make - run: nmake - - name: test + + - name: Compile jsonpath + run: | + phpize \ + && configure --enable-jsonpath --with-prefix=${{steps.setup-php.outputs.prefix}} \ + && nmake + + - name: Run jsonpath tests run: nmake test TESTS="-j2 --show-diff -g FAIL,BORK,WARN,LEAK tests" From 06c141f94880ade0d5c1390b4cadaee356e3c313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Djupsj=C3=B6backa?= Date: Mon, 18 Dec 2023 13:56:38 +0200 Subject: [PATCH 2/5] Define matrix arguments as strings to avoid version number issues --- .github/workflows/build.yml | 4 ++-- .github/workflows/windows.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 37789e1..dc906ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,8 +14,8 @@ jobs: strategy: fail-fast: false matrix: - php: [ 8.0, 8.1, 8.2, 8.3, 8.4 ] - use-opcache: [ true, false ] + php: [ "8.0", "8.1", "8.2", "8.3", "8.4" ] + use-opcache: [ "true", "false" ] steps: - name: Checkout jsonpath diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index aa62ce4..356793d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -16,9 +16,9 @@ jobs: shell: cmd strategy: matrix: - version: [ 8.0, 8.1, 8.2, 8.3 ] - arch: [ x64 ] - ts: [ ts ] + version: [ "8.0", "8.1", "8.2", "8.3" ] + arch: [ "x64" ] + ts: [ "ts" ] steps: - name: Checkout jsonpath uses: actions/checkout@v2 From 1cd1005bad7af560e20130fe9e2bddf439c2d28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Djupsj=C3=B6backa?= Date: Mon, 18 Dec 2023 14:01:52 +0200 Subject: [PATCH 3/5] Define matrix arguments as strings to avoid version number issues --- .github/workflows/code_coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml index 5f0726d..e81dc0f 100644 --- a/.github/workflows/code_coverage.yml +++ b/.github/workflows/code_coverage.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ 8.3 ] + php: [ "8.3" ] steps: - uses: actions/checkout@v2 From 9b28bada8a80c9e4d8ffb803c8a3b675d94d3e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Djupsj=C3=B6backa?= Date: Mon, 18 Dec 2023 14:02:23 +0200 Subject: [PATCH 4/5] Run each command separately on Windows, since chaining them doesn't seem to work --- .github/workflows/windows.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 356793d..0ecb6c5 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -37,11 +37,14 @@ jobs: arch: ${{matrix.arch}} toolset: ${{steps.setup-php.outputs.toolset}} + - name: Run phpize for jsonpath + run: phpize + + - name: Run configure for jsonpath + run: configure --enable-jsonpath --with-prefix=${{steps.setup-php.outputs.prefix}} + - name: Compile jsonpath - run: | - phpize \ - && configure --enable-jsonpath --with-prefix=${{steps.setup-php.outputs.prefix}} \ - && nmake + run: nmake - name: Run jsonpath tests run: nmake test TESTS="-j2 --show-diff -g FAIL,BORK,WARN,LEAK tests" From 62fae1cf25d409632bf8b15f79373503bf344833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Djupsj=C3=B6backa?= Date: Mon, 18 Dec 2023 14:03:13 +0200 Subject: [PATCH 5/5] Don't build for PHP 8.4 on Linux, since php_pcre_match_impl() isn't compatible --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc906ce..4cddd54 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ "8.0", "8.1", "8.2", "8.3", "8.4" ] + php: [ "8.0", "8.1", "8.2", "8.3" ] use-opcache: [ "true", "false" ] steps: