Skip to content

Commit

Permalink
Modernize CI environments (#20)
Browse files Browse the repository at this point in the history
* add PHP 8.3 support (extension)

* actions: update actions

* chore: remove unused compose dependencies

* fix: suppress clang ubsan

* chore: fix: remove unused compose deps again

* actions: skip UBSan in PHP 8.1

* chore 11.0.2-dev
  • Loading branch information
zeriyoshi authored Jul 2, 2024
1 parent 9be9dbf commit 2e66e1b
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"build": {
"args": {
"IMAGE": "php",
"TAG": "8.2-cli"
"TAG": "8.3-cli"
}
},
"customizations": {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
mkdir "artifacts"
docker run --env VERSION="${{ github.ref_name }}" --rm -v"$(pwd)/artifacts:/tmp/artifacts" -i "pskel-build-ubuntu2204-${{ matrix.arch }}"
- name: Upload deb Packages
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ubuntu_2204_debs
name: ubuntu_2204_debs-${{ matrix.arch }}
path: artifacts/
78 changes: 26 additions & 52 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,73 +1,47 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '0 2 * * *'
on: [push, pull_request]
jobs:
Library:
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
matrix:
version: ["7.4", "8.0", "8.1", "8.2", "8.3"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Build Container
uses: docker/build-push-action@v6
with:
build-args: |
IMAGE=php
TAG=${{ matrix.version }}-cli
context: .
file: ./build/library/Dockerfile
load: true
tags: "library-docker-${{ matrix.version }}"
- name: Test Library
run: docker run --rm -v"$(pwd):/workspace:cached" -i library-docker-${{ matrix.version }}
Extension:
CI:
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
matrix:
arch: ["amd64", "arm64v8", "s390x"]
version: ["8.0", "8.1", "8.2"]
version: ["8.1", "8.2", "8.3"]
type: ["cli", "zts"]
distro: ["bullseye", "alpine"]
distro: ["bookworm", "alpine"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "arm64,s390x"
- name: Setup Buildx
- name: Setup buildx
uses: docker/setup-buildx-action@v3
- name: Build Container
uses: docker/build-push-action@v6
with:
build-args: |
IMAGE=${{ matrix.arch }}/php
TAG=${{ matrix.version }}-${{ matrix.type }}-${{ matrix.distro }}
PSKEL_SKIP_DEBUG=${{ matrix.arch != 'amd64' && '1' || '' }}
context: .
load: true
tags: "pskel-${{ matrix.arch }}-${{ matrix.type }}-${{ matrix.distro }}"
- name: Test Extension
- name: Build container
run: |
docker run --env TEST_EXTENSION=1 --rm -i pskel-${{ matrix.arch }}-${{ matrix.type }}-${{ matrix.distro }}
- name: Test Extension with Valgrind
docker compose build --pull --no-cache --build-arg IMAGE=${{ matrix.arch }}/php --build-arg TAG=${{ matrix.version }}-${{ matrix.type }}-${{ matrix.distro }} --build-arg PSKEL_SKIP_DEBUG=${{ matrix.arch != 'amd64' && '1' || '' }}
- name: Run tests
run: |
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION=1 dev
- name: Test extension with PHP Debug Build
if: matrix.arch == 'amd64'
run: |
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION_DEBUG=1 dev
- name: Test extension with Valgrind
if: matrix.arch == 'amd64'
run: |
docker run --env TEST_EXTENSION_VALGRIND=1 --rm -i pskel-${{ matrix.arch }}-${{ matrix.type }}-${{ matrix.distro }}
- name: Test Extension with MSAN
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION_VALGRIND=1 dev
- name: Test extension with LLVM Sanitizer (MemorySanitizer)
if: matrix.arch == 'amd64' && matrix.distro != 'alpine'
run: |
docker run --env TEST_EXTENSION_MSAN=1 --rm -i pskel-${{ matrix.arch }}-${{ matrix.type }}-${{ matrix.distro }}
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION_MSAN=1 dev
- name: Test extension with LLVM Sanitizer (AddressSanitizer)
if: matrix.arch == 'amd64' && matrix.distro != 'alpine'
run: |
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION_ASAN=1 dev
- name: Test extension with LLVM Sanitizer (UndefinedBehaviorSanitizer)
if: matrix.arch == 'amd64' && matrix.distro != 'alpine' && matrix.version != '8.1'
run: |
docker compose run --rm --entrypoint=/usr/bin/ci --env TEST_EXTENSION_UBSAN=1 dev
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# x.x.x (Not released yet)
# 11.0.2-dev
- Add official support for PHP 8.3

# 11.0.1 (Not released yet)
# 11.0.1
- More strict bundled tests

# 11.0.0
Expand Down
88 changes: 74 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,54 +1,116 @@
ARG IMAGE=php
ARG TAG=8.2-cli
ARG TAG=8.3-cli

FROM ${IMAGE}:${TAG}

ARG PSKEL_SKIP_DEBUG=""
ARG PSKEL_EXTRA_CONFIGURE_OPTIONS=""

ENV USE_ZEND_ALLOC=0
ENV ZEND_DONT_UNLOAD_MODULES=1
ENV PSKEL_SKIP_DEBUG=${PSKEL_SKIP_DEBUG}
ENV PSKEL_EXTRA_CONFIGURE_OPTIONS=${PSKEL_EXTRA_CONFIGURE_OPTIONS}

RUN if test -f "/etc/debian_version"; then \
apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y \
"build-essential" "bison" "valgrind" "llvm" "clang" && \
"build-essential" "bison" "valgrind" "llvm" "clang" "zlib1g-dev" "libsqlite3-dev" && \
if test "${PSKEL_SKIP_DEBUG}" = ""; then \
docker-php-source extract && \
cd "/usr/src/php" && \
CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \
--includedir="/usr/local/include/gcc-debug-php" --program-prefix="gcc-debug-" \
--disable-cgi --disable-fpm --disable-phpdbg --enable-cli \
--includedir="/usr/local/include/gcc-valgrind-php" --program-prefix="gcc-valgrind-" \
--disable-cgi --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
--with-valgrind \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete && \
docker-php-source extract && \
cd "/usr/src/php" && \
CC=clang CXX=clang++ CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure \
--includedir="/usr/local/include/clang-debug-php" --program-prefix="clang-debug-" \
--disable-cgi --disable-all --disable-fpm --disable-phpdbg --enable-cli \
CC=clang CXX=clang++ CFLAGS="-fsanitize=memory -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=memory" ./configure \
--includedir="/usr/local/include/clang-msan-php" --program-prefix="clang-msan-" \
--disable-cgi --disable-all --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
--enable-memory-sanitizer \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete && \
docker-php-source extract && \
cd "/usr/src/php" && \
CC=clang CXX=clang++ CFLAGS="-fsanitize=address -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=address" ./configure \
--includedir="/usr/local/include/clang-asan-php" --program-prefix="clang-asan-" \
--disable-cgi --disable-all --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
--enable-address-sanitizer \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete && \
docker-php-source extract && \
cd "/usr/src/php" && \
CC=clang CXX=clang++ CFLAGS="-fsanitize=undefined -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined" ./configure \
--includedir="/usr/local/include/clang-ubsan-php" --program-prefix="clang-ubsan-" \
--disable-cgi --disable-all --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
--enable-undefined-sanitizer \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete && \
docker-php-source extract && \
cd "/usr/src/php" && \
CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \
--includedir="/usr/local/include/debug-php" --program-prefix="debug-" \
--disable-cgi --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete; \
fi; \
elif test -f "/etc/alpine-release"; then \
apk add --no-cache ${PHPIZE_DEPS} "bison" "valgrind" "valgrind-dev" && \
apk add --no-cache ${PHPIZE_DEPS} "bison" "valgrind" "valgrind-dev" "zlib-dev" "sqlite-dev" && \
if test "${PSKEL_SKIP_DEBUG}" = ""; then \
docker-php-source extract && \
cd "/usr/src/php" && \
CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \
--includedir="/usr/local/include/gcc-debug-php" --program-prefix="gcc-debug-" \
--disable-cgi --disable-fpm --disable-phpdbg --enable-cli \
--includedir="/usr/local/include/gcc-valgrind-php" --program-prefix="gcc-valgrind-" \
--disable-cgi --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug --without-pcre-jit "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
--with-valgrind \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
cd - && \
docker-php-source delete && \
docker-php-source extract && \
cd "/usr/src/php" && \
CFLAGS="-fpic -fpie -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-pie" ./configure --disable-all \
--includedir="/usr/local/include/debug-php" --program-prefix="debug-" \
--disable-cgi --disable-fpm --enable-cli \
--enable-mysqlnd --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
--enable-debug "$(php -r "echo PHP_ZTS === 1 ? '--enable-zts' : '';")" \
${PSKEL_EXTRA_CONFIGURE_OPTIONS} \
--enable-option-checking=fatal && \
make -j$(nproc) && \
make install && \
Expand All @@ -60,8 +122,6 @@ RUN if test -f "/etc/debian_version"; then \

WORKDIR "/usr/src/php"

COPY ./ci.sh /usr/bin/ci

ENTRYPOINT ["/usr/bin/ci"]

COPY ./ext /ext

COPY ./ci.sh /usr/bin/ci
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Provides various compatibility functions required for PHP (temporary) migration.
## Supported Versions

- Extension: PHP >= 8.0, 8.2 >= PHP
- Library: PHP >= 7.4, 8.2 >= PHP
- Extension: PHP >= 8.0, 8.3 >= PHP
- Library: PHP >= 7.4, 8.3 >= PHP

Library is introduced for migration to PHP 8.x with the same code base. If you do not need to work with the same code base, you can use only the Extension.

Expand Down
91 changes: 78 additions & 13 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,103 @@
#!/bin/sh -ex
#!/bin/sh -e

case "${1}" in
"") ;;
"test") TEST_EXTENSION=1;;
"debug") TEST_EXTENSION_DEBUG=1;;
"valgrind") TEST_EXTENSION_VALGRIND=1;;
"msan") TEST_EXTENSION_MSAN=1;;
"asan") TEST_EXTENSION_ASAN=1;;
"ubsan") TEST_EXTENSION_UBSAN=1;;
*) printf "Pskel CI\nusage:\n\t\t%s\t\t: %s\n\t\t%s\t\t: %s\n\t\t%s\t: %s\n\t\t%s\t\t: %s\n\t\t%s\t\t: %s\n\t\t%s\t\t: %s\n" "test" "Test extension with pre-installed PHP binary. [bin: $(which "php")]" "debug" "Test extension with Debug Build (GCC) binary. [bin: $(which "debug-php")]" "valgrind" "Test extension with GCC binary with Valgrind. [bin: $(which "gcc-valgrind-php")]" "msan" "Test extension with Clang binary with MemorySanitizer. [bin: $(which "clang-msan-php")]" "asan" "Test extension with Clang binary with AddressSanitizer. [bin: $(which "clang-asan-php")]" "ubsan" "Test extension with Clang binary with UndefinedBehaviorSanitizer. [bin: $(which "clang-ubsan-php")]"; exit 0;;
esac

