Skip to content

Commit

Permalink
feature(ci): better docker image building
Browse files Browse the repository at this point in the history
1. creating image with debug and release versions of php
2. docker image tags do not contain full php version, just major and minor
3. removing #define in version.h.in for brevitty

Signed-off-by: Dusan Malusev <[email protected]>
  • Loading branch information
CodeLieutenant committed Aug 12, 2024
1 parent b4f9164 commit a2149f3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 41 deletions.
47 changes: 21 additions & 26 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ on:
type: string
description: "PHP Version"
required: true
debug:
type: string
description: "PHP Debug -> Options [yes, no]"
required: false
zts:
type: string
description: "ZTS (Zend Thread Safety)"
description: "ZTS (Zend Thread Safety) -> Options [yes, no]"
required: true
ubuntu_version:
type: string
description: "Ubuntu Version"
description: "Ubuntu Version -> Options [20.04, 22.04, 24.04]"
required: false
default: "24.04"
secrets:
Expand All @@ -52,42 +56,33 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push API
id: docker_build_zts
uses: docker/build-push-action@v5
if: ${{ inputs.zts == 'yes' }}
with:
file: ./docker/Dockerfile
context: .
push: true
pull: true
platforms: linux/amd64
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: Extract PHP Version and ZTS
id: version
run: |
export PHP_VERSION="$(echo ${{ inputs.php }} | grep -oP '^\d+\.\d+')"
PHP_ENDING="php-$PHP_VERSION"
[[ ${{ inputs.zts }} == "yes" ]] && PHP_ENDING="$PHP_ENDING-zts"
[[ ${{ inputs.debug }} == "yes" ]] && PHP_ENDING="$PHP_ENDING-debug"
echo "php_ending=$PHP_ENDING" >> $GITHUB_ENV
- name: Build and push API
id: docker_build_nts
id: docker_build
uses: docker/build-push-action@v5
if: ${{ inputs.zts == 'no' }}
with:
file: ./docker/Dockerfile
context: .
push: true
pull: true
platforms: linux/amd64
target: final
tags: malusevd99/scylladb-php-driver:ubuntu-${{ inputs.ubuntu_version }}-php-${{ inputs.php }}
tags: malusevd99/scylladb-php-driver:ubuntu-${{ inputs.ubuntu_version }}-${{ steps.version.outputs.php }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
UBUNTU_VERSION=${{ inputs.ubuntu_version }}
PHP_VERSION=${{ inputs.php }}
PHP_ZTS=${{ inputs.zts }}
UBUNTU_VERSION=${{ inputs.ubuntu_version }}
PHP_DEBUG="yes"
PHP_DEBUG=${{ inputs.debug }}
PHP_MEM_SANITIZERS=${{ inputs.debug }}
4 changes: 3 additions & 1 deletion .github/workflows/test-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ jobs:
strategy:
matrix:
tag: ["8.1.29", "8.2.20", "8.3.8"]
zts: [yes, no]
zts: ['yes', 'no']
debug: ['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 }}
debug: ${{ matrix.debug }}
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ include(cmake/CPM.cmake)
include(cmake/TargetOptimizations.cmake)
include(cmake/ScyllaDBPHPLibrary.cmake)

set(PHP_SCYLLADB_VERSION_MAJOR 1)
set(PHP_SCYLLADB_VERSION_MINOR 3)
set(PHP_SCYLLADB_VERSION_PATCH 12)
set(PHP_SCYLLADB_STABILITY "devel")
set(PHP_SCYLLADB_VERSION_FULL "${PHP_SCYLLADB_VERSION_MAJOR}.${PHP_SCYLLADB_VERSION_MINOR}.${PHP_SCYLLADB_VERSION_PATCH}-${PHP_SCYLLADB_STABILITY}")
set(PHP_SCYLLADB_VERSION "${PHP_SCYLLADB_VERSION_MAJOR}.${PHP_SCYLLADB_VERSION_MINOR}.${PHP_SCYLLADB_VERSION_PATCH}-dev")
set(PHP_SCYLLADB_VERSION "1.4.0-dev")

set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
Expand Down
3 changes: 1 addition & 2 deletions src/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ void php_driver_define_Core() {
zend_declare_class_constant_string(php_driver_core_ce, ZEND_STRL("TYPE_INET"),
"inet");

zend_declare_class_constant_string(php_driver_core_ce, ZEND_STRL("VERSION"),
PHP_DRIVER_VERSION_FULL);
zend_declare_class_constant_string(php_driver_core_ce, ZEND_STRL("VERSION"), PHP_DRIVER_VERSION);

snprintf(buf, sizeof(buf), "%d.%d.%d%s", CASS_VERSION_MAJOR,
CASS_VERSION_MINOR, CASS_VERSION_PATCH,
Expand Down
7 changes: 1 addition & 6 deletions version.h.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#pragma once

#define PHP_DRIVER_NAME "cassandra"
#define PHP_DRIVER_MAJOR @PHP_SCYLLADB_VERSION_MAJOR@
#define PHP_DRIVER_MINOR @PHP_SCYLLADB_VERSION_MINOR@
#define PHP_DRIVER_RELEASE @PHP_SCYLLADB_VERSION_PATCH@
#define PHP_DRIVER_STABILITY "@PHP_SCYLLADB_STABILITY@"
#define PHP_DRIVER_VERSION "@PHP_SCYLLADB_VERSION@"
#define PHP_DRIVER_VERSION_FULL "@PHP_SCYLLADB_VERSION_FULL@"
#define PHP_DRIVER_VERSION "@PHP_SCYLLADB_VERSION@"

0 comments on commit a2149f3

Please sign in to comment.