From 2da37c239c55499eb20b6c34afc8499e0f7758ed Mon Sep 17 00:00:00 2001 From: John Boehr Date: Sat, 28 Sep 2024 14:27:16 -0700 Subject: [PATCH] Modernize CI configuration, add PHP 8.4 --- .github/workflows/ci.yml | 44 ++-- LICENSE.md | 11 +- config.m4 | 8 + flake.lock | 419 +++++++++++++++++++++++---------------- flake.nix | 71 ++++--- nix/derivation.nix | 76 +++++-- src/php_handlebars.c | 8 + 7 files changed, 404 insertions(+), 233 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7413273..5442b7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,7 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4" COVERAGE: ["true", "false"] steps: - uses: actions/checkout@v3 @@ -37,23 +38,24 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: ./coverage.info - osx: - runs-on: macos-latest - strategy: - fail-fast: false - matrix: - PHP_VERSION: - - "8.1" - - "8.2" - - "8.3" - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I'm putting everything in a FSCKING BASH SCRIPT - env: - PHP_VERSION: ${{ matrix.PHP_VERSION }} - run: bash ./.github/scripts/osx.sh + # broken and don't care apple is trash + # osx: + # runs-on: macos-latest + # strategy: + # fail-fast: false + # matrix: + # PHP_VERSION: + # # - "8.1" + # # - "8.2" + # - "8.3" + # steps: + # - uses: actions/checkout@v3 + # with: + # submodules: recursive + # - name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I'm putting everything in a FSCKING BASH SCRIPT + # env: + # PHP_VERSION: ${{ matrix.PHP_VERSION }} + # run: bash ./.github/scripts/osx.sh docker-debian: runs-on: ubuntu-latest @@ -64,6 +66,7 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4.0RC1" steps: - uses: actions/checkout@v3 with: @@ -83,6 +86,7 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4.0RC1" steps: - uses: actions/checkout@v3 with: @@ -139,9 +143,9 @@ jobs: nix-store.nar-${{ runner.os }}-${{ hashFiles('flake.lock') }}- nix-store.nar-${{ runner.os }}- - - uses: cachix/install-nix-action@v26 + - uses: cachix/install-nix-action@v27 with: - nix_path: nixpkgs=channel:nixos-23.11 + nix_path: nixpkgs=channel:nixos-24.05 extra_nix_config: "system-features = nixos-test benchmark big-parallel kvm" - name: Import Nix Store Cache @@ -149,8 +153,6 @@ jobs: run: | nix-store --import < /tmp/nix-store.nar - - run: sudo sysctl -w kernel.perf_event_paranoid=1 - - run: nix build -L ".#${{ matrix.attr }}" - name: Export Nix Store Cache diff --git a/LICENSE.md b/LICENSE.md index 8aaceb4..4774b2d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,17 +1,17 @@ BSD 2-Clause License ==================== -_Copyright © `2016`, `John Boehr`_ +_Copyright © anno Domini nostri Jesu Christi MMXVI-MMXXIV John Boehr & contributors_ _All rights reserved._ Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. + list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. + and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -25,6 +25,5 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those -of the authors and should not be interpreted as representing official policies, +of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. - diff --git a/config.m4 b/config.m4 index 1cfa4cb..e35cb89 100644 --- a/config.m4 +++ b/config.m4 @@ -28,6 +28,9 @@ PHP_ARG_ENABLE(handlebars-psr, whether to enable handlebars PSR support, PHP_ARG_ENABLE(handlebars-hardening, whether to enable handlebars hardening support, [ --enable-handlebars-hardening Enable handlebars hardening support], [yes], [no]) +PHP_ARG_ENABLE(handlebars-coverage, whether to enable handlebars coverage support, +[AS_HELP_STRING([--enable-handlebars-coverage], [Enable handlebars coverage support])], [no], [no]) + AC_DEFUN([PHP_HANDLEBARS_ADD_SOURCES], [ PHP_HANDLEBARS_SOURCES="$PHP_HANDLEBARS_SOURCES $1" ]) @@ -147,6 +150,11 @@ if test "$PHP_HANDLEBARS" != "no"; then ]) fi + if test "$PHP_HANDLEBARS_COVERAGE" == "yes"; then + CFLAGS="-fprofile-arcs -ftest-coverage $CFLAGS" + LDFLAGS="--coverage $LDFLAGS" + fi + PHP_ADD_BUILD_DIR(src) PHP_INSTALL_HEADERS([ext/handlebars], [php_handlebars.h]) PHP_NEW_EXTENSION(handlebars, $PHP_HANDLEBARS_SOURCES, $ext_shared, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) diff --git a/flake.lock b/flake.lock index 8d80af6..d3973b1 100644 --- a/flake.lock +++ b/flake.lock @@ -1,22 +1,22 @@ { "nodes": { - "composer2nix": { + "flake-compat": { "flake": false, "locked": { - "lastModified": 1646178110, - "narHash": "sha256-P3acfGwHYjjZQcviPiOT7T7qzzP/drc2mibzrsrNP18=", - "owner": "svanderburg", - "repo": "composer2nix", - "rev": "299caca4aac42d7639a42eb4dde951c010f6e91c", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { - "owner": "svanderburg", - "repo": "composer2nix", + "owner": "edolstra", + "repo": "flake-compat", "type": "github" } }, - "flake-compat": { + "flake-compat_2": { "flake": false, "locked": { "lastModified": 1696426674, @@ -32,7 +32,23 @@ "type": "github" } }, - "flake-compat_2": { + "flake-compat_3": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_4": { "flake": false, "locked": { "lastModified": 1696426674, @@ -55,11 +71,11 @@ ] }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -76,11 +92,11 @@ ] }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -91,14 +107,17 @@ }, "flake-utils_3": { "inputs": { - "systems": "systems" + "systems": [ + "handlebars_spec", + "systems" + ] }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -108,60 +127,18 @@ } }, "flake-utils_4": { - "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_5": { - "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_6": { - "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_7": { "inputs": { - "systems": "systems_3" + "systems": [ + "php-psr", + "systems" + ] }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -214,8 +191,7 @@ "gitignore_3": { "inputs": { "nixpkgs": [ - "handlebars-c", - "pre-commit-hooks", + "handlebars_spec", "nixpkgs" ] }, @@ -240,27 +216,6 @@ "nixpkgs" ] }, - "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "gitignore_5": { - "inputs": { - "nixpkgs": [ - "pre-commit-hooks", - "nixpkgs" - ] - }, "locked": { "lastModified": 1709087332, "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", @@ -279,25 +234,21 @@ "inputs": { "flake-utils": "flake-utils_2", "gitignore": "gitignore_2", - "handlebars_spec": [ - "handlebars_spec" - ], - "mustache_spec": [ - "mustache_spec" - ], + "handlebars_spec": "handlebars_spec", + "mustache_spec": "mustache_spec", "nix-github-actions": "nix-github-actions", "nixpkgs": [ "nixpkgs" ], "pre-commit-hooks": "pre-commit-hooks", - "systems": "systems_2" + "systems": "systems" }, "locked": { - "lastModified": 1712510613, - "narHash": "sha256-M1lCAooWD3LVrxkeoLt3ckmW6lSGUGbQIcH8t7AuA6w=", + "lastModified": 1727513065, + "narHash": "sha256-YMFaXfUawh0thDy2qYLHsTw5WGJO4RFlfkcLy6W2GU0=", "owner": "jbboehr", "repo": "handlebars.c", - "rev": "3467eec4d7db03f7c0191e378b330e1c18a1dd44", + "rev": "cc9057becadb2095ed22ca0f3d3a58a904a459df", "type": "github" }, "original": { @@ -308,17 +259,33 @@ }, "handlebars_spec": { "inputs": { - "flake-utils": "flake-utils_4", + "flake-utils": [ + "handlebars-c", + "flake-utils" + ], + "gitignore": [ + "handlebars-c", + "gitignore" + ], "nixpkgs": [ + "handlebars-c", "nixpkgs" + ], + "pre-commit-hooks": [ + "handlebars-c", + "pre-commit-hooks" + ], + "systems": [ + "handlebars-c", + "systems" ] }, "locked": { - "lastModified": 1669575861, - "narHash": "sha256-zBvuDrq6EPkwVgtE7dNeITJPE+cJPSq39Vmf0ZK8Suc=", + "lastModified": 1727508389, + "narHash": "sha256-1RdK24zzzYpY/u/R+kTktIjgBpfig8s5dxGx2mr8jRs=", "owner": "jbboehr", "repo": "handlebars-spec", - "rev": "289859aba16bc9e63d5b05ce176b777cb67700dc", + "rev": "0fbf7ecdcd7ed789139f475fd40bfcf0520b0e9a", "type": "github" }, "original": { @@ -327,24 +294,60 @@ "type": "github" } }, - "mustache_spec": { + "handlebars_spec_2": { "inputs": { - "flake-utils": "flake-utils_5", + "flake-utils": "flake-utils_3", + "gitignore": "gitignore_3", "nixpkgs": [ "nixpkgs" - ] + ], + "pre-commit-hooks": "pre-commit-hooks_2", + "systems": "systems_2" }, "locked": { - "lastModified": 1669505557, - "narHash": "sha256-kYsxjpZruLDzJCT9wYFvUFQshHkQqF9jMeXu1ZTo6XU=", + "lastModified": 1727508389, + "narHash": "sha256-1RdK24zzzYpY/u/R+kTktIjgBpfig8s5dxGx2mr8jRs=", "owner": "jbboehr", - "repo": "mustache-spec", - "rev": "18cca097c306e8cbfd9f6a30f86a52f4c1d219e4", + "repo": "handlebars-spec", + "rev": "0fbf7ecdcd7ed789139f475fd40bfcf0520b0e9a", "type": "github" }, "original": { "owner": "jbboehr", - "repo": "mustache-spec", + "repo": "handlebars-spec", + "type": "github" + } + }, + "mustache_spec": { + "flake": false, + "locked": { + "lastModified": 1424648577, + "narHash": "sha256-AHkiEFeo204TnNkm2ACoaJc3tz/19zjKzH1uAiI0Trw=", + "owner": "mustache", + "repo": "spec", + "rev": "83b0721610a4e11832e83df19c73ace3289972b9", + "type": "github" + }, + "original": { + "owner": "mustache", + "ref": "v1.1.3", + "repo": "spec", + "type": "github" + } + }, + "mustache_spec_2": { + "flake": false, + "locked": { + "lastModified": 1723412998, + "narHash": "sha256-8Xn9lfbfWeL0re4W9+K5QVFWq6aByzPA+rflFhUr3cg=", + "owner": "mustache", + "repo": "spec", + "rev": "66f078e0d534515d8df23d0d3764dccda74e042b", + "type": "github" + }, + "original": { + "owner": "mustache", + "repo": "spec", "type": "github" } }, @@ -356,11 +359,11 @@ ] }, "locked": { - "lastModified": 1703863825, - "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=", + "lastModified": 1720066371, + "narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=", "owner": "nix-community", "repo": "nix-github-actions", - "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547", + "rev": "622f829f5fe69310a866c8a6cd07e747c44ef820", "type": "github" }, "original": { @@ -376,11 +379,11 @@ ] }, "locked": { - "lastModified": 1703863825, - "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=", + "lastModified": 1720066371, + "narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=", "owner": "nix-community", "repo": "nix-github-actions", - "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547", + "rev": "622f829f5fe69310a866c8a6cd07e747c44ef820", "type": "github" }, "original": { @@ -389,68 +392,79 @@ "type": "github" } }, - "nixpkgs": { + "nix-github-actions_3": { + "inputs": { + "nixpkgs": [ + "php-psr", + "nixpkgs" + ] + }, "locked": { - "lastModified": 1712510854, - "narHash": "sha256-5grEixAy6uUMFKE8w1c54iBg8BeLzz4HdPNRD4tN3HQ=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "0f58ce3b44a0b4c8a95034af8a45c0061c01d766", + "lastModified": 1720066371, + "narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "622f829f5fe69310a866c8a6cd07e747c44ef820", "type": "github" }, "original": { - "owner": "nixos", - "repo": "nixpkgs", + "owner": "nix-community", + "repo": "nix-github-actions", "type": "github" } }, - "nixpkgs-stable": { + "nixpkgs": { "locked": { - "lastModified": 1710695816, - "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", - "owner": "NixOS", + "lastModified": 1727397532, + "narHash": "sha256-pojbL/qteElw/nIXlN8kmHn/w6PQbEHr7Iz+WOXs0EM=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "614b4613980a522ba49f0d194531beddbb7220d3", + "rev": "f65141456289e81ea0d5a05af8898333cab5c53d", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixos-23.11", + "owner": "nixos", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } }, - "nixpkgs-stable_2": { + "nixpkgs-unstable": { "locked": { - "lastModified": 1710695816, - "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", - "owner": "NixOS", + "lastModified": 1727348695, + "narHash": "sha256-J+PeFKSDV+pHL7ukkfpVzCOO7mBSrrpJ3svwBFABbhI=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "614b4613980a522ba49f0d194531beddbb7220d3", + "rev": "1925c603f17fc89f4c8f6bf6f631a802ad85d784", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixos-23.11", + "owner": "nixos", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "php-psr": { "inputs": { - "composer2nix": "composer2nix", - "flake-utils": "flake-utils_6", + "flake-utils": "flake-utils_4", "gitignore": "gitignore_4", + "nix-github-actions": "nix-github-actions_3", "nixpkgs": [ "nixpkgs" - ] + ], + "nixpkgs-unstable": [ + "nixpkgs-unstable" + ], + "pre-commit-hooks": "pre-commit-hooks_3", + "systems": "systems_3" }, "locked": { - "lastModified": 1669530777, - "narHash": "sha256-/b1k+hLX4iQSDiiZyNfVqseKh6IdSurbz8Zij9EAKGA=", + "lastModified": 1727556183, + "narHash": "sha256-UcSDFSivtskW5eLWNDD3YgKCavX9OZGd1h2kl2U6SZU=", "owner": "jbboehr", "repo": "php-psr", - "rev": "a46f438d0e2669ad56ffe859650ef0be10fc5e91", + "rev": "5aeec9f57379958b761069eca817fcf418f429e6", "type": "github" }, "original": { @@ -462,20 +476,25 @@ "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils_3", - "gitignore": "gitignore_3", + "gitignore": [ + "handlebars-c", + "gitignore" + ], "nixpkgs": [ "handlebars-c", "nixpkgs" ], - "nixpkgs-stable": "nixpkgs-stable" + "nixpkgs-stable": [ + "handlebars-c", + "nixpkgs" + ] }, "locked": { - "lastModified": 1712055707, - "narHash": "sha256-4XLvuSIDZJGS17xEwSrNuJLL7UjDYKGJSbK1WWX2AK8=", + "lastModified": 1726745158, + "narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "e35aed5fda3cc79f88ed7f1795021e559582093a", + "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74", "type": "github" }, "original": { @@ -487,19 +506,82 @@ "pre-commit-hooks_2": { "inputs": { "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_7", - "gitignore": "gitignore_5", + "gitignore": [ + "handlebars_spec", + "gitignore" + ], "nixpkgs": [ + "handlebars_spec", "nixpkgs" ], - "nixpkgs-stable": "nixpkgs-stable_2" + "nixpkgs-stable": [ + "handlebars_spec", + "nixpkgs" + ] }, "locked": { - "lastModified": 1712055707, - "narHash": "sha256-4XLvuSIDZJGS17xEwSrNuJLL7UjDYKGJSbK1WWX2AK8=", + "lastModified": 1726745158, + "narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "e35aed5fda3cc79f88ed7f1795021e559582093a", + "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pre-commit-hooks_3": { + "inputs": { + "flake-compat": "flake-compat_3", + "gitignore": [ + "php-psr", + "gitignore" + ], + "nixpkgs": [ + "php-psr", + "nixpkgs" + ], + "nixpkgs-stable": [ + "php-psr", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1727514110, + "narHash": "sha256-0YRcOxJG12VGDFH8iS8pJ0aYQQUAgo/r3ZAL+cSh9nk=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "85f7a7177c678de68224af3402ab8ee1bcee25c8", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pre-commit-hooks_4": { + "inputs": { + "flake-compat": "flake-compat_4", + "gitignore": [ + "gitignore" + ], + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1727514110, + "narHash": "sha256-0YRcOxJG12VGDFH8iS8pJ0aYQQUAgo/r3ZAL+cSh9nk=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "85f7a7177c678de68224af3402ab8ee1bcee25c8", "type": "github" }, "original": { @@ -513,12 +595,13 @@ "flake-utils": "flake-utils", "gitignore": "gitignore", "handlebars-c": "handlebars-c", - "handlebars_spec": "handlebars_spec", - "mustache_spec": "mustache_spec", + "handlebars_spec": "handlebars_spec_2", + "mustache_spec": "mustache_spec_2", "nix-github-actions": "nix-github-actions_2", "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable", "php-psr": "php-psr", - "pre-commit-hooks": "pre-commit-hooks_2", + "pre-commit-hooks": "pre-commit-hooks_4", "systems": "systems_4" } }, @@ -539,16 +622,16 @@ }, "systems_2": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", "type": "github" }, "original": { "owner": "nix-systems", - "repo": "default", + "repo": "default-linux", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 3b1af18..e1d08d5 100644 --- a/flake.nix +++ b/flake.nix @@ -2,15 +2,16 @@ description = "php-handlebars"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; systems.url = "github:nix-systems/default"; flake-utils = { url = "github:numtide/flake-utils"; inputs.systems.follows = "systems"; }; mustache_spec = { - url = "github:jbboehr/mustache-spec"; - inputs.nixpkgs.follows = "nixpkgs"; + url = "github:mustache/spec"; + flake = false; }; handlebars_spec = { url = "github:jbboehr/handlebars-spec"; @@ -18,13 +19,14 @@ }; handlebars-c = { url = "github:jbboehr/handlebars.c"; - inputs.mustache_spec.follows = "mustache_spec"; - inputs.handlebars_spec.follows = "handlebars_spec"; + #inputs.mustache_spec.follows = "mustache_spec"; + #inputs.handlebars_spec.follows = "handlebars_spec"; inputs.nixpkgs.follows = "nixpkgs"; }; php-psr = { url = "github:jbboehr/php-psr"; inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs-unstable.follows = "nixpkgs-unstable"; }; gitignore = { url = "github:hercules-ci/gitignore.nix"; @@ -33,6 +35,8 @@ pre-commit-hooks = { url = "github:cachix/pre-commit-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixpkgs-stable.follows = "nixpkgs"; + inputs.gitignore.follows = "gitignore"; }; nix-github-actions = { url = "github:nix-community/nix-github-actions"; @@ -43,6 +47,8 @@ outputs = { self, nixpkgs, + nixpkgs-unstable, + systems, flake-utils, mustache_spec, handlebars_spec, @@ -51,13 +57,12 @@ gitignore, pre-commit-hooks, nix-github-actions, - ... - } @ args: + }: flake-utils.lib.eachDefaultSystem ( system: let pkgs = nixpkgs.legacyPackages.${system}; + pkgs-unstable = nixpkgs-unstable.legacyPackages.${system}; lib = pkgs.lib; - php = pkgs.php; src' = gitignore.lib.gitignoreSource ./.; src = pkgs.lib.cleanSourceWith { @@ -84,6 +89,7 @@ pre-commit-check = pre-commit-hooks.lib.${system}.run { src = src'; hooks = { + actionlint.enable = true; alejandra.enable = true; #markdownlint.enable = true; #shellcheck.enable = true; @@ -94,18 +100,20 @@ stdenv ? pkgs.stdenv, php ? pkgs.php, astSupport ? false, + checkSupport ? false, + coverageSupport ? false, }: pkgs.callPackage ./nix/derivation.nix { inherit src; inherit stdenv php; + inherit astSupport checkSupport coverageSupport; buildPecl = pkgs.callPackage (nixpkgs + "/pkgs/build-support/php/build-pecl.nix") { inherit php stdenv; }; - inherit (gitignore.lib) gitignoreSource; - mustache_spec = mustache_spec.packages.${system}.mustache-spec; + mustache_spec = mustache_spec; handlebars_spec = handlebars_spec.packages.${system}.handlebars-spec; handlebarsc = handlebars-c.packages.${system}.handlebars-c; - php_psr = args.php-psr.packages.${system}.php-psr; + php_psr = php-psr.packages.${system}.php-psr; }; makeCheck = package: @@ -143,6 +151,7 @@ matrix = with pkgs; { php = { inherit php81 php82 php83; + php84 = pkgs-unstable.php84; }; stdenv = { gcc = stdenv; @@ -153,21 +162,30 @@ }; # @see https://github.com/NixOS/nixpkgs/pull/110787 - buildConfs = lib.cartesianProductOfSets { - php = ["php81" "php82" "php83"]; - stdenv = [ - "gcc" - "clang" - # totally broken - # "musl" - ]; - astSupport = [true false]; - }; + buildConfs = + (lib.cartesianProductOfSets { + php = ["php81" "php82" "php83" "php84"]; + stdenv = [ + "gcc" + "clang" + # totally broken + # "musl" + ]; + astSupport = [true false]; + coverageSupport = [false]; + }) + ++ (lib.cartesianProductOfSets { + php = ["php81" "php82" "php83" "php84"]; + stdenv = ["gcc"]; + astSupport = [true]; + coverageSupport = [true]; + }); buildFn = { php, stdenv, astSupport ? false, + coverageSupport ? false, }: lib.nameValuePair (lib.concatStringsSep "-" (lib.filter (v: v != "") [ @@ -178,12 +196,17 @@ then "ast" else "" ) + ( + if coverageSupport + then "coverage" + else "" + ) ])) ( makePackage { php = matrix.php.${php}; stdenv = matrix.stdenv.${stdenv}; - inherit astSupport; + inherit astSupport coverageSupport; } ); @@ -197,11 +220,11 @@ php-handlebars-dist = pkgs.runCommand "handlebars-pecl.tgz" { - buildInputs = [php]; + buildInputs = [pkgs.php]; inherit src; } '' cp -r $src/* . - PHP_PEAR_PHP_BIN=${php}/bin/php pecl package + PHP_PEAR_PHP_BIN=${pkgs.php}/bin/php pecl package mv handlebars-*.tgz $out ''; }; diff --git a/nix/derivation.nix b/nix/derivation.nix index b973d61..90ffe2c 100644 --- a/nix/derivation.nix +++ b/nix/derivation.nix @@ -4,12 +4,13 @@ stdenv, autoreconfHook, fetchurl, + pkg-config, talloc, pcre, pcre2, buildPecl, handlebarsc, - gitignoreSource, + lcov ? null, valgrind ? null, php_psr ? null, handlebars_spec ? null, @@ -22,9 +23,10 @@ psrSupport ? true, WerrorSupport ? (debugSupport || devSupport), valgrindSupport ? (debugSupport || devSupport), + coverageSupport ? false, src, }: -buildPecl rec { +(buildPecl rec { pname = "handlebars"; name = "handlebars-${version}"; version = "v1.0.0"; @@ -35,14 +37,20 @@ buildPecl rec { inherit stdenv php; }; + outputs = + lib.optional (checkSupport && coverageSupport) "coverage" + ++ ["out" "dev"]; + buildInputs = [handlebarsc talloc pcre pcre2] ++ lib.optional valgrindSupport valgrind ++ lib.optional psrSupport php_psr; nativeBuildInputs = - [php.unwrapped.dev] - ++ lib.optionals checkSupport [handlebars_spec mustache_spec]; + [php.unwrapped.dev pkg-config] + ++ lib.optionals checkSupport [handlebars_spec] + ++ lib.optional valgrindSupport valgrind + ++ lib.optional coverageSupport lcov; configureFlags = [] @@ -53,17 +61,57 @@ buildPecl rec { ++ lib.optional psrSupport "--enable-handlebars-psr" ++ lib.optional (!psrSupport) "--disable-handlebars-psr" ++ lib.optional WerrorSupport "--enable-compile-warnings=error" - ++ lib.optionals (!WerrorSupport) ["--enable-compile-warnings=yes" "--disable-Werror"]; + ++ lib.optionals (!WerrorSupport) ["--enable-compile-warnings=yes" "--disable-Werror"] + ++ lib.optional coverageSupport ["--enable-handlebars-coverage"]; - makeFlags = ["phpincludedir=$(out)/include/php/ext/handlebars"]; + makeFlags = ["phpincludedir=$(dev)/include"]; - preBuild = lib.optionalString checkSupport '' - HANDLEBARS_SPEC_DIR="${handlebars_spec}/share/handlebars-spec" \ - MUSTACHE_SPEC_DIR="${mustache_spec}/share/mustache-spec" \ - ${php}/bin/php generate-tests.php - ''; + preBuild = + # (lib.optionalString checkSupport '' + # HANDLEBARS_SPEC_DIR="${handlebars_spec}/share/handlebars-spec" \ + # MUSTACHE_SPEC_DIR="${mustache_spec}" \ + # ${php}/bin/php generate-tests.php + # '') + # + + lib.optionalString coverageSupport '' + lcov --directory . --zerocounters + lcov --directory . --capture --compat-libtool --initial --output-file coverage.info + ''; doCheck = checkSupport; - #checkTarget = "test"; - #checkFlags = ["REPORT_EXIT_STATUS=1" "NO_INTERACTION=1"]; -} + + theRealFuckingCheckPhase = + '' + runHook preCheck + REPORT_EXIT_STATUS=1 NO_INTERACTION=1 make test TEST_PHP_ARGS="-n" || (find tests -name '*.log' | xargs cat ; exit 1) + '' + + (lib.optionalString valgrindSupport '' + USE_ZEND_ALLOC=0 REPORT_EXIT_STATUS=1 NO_INTERACTION=1 make test TEST_PHP_ARGS="-n -m" || (find tests -name '*.mem' | xargs cat ; exit 1) + '') + + '' + runHook postCheck + ''; + + postCheck = lib.optionalString coverageSupport '' + lcov --no-checksum --directory . --capture --no-markers --compat-libtool --output-file coverage.info + set -o noglob + lcov --remove coverage.info '${builtins.storeDir}/*' \ + --compat-libtool \ + --output-file coverage.info + set +o noglob + mkdir -p $coverage + cp coverage.info $coverage/coverage.info + genhtml coverage.info -o $coverage/html/ + ''; + + meta = with lib; { + homepage = "https://github.com/jbboehr/php-handlebars"; + license = licenses.bsd2; + outputsToInstall = outputs; + }; +}) +.overrideAttrs (o: + o + // { + checkPhase = o.theRealFuckingCheckPhase; + }) diff --git a/src/php_handlebars.c b/src/php_handlebars.c index f870fbd..b88c1fc 100644 --- a/src/php_handlebars.c +++ b/src/php_handlebars.c @@ -97,6 +97,9 @@ static PHP_RINIT_FUNCTION(handlebars) /* }}} */ /* {{{ PHP_MINIT_FUNCTION */ +const char *HANDLEBARS_MOTD = + "Think not that I am come to send peace on earth: I came not to send peace, but a sword. Matthew 10:34"; + static PHP_MINIT_FUNCTION(handlebars) { int flags = CONST_CS | CONST_PERSISTENT; @@ -113,6 +116,7 @@ static PHP_MINIT_FUNCTION(handlebars) REGISTER_STRING_CONSTANT("Handlebars\\VERSION", (char *) PHP_HANDLEBARS_VERSION, flags); REGISTER_STRING_CONSTANT("Handlebars\\LIBVERSION", (char *) version, flags); REGISTER_STRING_CONSTANT("Handlebars\\LIBVERSION2", (char *) HANDLEBARS_VERSION_STRING, flags); + REGISTER_STRING_CONSTANT("Handlebars\\MOTD", (char *) HANDLEBARS_MOTD, flags); // Setup root contexts HANDLEBARS_G(root) = talloc_new(NULL); @@ -277,6 +281,10 @@ static PHP_MINFO_FUNCTION(handlebars) } DISPLAY_INI_ENTRIES(); + + php_info_print_box_start(0); + PUTS(HANDLEBARS_MOTD); + php_info_print_box_end(); } /* }}} */