echo "[Pskel CI] BEGIN TEST"

if test "${TEST_EXTENSION}" != ""; then
cd "/ext"
phpize
./configure --with-php-config=$(which php-config)
./configure --with-php-config="$(which php-config)"
make clean
make -j$(nproc)
make -j"$(nproc)"
TEST_PHP_ARGS="--show-diff -q" make test
else
echo "[Pskel CI] skip: TEST_EXTENSION is not set"
fi

if test "${TEST_EXTENSION_DEBUG}" != ""; then
cd "/ext"
debug-phpize
./configure --with-php-config="$(which debug-php-config)"
make clean
make -j"$(nproc)"
TEST_PHP_ARGS="--show-diff -q" make test
else
echo "[Pskel CI] skip: TEST_EXTENSION_DEBUG is not set"
fi

if test "${TEST_EXTENSION_VALGRIND}" != ""; then
if type "gcc-debug-php" > /dev/null 2>&1; then
if type "gcc-valgrind-php" > /dev/null 2>&1; then
cd "/ext"
gcc-debug-phpize
./configure --with-php-config=$(which gcc-debug-php-config)
gcc-valgrind-phpize
./configure --with-php-config="$(which gcc-valgrind-php-config)"
make clean
make -j$(nproc)
make -j"$(nproc)"
TEST_PHP_ARGS="--show-diff -q -m" make test
else
echo "missing gcc-debug-php"
echo "[Pskel CI] missing gcc-valgrind-php"
exit 1
fi
else
echo "[Pskel CI] skip: TEST_EXTENSION_VALGRIND is not set"
fi

