Skip to content

Commit

Permalink
Merge pull request #102 from he4rt/feat/better-docker-image
Browse files Browse the repository at this point in the history
feature(dockerimage): better docker image
  • Loading branch information
CodeLieutenant committed Aug 12, 2024
2 parents bfe1bbf + 5697620 commit 871d2ed
Show file tree
Hide file tree
Showing 12 changed files with 541 additions and 453 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
zts:
description: 'ZTS (Zend Thread Safety)'
required: true
ubuntu_version:
type: string
description: 'Ubuntu Version'
required: false
default: '22.04'
workflow_call:
inputs:
php:
Expand All @@ -19,6 +24,11 @@ on:
type: string
description: 'ZTS (Zend Thread Safety)'
required: true
ubuntu_version:
type: string
description: 'Ubuntu Version'
required: false
default: '22.04'
secrets:
DOCKER_USERNAME:
required: true
Expand Down Expand Up @@ -52,14 +62,16 @@ jobs:
push: true
pull: true
platforms: linux/amd64
target: base
tags: malusevd99/scylladb-php-driver:php-${{ inputs.php }}-zts
target: final
tags: malusevd99/scylladb-php-driver:ubuntu-${{ inputs.ubuntu_version }}-php-${{ inputs.php }}-zts
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PHP_VERSION=${{ inputs.php }}
PHP_ZTS=${{ inputs.zts }}
UBUNTU_VERSION=${{ inputs.ubuntu_version }}
PHP_DEBUG="yes"
- name: Build and push API
id: docker_build_nts
uses: docker/build-push-action@v5
Expand All @@ -70,11 +82,12 @@ jobs:
push: true
pull: true
platforms: linux/amd64
target: base
tags: malusevd99/scylladb-php-driver:php-${{ inputs.php }}
target: final
tags: malusevd99/scylladb-php-driver:ubuntu-${{ inputs.ubuntu_version }}-php-${{ inputs.php }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PHP_VERSION=${{ inputs.php }}
PHP_ZTS=${{ inputs.zts }}
UBUNTU_VERSION=${{ inputs.ubuntu_version }}
PHP_DEBUG="yes"
2 changes: 2 additions & 0 deletions .github/workflows/test-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ jobs:
matrix:
tag: ['8.1.29', '8.2.20', '8.3.8']
zts: [yes, no]
ubuntu_version: ['20.04', '22.04', '24.04']
uses: "./.github/workflows/docker-image.yml"
with:
php: ${{ matrix.tag }}
zts: ${{ matrix.zts }}
ubuntu_version: ${{ matrix.ubuntu_version }}
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
16 changes: 6 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,26 @@ jobs:
strategy:
matrix:
php: ['8.1.29', '8.2.20', '8.3.8', '8.1.29-zts', '8.2.20-zts', '8.3.8-zts']
os: ['ubuntu-latest']
os: ['ubuntu-20.04', 'ubuntu-24.04']
preset: ['CICassandra', 'CIScylla']
runs-on: ${{ matrix.os }}
container: malusevd99/scylladb-php-driver:php-${{ matrix.php }}
fail-fast: false
runs-on: ubuntu-latest
container: malusevd99/scylladb-php-driver:${{ matrix.os }}-php-${{ matrix.php }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Run tests
run: |
export PATH="$PATH:/usr/local/bin:/root/php/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/lib/x86_64-linux-gnu:/usr/local/lib/:/usr/lib:/lib:/usr/local/lib/x86_64-linux-gnu"
cmake --preset ${{ matrix.preset }} || exit 1
cd out/${{ matrix.preset }} || exit 1
ninja install || exit 1
cd ../../
PHP_INI=$("php" --ini | grep "php.ini" | awk '{ print $5 }' | xargs -I {} printf '%s/php.ini' {})
cat cassandra.ini >> "$PHP_INI" || exit 1
cat cassandra.ini >> "$(php-config --ini-path | xargs -I {} printf '%s/php.ini' {})" || exit 1
cd tests
php /bin/composer install
composer install
php ./vendor/bin/pest
96 changes: 47 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
cmake_minimum_required(VERSION 3.24)

if (POLICY CMP0074)
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif ()
endif()

if (POLICY CMP0054)
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif ()
endif()

if (POLICY CMP0079)
if(POLICY CMP0079)
cmake_policy(SET CMP0079 NEW)
endif ()
endif()

if (POLICY CMP0108)
if(POLICY CMP0108)
cmake_policy(SET CMP0108 NEW)
endif ()
endif()

if (POLICY CMP0109)
if(POLICY CMP0109)
cmake_policy(SET CMP0109 NEW)
endif ()
endif()

if (POLICY CMP0128)
if(POLICY CMP0128)
cmake_policy(SET CMP0128 NEW)
endif ()

endif()

project(php-ext-scylladb LANGUAGES C CXX)
add_library(ext_scylladb SHARED)

# if build type is not set, default to debug
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Debug")
endif ()
endif()

include(GNUInstallDirs)
include(CheckSymbolExists)
include(CheckIncludeFile)
include(CMakePackageConfigHelpers)
Expand Down Expand Up @@ -65,39 +63,39 @@ set(PHP_VERSION_FOR_PHP_CONFIG "8.3" CACHE STRING "PHP version")
option(PHP_DEBUG_FOR_PHP_CONFIG "Debug or Release" ON)
option(PHP_THREAD_SAFE_FOR_PHP_CONFIG "ZTS(zts) or NTS(nts)" OFF)

if (CMAKE_HOST_APPLE)
if(CMAKE_HOST_APPLE)
option(PHP_SCYLLADB_LIBUV_STATIC "Statically link libuv" ON)
else ()
else()
option(PHP_SCYLLADB_LIBUV_STATIC "Statically link libuv" OFF)
endif ()
endif()

option(PHP_SCYLLADB_LIBUV_FROM_SRC "Build LibUV from Source" ON)

if (CMAKE_HOST_APPLE)
if(CMAKE_HOST_APPLE)
option(PHP_SCYLLADB_LIBSCYLLADB_STATIC "Statically link LibScyllaDB" ON)
else ()
else()
option(PHP_SCYLLADB_LIBSCYLLADB_STATIC "Statically link LibScyllaDB" OFF)
endif ()
endif()

option(PHP_SCYLLADB_USE_LIBCASSANDRA "Use DataStax LibCassandra instead of LibScyllaDB" OFF)

if (CMAKE_HOST_APPLE)
if(CMAKE_HOST_APPLE)
option(PHP_SCYLLADB_LIBCASSANDRA_STATIC "Statically link LibCassandra" ON)
else ()
else()
option(PHP_SCYLLADB_LIBCASSANDRA_STATIC "Statically link LibCassandra" OFF)
endif ()
endif()

find_package(PHPConfig REQUIRED)
find_package(PHP REQUIRED)
find_package(Sanitizers REQUIRED)
find_package(Libuv REQUIRED)
find_package(LibGMP REQUIRED)

if (PHP_SCYLLADB_USE_LIBCASSANDRA)
if(PHP_SCYLLADB_USE_LIBCASSANDRA)
find_package(CassandraDriver REQUIRED)
else ()
else()
find_package(ScyllaDBDriver REQUIRED)
endif ()
endif()

add_subdirectory(ZendCPP)
add_subdirectory(util)
Expand All @@ -120,19 +118,19 @@ target_sources(ext_scylladb PUBLIC FILE_SET headers TYPE HEADERS FILES "${HEADER
target_sources(ext_scylladb PRIVATE php_driver.cpp)

target_link_libraries(
ext_scylladb PRIVATE
Zend
ext_scylladb::src
ext_scylladb::utils
ext_scylladb::type
ext_scylladb::datetime
ext_scylladb::database
ext_scylladb::numbers
ext_scylladb::ssl_options
ext_scylladb::exceptions
ext_scylladb::cluster::builder
ext_scylladb::retry_policy
ext_scylladb::timestamp_generator
ext_scylladb PRIVATE
Zend
ext_scylladb::src
ext_scylladb::utils
ext_scylladb::type
ext_scylladb::datetime
ext_scylladb::database
ext_scylladb::numbers
ext_scylladb::ssl_options
ext_scylladb::exceptions
ext_scylladb::cluster::builder
ext_scylladb::retry_policy
ext_scylladb::timestamp_generator
)

check_include_file("dlfcn.h" HAVE_DLFCN_H)
Expand All @@ -148,17 +146,17 @@ check_include_file("unistd.h" HAVE_UNISTD_H)
set(HAVE_STRINGS_H 0)

configure_file(
config.in
config.h
USE_SOURCE_PERMISSIONS
NEWLINE_STYLE UNIX
config.in
config.h
USE_SOURCE_PERMISSIONS
NEWLINE_STYLE UNIX
)

configure_file(
version.h.in
version.h
USE_SOURCE_PERMISSIONS
NEWLINE_STYLE UNIX
version.h.in
version.h
USE_SOURCE_PERMISSIONS
NEWLINE_STYLE UNIX
)

target_compile_definitions(ext_scylladb PRIVATE -DCOMPILE_DL_CASSANDRA -DHAVE_CONFIG_H)
Expand Down
6 changes: 2 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,10 @@
"binaryDir": "${sourceDir}/out/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithInfo",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"PHP_SCYLLADB_ENABLE_SANITIZERS": "ON",
"SANITIZE_UNDEFINED": "ON",
"SANITIZE_ADDRESS": "ON",
"CUSTOM_PHP_CONFIG": "/root/php/bin/php-config"
"CUSTOM_PHP_CONFIG": "/php/bin/php-config"
}
},
{
Expand All @@ -118,11 +117,10 @@
"binaryDir": "${sourceDir}/out/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithInfo",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"PHP_SCYLLADB_ENABLE_SANITIZERS": "ON",
"SANITIZE_UNDEFINED": "ON",
"SANITIZE_ADDRESS": "ON",
"CUSTOM_PHP_CONFIG": "/root/php/bin/php-config"
"CUSTOM_PHP_CONFIG": "/php/bin/php-config"
}
}
]
Expand Down
1 change: 1 addition & 0 deletions cassandra.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

extension = cassandra

[cassandra]
Expand Down
Loading

0 comments on commit 871d2ed

Please sign in to comment.