diff --git a/.github/workflows/build-debian-ext/Dockerfile b/.github/workflows/build-debian-ext/Dockerfile new file mode 100644 index 0000000..d5ea606 --- /dev/null +++ b/.github/workflows/build-debian-ext/Dockerfile @@ -0,0 +1,25 @@ +FROM debian:11.5-slim as builder + +LABEL Description="Base image with custom PHP version based on Debian" +LABEL name="spx-profiler-debian11" + +ENV DEBIAN_FRONTEND="noninteractive" +ARG PHP_VERSION + +RUN apt update && apt upgrade -y && \ + apt install --no-install-recommends -y \ + lsb-release \ + ca-certificates \ + apt-transport-https \ + software-properties-common \ + gnupg2 \ + wget \ + curl \ + git \ + make\ + zlib1g-dev \ + && \ + echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/sury-php.list && \ + wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add - && \ + apt update && \ + apt install -y php${PHP_VERSION}-dev diff --git a/.github/workflows/build-debian-ext/action.yml b/.github/workflows/build-debian-ext/action.yml new file mode 100644 index 0000000..1a5325e --- /dev/null +++ b/.github/workflows/build-debian-ext/action.yml @@ -0,0 +1,44 @@ +name: 'PHP Extension build action' +description: 'Build PHP extension for debian using docker' + +runs: + using: 'composite' + steps: + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-php${{ matrix.php }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - uses: docker/build-push-action@v4 + with: + push: false + load: true + tags: builder:${{ matrix.php }} + file: ./.github/workflows/build-debian-ext/Dockerfile + build-args: | + PHP_VERSION=${{ matrix.php }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + - name: Move buildx cache + shell: bash + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + - name: Run the build process with Docker + uses: addnab/docker-run-action@v3 + with: + image: builder:${{ matrix.php }} + options: -v ${{ github.workspace }}:/php-spx + run: | + cd /php-spx + phpize + ./configure + make -j"$(getconf _NPROCESSORS_ONLN)" diff --git a/.github/workflows/build-linux-mac-ext/action.yml b/.github/workflows/build-linux-mac-ext/action.yml new file mode 100644 index 0000000..fbfe8be --- /dev/null +++ b/.github/workflows/build-linux-mac-ext/action.yml @@ -0,0 +1,48 @@ +name: 'PHP Extension build action' +description: 'Build PHP extension for linux/mac' + +runs: + using: 'composite' + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: Install dependencies + shell: bash + if: runner.os == 'macOS' + run: brew install zlib + + - name: phpize + shell: bash + run: phpize + + - name: Configure + shell: bash + run: | + if [ "${{ runner.os }}" = "macOS" ]; then + ./configure --with-zlib-dir=$(brew --prefix)/opt/zlib + else + ./configure + fi + + - name: Compile + shell: bash + run: | + make -j"$(getconf _NPROCESSORS_ONLN)" + sudo make install + + - name: Extension Info + shell: bash + run: | + php --ini + php -d extension=./modules/spx.so --ri spx + + - name: Run Tests + shell: bash + run: make test + env: + NO_INTERACTION: 1 + REPORT_EXIT_STATUS: 1 + TEST_PHP_ARGS: "--show-diff" \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5528bf7..d09c21a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,65 +25,39 @@ jobs: name: - linux + - debian - mac include: # Linux - - { name: linux, ts: 'nts', compiler: 'gcc', os: ubuntu-20.04 } + - { name: linux, ts: 'nts', compiler: 'gcc', os: ubuntu-20.04 } + # Debian (docker) + - { name: debian, ts: 'nts', compiler: 'gcc', os: ubuntu-20.04 } # macOS - - { name: mac, ts: 'nts', compiler: 'clang', os: macos-11 } + - { name: mac, ts: 'nts', compiler: 'clang', os: macos-11 } steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # configure spx artifact name in next format: # {php}-{ts}-{os.name}-{compiler} - # spx-php-8.1-nts-Linux-gcc + # spx-php-8.1-nts-linux-gcc - name: Set artifact name id: setup-artifact run: | - echo "::set-output name=spx_file_name::spx-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}" + echo "spx_file_name=spx-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.compiler }}" >> $GITHUB_OUTPUT - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - - - name: Install dependencies - if: runner.os == 'macOS' - run: brew install zlib - - - name: phpize - run: phpize - - - name: Configure - run: | - if [ "${{ runner.os }}" = "macOS" ]; then - ./configure --with-zlib-dir=$(brew --prefix)/opt/zlib - else - ./configure - fi + - name: Build extension for Ubuntu and macOS + if: matrix.name != 'debian' + uses: ./.github/workflows/build-linux-mac-ext - - name: Compile - run: | - make -j"$(getconf _NPROCESSORS_ONLN)" - sudo make install - - - name: Extension Info - run: | - php --ini - php -d extension=./modules/spx.so --ri spx - - - name: Run Tests - run: make test - env: - NO_INTERACTION: 1 - REPORT_EXIT_STATUS: 1 - TEST_PHP_ARGS: "--show-diff" + - name: Build extension for Debian using docker + if: matrix.name == 'debian' + uses: ./.github/workflows/build-debian-ext - name: Upload build artifacts after Failure if: failure() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: debug-${{ steps.setup-artifact.outputs.spx_file_name }} path: | @@ -106,9 +80,9 @@ jobs: ./.github/release-notes.sh ./CHANGELOG.md - name: Upload build artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: - name: ${{ steps.setup-artifact.outputs.spx_file_name }} + name: ${{ steps.setup-artifact.outputs.spx_file_name }}.zip path: ${{ steps.setup-artifact.outputs.spx_file_name }}.zip release: @@ -120,18 +94,18 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 1 - name: Get the release version id: get-version run: | - echo ::set-output name=version::${GITHUB_REF#refs/tags/} + echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - name: Download SPX build artifacts id: download - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: path: ./build-artifacts diff --git a/CHANGELOG.md b/CHANGELOG.md index 81f4c56..c8d0eb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [Unreleased](https://github.com/NoiseByNorthwest/php-spx/compare/0.4.13...HEAD) +## [Unreleased](https://github.com/NoiseByNorthwest/php-spx/compare/0.4.14...HEAD) + +### Added +- Added Debian builds to github workflow + + +## [v0.4.14](https://github.com/NoiseByNorthwest/php-spx/compare/0.4.13...0.4.14) + +### Added +- Added simple search feature +- Added custom metadata storage implementation +- Added `--enable-spx-dev` to compile with debug symbols + +### Fixed +- Fixed buffer overflow in str_builder ## [v0.4.13](https://github.com/NoiseByNorthwest/php-spx/compare/0.4.12...0.4.13)