if test "${TEST_EXTENSION_MSAN}" != ""; then
if type "clang-debug-php" > /dev/null 2>&1; then
if type "clang-msan-php" > /dev/null 2>&1; then
cd "/ext"
clang-debug-phpize
CC=clang CXX=clang++ CFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=memory" ./configure --with-php-config=$(which clang-debug-php-config)
clang-msan-phpize
CC="clang" CXX="clang++" CFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC" CPPFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC ${CPPFLAGS}" LDFLAGS="-fsanitize=memory" ./configure --with-php-config="$(which clang-msan-php-config)"
make clean
make -j$(nproc)
CFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC ${CFLAGS}" CPPFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC ${CPPFLAGS}" LDFLAGS="-fsanitize=memory" make -j"$(nproc)"
TEST_PHP_ARGS="--show-diff -q --msan" make test
else
echo "missing clang-debug-php"
echo "[Pskel CI] missing clang-msan-php"
exit 1
fi
else
echo "[Pskel CI] skip: TEST_EXTENSION_MSAN is not set"
fi

if test "${TEST_EXTENSION_ASAN}" != ""; then
if type "clang-asan-php" > /dev/null 2>&1; then
cd "/ext"
clang-asan-phpize
CC="clang" CXX="clang++" CFLAGS="-fsanitize=address -DZEND_TRACK_ARENA_ALLOC" CPPFLAGS="-fsanitize=address -DZEND_TRACK_ARENA_ALLOC ${CPPFLAGS}" LDFLAGS="-fsanitize=address" ./configure --with-php-config="$(which clang-asan-php-config)"
make clean
CFLAGS="-fsanitize=address -DZEND_TRACK_ARENA_ALLOC ${CFLAGS}" CPPFLAGS="-fsanitize=address -DZEND_TRACK_ARENA_ALLOC ${CPPFLAGS}" LDFLAGS="-fsanitize=address" make -j"$(nproc)"
TEST_PHP_ARGS="--show-diff -q --asan" make test
else
echo "[Pskel CI] missing clang-asan-php"
exit 1
fi
else
echo "[Pskel CI] skip: TEST_EXTENSION_ASAN is not set"
fi

if test "${TEST_EXTENSION_UBSAN}" != ""; then
if type "clang-ubsan-php" > /dev/null 2>&1; then
cd "/ext"
clang-ubsan-phpize
CC="clang" CXX="clang++" CFLAGS="-fsanitize=undefined -DZEND_TRACK_ARENA_ALLOC" CPPFLAGS="-fsanitize=undefined -DZEND_TRACK_ARENA_ALLOC ${CPPFLAGS}" LDFLAGS="-fsanitize=undefined" ./configure --with-php-config="$(which clang-ubsan-php-config)"
make clean
CFLAGS="-fsanitize=undefined -DZEND_TRACK_ARENA_ALLOC ${CFLAGS}" CPPFLAGS="-fsanitize=undefined -DZEND_TRACK_ARENA_ALLOC ${CPPFLAGS}" LDFLAGS="-fsanitize=undefined" make -j"$(nproc)"
TEST_PHP_ARGS="--show-diff -q" make test
else
echo "[Pskel CI] missing clang-ubsan-php"
exit 1
fi
else
echo "[Pskel CI] skip: TEST_EXTENSION_UBSAN is not set"
fi

echo "[Pskel CI] END TEST"
exit 0
Loading

0 comments on commit 2e66e1b

Please sign in to comment.