Skip to content

Commit

Permalink
Merge pull request #222 from AlexNDRmac/builds-for-debian
Browse files Browse the repository at this point in the history
Builds for debian
  • Loading branch information
NoiseByNorthwest authored Sep 2, 2023
2 parents e6ad49d + 827ded0 commit d245728
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 47 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build-debian-ext/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions .github/workflows/build-debian-ext/action.yml
Original file line number Diff line number Diff line change
@@ -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)"
48 changes: 48 additions & 0 deletions .github/workflows/build-linux-mac-ext/action.yml
Original file line number Diff line number Diff line change
@@ -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"
66 changes: 20 additions & 46 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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:
Expand All @@ -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

Expand Down
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d245728

Please sign in to comment.