From f84d0468edff7e177f0bfbbb2b5f9f849148635d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 16 Feb 2024 12:45:15 +0100 Subject: [PATCH 01/37] add support for Zend Max Exeuction Timers on FreeBSD (#13393) --- Zend/Zend.m4 | 2 +- Zend/zend_max_execution_timer.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index 832045f23e00e..feb2fcc2a63e4 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -306,7 +306,7 @@ AC_ARG_ENABLE([zend-max-execution-timers], [ZEND_MAX_EXECUTION_TIMERS=$enableval], [ZEND_MAX_EXECUTION_TIMERS=$ZEND_ZTS]) -AS_CASE(["$host_alias"], [*linux*], [], [ZEND_MAX_EXECUTION_TIMERS='no']) +AS_CASE(["$host_alias"], [*linux*|*freebsd*], [], [ZEND_MAX_EXECUTION_TIMERS='no']) PHP_CHECK_FUNC(timer_create, rt) if test "$ac_cv_func_timer_create" != "yes"; then diff --git a/Zend/zend_max_execution_timer.c b/Zend/zend_max_execution_timer.c index 48a4d1bd66415..92b70fbb2a6ad 100644 --- a/Zend/zend_max_execution_timer.c +++ b/Zend/zend_max_execution_timer.c @@ -23,6 +23,9 @@ #include #include #include +# ifdef __FreeBSD__ +# include +# endif #include "zend.h" #include "zend_globals.h" @@ -33,6 +36,13 @@ # define sigev_notify_thread_id _sigev_un._tid # endif +// FreeBSD doesn't support CLOCK_BOOTTIME +# ifdef __FreeBSD__ +# define ZEND_MAX_EXECUTION_TIMERS_CLOCK CLOCK_MONOTONIC +# else +# define ZEND_MAX_EXECUTION_TIMERS_CLOCK CLOCK_BOOTTIME +# endif + ZEND_API void zend_max_execution_timer_init(void) /* {{{ */ { pid_t pid = getpid(); @@ -45,10 +55,14 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */ sev.sigev_notify = SIGEV_THREAD_ID; sev.sigev_value.sival_ptr = &EG(max_execution_timer_timer); sev.sigev_signo = SIGRTMIN; +# ifdef __FreeBSD__ + sev.sigev_notify_thread_id = pthread_getthreadid_np(); +# else sev.sigev_notify_thread_id = (pid_t) syscall(SYS_gettid); +# endif // Measure wall time instead of CPU time as originally planned now that it is possible https://github.com/php/php-src/pull/6504#issuecomment-1370303727 - if (timer_create(CLOCK_BOOTTIME, &sev, &EG(max_execution_timer_timer)) != 0) { + if (timer_create(ZEND_MAX_EXECUTION_TIMERS_CLOCK, &sev, &EG(max_execution_timer_timer)) != 0) { zend_strerror_noreturn(E_ERROR, errno, "Could not create timer"); } From 2065829074a5f254f96c4466c1ce41995cbe166f Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Fri, 16 Feb 2024 12:49:20 +0100 Subject: [PATCH 02/37] [ci skip] NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 7e50c4be37f1c..b894a35551d67 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ PHP NEWS array to hashed). (ilutov) . Fixed zend fiber build for solaris default mode (32 bits). (David Carlier) . Fixed zend call stack size for macOs/arm64. (David Carlier) + . Added support for Zend Max Execution Timers on FreeBSD (Kévin Dunglas) - Curl: . Deprecated the CURLOPT_BINARYTRANSFER constant. (divinity76) From 51591ab7c7719efae47c7c13bc1872ae4454a8d9 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Fri, 16 Feb 2024 13:00:42 +0100 Subject: [PATCH 03/37] [ci skip] Adding myself as reviewer --- CODEOWNERS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index dc79939aeae13..69984738e1331 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -37,12 +37,14 @@ /Zend/zend.* @dstogov /Zend/zend_alloc.* @dstogov /Zend/zend_API.* @dstogov +/Zend/zend_call_stack.* @arnaud_lb /Zend/zend_closures.* @dstogov /Zend/zend_execute.* @dstogov /Zend/zend_execute_API.c @dstogov -/Zend/zend_gc.* @dstogov +/Zend/zend_gc.* @dstogov @arnaud_lb /Zend/zend_hash.* @dstogov /Zend/zend_inheritance.* @dstogov +/Zend/zend_max_execution_timer.* @arnaud_lb /Zend/zend_object_handlers.* @dstogov /Zend/zend_objects.* @dstogov /Zend/zend_objects_API.* @dstogov From 9a034c9edbc33cb402893f08855933d374175434 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Fri, 16 Feb 2024 13:02:12 +0100 Subject: [PATCH 04/37] [ci skip] Adding myself as reviewer --- CODEOWNERS | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index 69984738e1331..40ec5651f1c59 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -37,14 +37,14 @@ /Zend/zend.* @dstogov /Zend/zend_alloc.* @dstogov /Zend/zend_API.* @dstogov -/Zend/zend_call_stack.* @arnaud_lb +/Zend/zend_call_stack.* @arnaud-lb /Zend/zend_closures.* @dstogov /Zend/zend_execute.* @dstogov /Zend/zend_execute_API.c @dstogov -/Zend/zend_gc.* @dstogov @arnaud_lb +/Zend/zend_gc.* @dstogov @arnaud-lb /Zend/zend_hash.* @dstogov /Zend/zend_inheritance.* @dstogov -/Zend/zend_max_execution_timer.* @arnaud_lb +/Zend/zend_max_execution_timer.* @arnaud-lb /Zend/zend_object_handlers.* @dstogov /Zend/zend_objects.* @dstogov /Zend/zend_objects_API.* @dstogov From 25923987b5790ae05080b630a165abffdec85d3b Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Fri, 16 Feb 2024 13:29:20 +0100 Subject: [PATCH 05/37] Refactor PHP_SOCKADDR_CHECKS (#13406) Instead of the project macro, the sockaddr_storage and sockaddr.sa_len can be checked with the AC_CHECK_TYPES and AC_CHECK_MEMBERS by including the sys/socket.h. Some systems (~1988) didn't include the sys/types.h in the socket.h (obsolete on current systems). These macros by default define the HAVE_STRUCT_SOCKADDR_STORAGE and HAVE_STRUCT_SOCKADDR_SA_LEN. --- UPGRADING.INTERNALS | 2 ++ build/php.m4 | 25 ------------------------- configure.ac | 3 ++- ext/sockets/multicast.c | 2 +- main/php_network.h | 4 ++-- 5 files changed, 7 insertions(+), 29 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 820705e8b6d2f..bb5e9c10dd098 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -69,6 +69,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES - M4 macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and config.h). - M4 macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH). - M4 macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES). + - M4 macro PHP_SOCKADDR_CHECKS has been removed (use AC_CHECK_TYPES and + AC_CHECK_MEMBERS). c. Windows build system changes - The configure options --with-oci8-11g, --with-oci8-12c, --with-oci8-19 have diff --git a/build/php.m4 b/build/php.m4 index 326c312674dfc..8b915d65aff2e 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -1242,31 +1242,6 @@ AC_DEFUN([PHP_MISSING_TIME_R_DECL],[ AC_MSG_RESULT([done]) ]) -dnl -dnl PHP_SOCKADDR_CHECKS -dnl -AC_DEFUN([PHP_SOCKADDR_CHECKS], [ - dnl Check for struct sockaddr_storage exists. - AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include -#include ]], - [[struct sockaddr_storage s; s]])], - [ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no]) - ]) - if test "$ac_cv_sockaddr_storage" = "yes"; then - AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage]) - fi - dnl Check if field sa_len exists in struct sockaddr. - AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include -#include ]], [[static struct sockaddr sa; int n = (int) sa.sa_len; return n;]])], - [ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no]) - ]) - if test "$ac_cv_sockaddr_sa_len" = "yes"; then - AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len]) - fi -]) - dnl dnl PHP_EBCDIC dnl diff --git a/configure.ac b/configure.ac index 1e74b29669244..f807bf215594a 100644 --- a/configure.ac +++ b/configure.ac @@ -552,7 +552,8 @@ dnl Checks for types. AC_TYPE_UID_T dnl Checks for sockaddr_storage and sockaddr.sa_len. -PHP_SOCKADDR_CHECKS +AC_CHECK_TYPES([struct sockaddr_storage],,,[#include ]) +AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,[#include ]) dnl Checks for GCC function attributes on all systems except ones without glibc dnl Fix for these systems is already included in GCC 7, but not on GCC 6. diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c index 82672e68f2bab..82287cfa1fe49 100644 --- a/ext/sockets/multicast.c +++ b/ext/sockets/multicast.c @@ -790,7 +790,7 @@ zend_result php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, uns struct ifreq cur_req; memcpy(&cur_req, p, sizeof(struct ifreq)); -#ifdef HAVE_SOCKADDR_SA_LEN +#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN entry_len = cur_req.ifr_addr.sa_len + sizeof(cur_req.ifr_name); #else /* if there's no sa_len, assume the ifr_addr field is a sockaddr */ diff --git a/main/php_network.h b/main/php_network.h index 7cc3609c44089..0f155211d8fc7 100644 --- a/main/php_network.h +++ b/main/php_network.h @@ -247,11 +247,11 @@ static inline bool _php_check_fd_setsize(php_socket_t *max_fd, int setsize) #define PHP_SOCK_CHUNK_SIZE 8192 -#ifdef HAVE_SOCKADDR_STORAGE +#ifdef HAVE_STRUCT_SOCKADDR_STORAGE typedef struct sockaddr_storage php_sockaddr_storage; #else typedef struct { -#ifdef HAVE_SOCKADDR_SA_LEN +#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN unsigned char ss_len; unsigned char ss_family; #else From b5c3cbf94b6b64568d962c50dcc589507e86d35b Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Fri, 16 Feb 2024 14:24:55 +0100 Subject: [PATCH 06/37] Check sockaddr_storage.ss_family with AC_CHECK_MEMBERS (#13407) This simplifies the check. On AIX 6 and newer, the ss_family is available, if compiled without defining COMPAT_43 (BSD 4.3 compatibility). --- ext/sockets/config.m4 | 16 ++-------------- ext/sockets/php_sockets.h | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/ext/sockets/config.m4 b/ext/sockets/config.m4 index 398354fdb9a99..d0f630c5502ca 100644 --- a/ext/sockets/config.m4 +++ b/ext/sockets/config.m4 @@ -9,20 +9,8 @@ if test "$PHP_SOCKETS" != "no"; then AC_CHECK_HEADERS([sys/sockio.h linux/filter.h]) AC_DEFINE([HAVE_SOCKETS], 1, [ ]) - dnl Check for fied ss_family in sockaddr_storage (missing in AIX until 5.3) - AC_CACHE_CHECK([for field ss_family in struct sockaddr_storage], ac_cv_ss_family, - [ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include - ]], [[struct sockaddr_storage sa_store; sa_store.ss_family = AF_INET6;]])], - [ac_cv_ss_family=yes], [ac_cv_ss_family=no]) - ]) - - if test "$ac_cv_ss_family" = yes; then - AC_DEFINE(HAVE_SA_SS_FAMILY,1,[Whether you have sockaddr_storage.ss_family]) - fi + dnl Check for field ss_family in sockaddr_storage (missing in AIX until 5.3) + AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family],,,[#include ]) dnl Check for AI_V4MAPPED flag AC_CACHE_CHECK([if getaddrinfo supports AI_V4MAPPED],[ac_cv_gai_ai_v4mapped], diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index 93eba9da0731a..42db7679522ed 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -132,7 +132,7 @@ PHP_SOCKETS_API bool socket_import_file_descriptor(PHP_SOCKET socket, php_socket #define phpext_sockets_ptr NULL #endif -#if defined(_AIX) && !defined(HAVE_SA_SS_FAMILY) +#if defined(_AIX) && !defined(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) # define ss_family __ss_family #endif From eaaffae555ae02949d3e7b1e5b07799cb3332ea3 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Fri, 16 Feb 2024 14:01:03 +0000 Subject: [PATCH 07/37] zend_call_stack sort of GH-13358 follow-up. (#13368) for threaded context, it solely uses a new api only available on illumos. Here using a common older api to get the stack info for the current thread. while at it, completing stack_limit_010 test for these platforms. --- Zend/tests/stack_limit/stack_limit_010.phpt | 1 + Zend/zend_call_stack.c | 37 ++++----------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/Zend/tests/stack_limit/stack_limit_010.phpt b/Zend/tests/stack_limit/stack_limit_010.phpt index 9e37555e6decc..4f8358fb41e71 100644 --- a/Zend/tests/stack_limit/stack_limit_010.phpt +++ b/Zend/tests/stack_limit/stack_limit_010.phpt @@ -27,6 +27,7 @@ $expectedMaxSize = match(php_uname('s')) { 'true' => 16*1024*1024, // https://github.com/actions/runner-images/pull/3328 default => 8*1024*1024, }, + 'SunOS' => 10 * 1024 * 1024, 'Windows NT' => 67108864 - 4*4096, // Set by sapi/cli/config.w32 }; diff --git a/Zend/zend_call_stack.c b/Zend/zend_call_stack.c index a89e9898ee864..ad6c1932553a9 100644 --- a/Zend/zend_call_stack.c +++ b/Zend/zend_call_stack.c @@ -68,6 +68,7 @@ typedef int boolean_t; #include #include #include +#include #endif #ifdef ZEND_CHECK_STACK_LIMIT @@ -664,43 +665,17 @@ static bool zend_call_stack_get_netbsd(zend_call_stack *stack) #endif /* defined(__NetBSD__) */ #if defined(__sun) -# if defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) static bool zend_call_stack_get_solaris_pthread(zend_call_stack *stack) { - pthread_attr_t attr; - int error; - void *addr; - size_t max_size, guard_size; - - error = pthread_attr_get_np(pthread_self(), &attr); - if (error) { - return false; - } - - error = pthread_attr_getstack(&attr, &addr, &max_size); - if (error) { - return false; - } - - error = pthread_attr_getguardsize(&attr, &guard_size); - if (error) { + stack_t s; + if (thr_stksegment(&s) < 0) { return false; } - addr = (char *)addr + guard_size; - max_size -= guard_size; - - stack->base = (char *)addr + max_size; - stack->max_size = max_size; - + stack->max_size = s.ss_size; + stack->base = s.ss_sp; return true; } -# else /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */ -static bool zend_call_stack_get_solaris_pthread(zend_call_stack *stack) -{ - return false; -} -# endif /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */ static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack) { @@ -723,7 +698,7 @@ static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack) } size = (1 << 20); - snprintf(path, sizeof(path), "/proc/%d/map", pid); + snprintf(path, sizeof(path), "/proc/%d/map", (int)pid); if ((fd = open(path, O_RDONLY)) == -1) { Prelease(proc, 0); From e7b1f2a95bf357d95a9f5c64a55e7ac64238ebfe Mon Sep 17 00:00:00 2001 From: Jorg Adam Sowa Date: Fri, 16 Feb 2024 17:11:18 +0100 Subject: [PATCH 08/37] Change long2ip return type (#13395) --- Zend/Optimizer/zend_func_infos.h | 2 +- ext/standard/basic_functions.c | 9 ++++----- ext/standard/basic_functions.stub.php | 2 +- ext/standard/basic_functions_arginfo.h | 4 ++-- ext/standard/tests/network/ip_x86_64.phpt | 4 ++++ 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 16971fc178ea7..d1799ad0de821 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -468,7 +468,7 @@ static const func_info_t func_infos[] = { FN("array_rand", MAY_BE_LONG|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING), F1("base64_encode", MAY_BE_STRING), F1("base64_decode", MAY_BE_STRING|MAY_BE_FALSE), - F1("long2ip", MAY_BE_STRING|MAY_BE_FALSE), + F1("long2ip", MAY_BE_STRING), F1("getenv", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE), F1("getopt", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_FALSE|MAY_BE_FALSE), #if defined(HAVE_NANOSLEEP) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index d62951b63ff26..ed4309818275a 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -643,11 +643,10 @@ PHP_FUNCTION(long2ip) ip = (zend_ulong)sip; myaddr.s_addr = htonl(ip); - if (inet_ntop(AF_INET, &myaddr, str, sizeof(str))) { - RETURN_STRING(str); - } else { - RETURN_FALSE; - } + const char* result = inet_ntop(AF_INET, &myaddr, str, sizeof(str)); + ZEND_ASSERT(result != NULL); + + RETURN_STRING(str); } /* }}} */ diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index ed73d16d6d0b9..899d29ea3b078 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1945,7 +1945,7 @@ function constant(string $name): mixed {} function ip2long(string $ip): int|false {} /** @refcount 1 */ -function long2ip(int $ip): string|false {} +function long2ip(int $ip): string {} /** * @return string|array|false diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 4efdcb54546b6..7a1812d7ca565 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 0bd0ac5d23881670cac81cda3e274cbee1e9a8dc */ + * Stub hash: 1350cc5169dbd48df08513f01c10d5706d47b8d4 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -381,7 +381,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ip2long, 0, 1, MAY_BE_LONG|MAY_B ZEND_ARG_TYPE_INFO(0, ip, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_long2ip, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_long2ip, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, ip, IS_LONG, 0) ZEND_END_ARG_INFO() diff --git a/ext/standard/tests/network/ip_x86_64.phpt b/ext/standard/tests/network/ip_x86_64.phpt index dd81bde55c89b..16e855188aafa 100644 --- a/ext/standard/tests/network/ip_x86_64.phpt +++ b/ext/standard/tests/network/ip_x86_64.phpt @@ -26,6 +26,8 @@ var_dump(ip2long("777.777.777.777")); var_dump(ip2long("111.111.111.111")); var_dump(long2ip(-110000)); +var_dump(long2ip(PHP_INT_MAX)); +var_dump(long2ip(PHP_INT_MIN)); echo "Done\n"; ?> @@ -46,4 +48,6 @@ bool(false) bool(false) int(1869573999) string(13) "255.254.82.80" +string(15) "255.255.255.255" +string(7) "0.0.0.0" Done From 492b9e09e90c4d8b3a0eaf69191b5f7d9ec82387 Mon Sep 17 00:00:00 2001 From: Jorg Adam Sowa Date: Fri, 16 Feb 2024 18:31:21 +0100 Subject: [PATCH 09/37] Add entry on return type of long2ip to NEWS (#13408) [skip ci] add entry on return type of long2ip to NEWS and to UPGRADING. --- NEWS | 1 + UPGRADING | 1 + 2 files changed, 2 insertions(+) diff --git a/NEWS b/NEWS index b894a35551d67..fe4f98f4a6cc5 100644 --- a/NEWS +++ b/NEWS @@ -175,6 +175,7 @@ PHP NEWS . Add support for 4 new rounding modes to the round() function. (Jorg Sowa) . debug_zval_dump() now indicates whether an array is packed. (Max Semenik) . Fix GH-12143 (Optimize round). (SakiTakamachi) + . Changed return type of long2ip to string from string|false. (Jorg Sowa) - XML: . Added XML_OPTION_PARSE_HUGE parser option. (nielsdos) diff --git a/UPGRADING b/UPGRADING index 44594ad40ab61..6f97856999af2 100644 --- a/UPGRADING +++ b/UPGRADING @@ -364,6 +364,7 @@ PHP 8.4 UPGRADE NOTES decimal number and round it to 0.29. However, "pre-rounding" incorrectly rounds certain numbers, so this fix removes "pre-rounding" and changes the way numbers are compared, so that the values ​​are correctly rounded as decimal numbers. + . long2ip() now returns string instead of string|false. ======================================== 6. New Functions From 09415077f933afe93b0645aca100eb5a0bd51812 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Fri, 16 Feb 2024 18:26:08 +0000 Subject: [PATCH 10/37] ext/ldap: few new unit tests (tls13 protocol). (#13409) --- ...dap_set_option_tls_protocol_max_basic.phpt | 3 -- ...t_option_tls_protocol_max_basic_tls13.phpt | 45 +++++++++++++++++++ ...dap_set_option_tls_protocol_min_basic.phpt | 3 -- ...t_option_tls_protocol_min_basic_tls13.phpt | 45 +++++++++++++++++++ 4 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 ext/ldap/tests/ldap_set_option_tls_protocol_max_basic_tls13.phpt create mode 100644 ext/ldap/tests/ldap_set_option_tls_protocol_min_basic_tls13.phpt diff --git a/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic.phpt b/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic.phpt index 7fc24684c8f14..1b4ea8e9a11fd 100644 --- a/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic.phpt +++ b/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic.phpt @@ -15,7 +15,6 @@ foreach([ LDAP_OPT_X_TLS_PROTOCOL_TLS1_0, LDAP_OPT_X_TLS_PROTOCOL_TLS1_1, LDAP_OPT_X_TLS_PROTOCOL_TLS1_2, - LDAP_OPT_X_TLS_PROTOCOL_TLS1_3, ] as $option) { $result = ldap_set_option($link, LDAP_OPT_X_TLS_PROTOCOL_MAX, $option); var_dump($result); @@ -35,5 +34,3 @@ bool(true) int(770) bool(true) int(771) -bool(true) -int(772) diff --git a/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic_tls13.phpt b/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic_tls13.phpt new file mode 100644 index 0000000000000..2f83b807c4a4d --- /dev/null +++ b/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic_tls13.phpt @@ -0,0 +1,45 @@ +--TEST-- +ldap_set_option() - Basic test for TLS protocol max ldap option +--CREDITS-- +Chad Sikorra +--EXTENSIONS-- +ldap +--SKIPIF-- + +--EXPECT-- +bool(true) +int(512) +bool(true) +int(768) +bool(true) +int(769) +bool(true) +int(770) +bool(true) +int(771) +bool(true) +int(772) diff --git a/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt b/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt index 5c4da7368b62d..44abaeb9d9a3b 100644 --- a/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt +++ b/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt @@ -15,7 +15,6 @@ foreach([ LDAP_OPT_X_TLS_PROTOCOL_TLS1_0, LDAP_OPT_X_TLS_PROTOCOL_TLS1_1, LDAP_OPT_X_TLS_PROTOCOL_TLS1_2, - LDAP_OPT_X_TLS_PROTOCOL_TLS1_3, ] as $option) { $result = ldap_set_option($link, LDAP_OPT_X_TLS_PROTOCOL_MIN, $option); var_dump($result); @@ -35,5 +34,3 @@ bool(true) int(770) bool(true) int(771) -bool(true) -int(772) diff --git a/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic_tls13.phpt b/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic_tls13.phpt new file mode 100644 index 0000000000000..e2f2af8763bf0 --- /dev/null +++ b/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic_tls13.phpt @@ -0,0 +1,45 @@ +--TEST-- +ldap_set_option() - Basic test for TLS protocol min ldap option +--CREDITS-- +Chad Sikorra +--EXTENSIONS-- +ldap +--SKIPIF-- + +--EXPECT-- +bool(true) +int(512) +bool(true) +int(768) +bool(true) +int(769) +bool(true) +int(770) +bool(true) +int(771) +bool(true) +int(772) From e0f6fe22ea118015dd59d5c2aad0ec9e35396cbd Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 09:46:42 +0100 Subject: [PATCH 11/37] code formatting ci test --- .github/workflows/push.yml | 61 ++++++++++++++++++++ scripts/dev/format_pull_request.php | 86 +++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 scripts/dev/format_pull_request.php diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 52a323c581488..4f429ae855831 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -314,3 +314,64 @@ jobs: name: profiles path: ${{ github.workspace }}/benchmark/profiles retention-days: 30 + CODE_FORMATTING_CHECK: + name: CODE_FORMATTING_CHECK + if: github.repository_owner == 'php' || github.event_name == 'pull_request' + runs-on: ubuntu + steps: + - name: git checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: apt + run: | + set -x + sudo apt-get update + sudo apt-get install \ + git \ + clang-format \ + php-cli + netcat + - name: check code formatting + run: | + set -x + echo "Checking code formatting" + echo "Generating diff against master" + git fetch origin master + git diff origin/master > ../master.diff + cat ../master.diff + echo 1 check if scripts/dev/format_pull_request.php exists + if [ -f scripts/dev/format_pull_request.php ]; then + echo 1 cp scripts/dev/format_pull_request.php .. + cp scripts/dev/format_pull_request.php .. + else + echo "1 scripts/dev/format_pull_request.php does not exist" + fi + echo "checkout master" + git checkout master + echo 2 check if scripts/dev/format_pull_request.php exists + if [ -f scripts/dev/format_pull_request.php ]; then + echo 2 cp scripts/dev/format_pull_request.php .. + cp scripts/dev/format_pull_request.php .. + else + echo "2 scripts/dev/format_pull_request.php does not exist" + fi + echo "sanity check" + if [ ! -f ../format_pull_request.php ]; then + echo "error: format_pull_request.php does not exist" 1>&2 + exit 1 + fi + echo "run ../format_pull_request.php" + php ../format_pull_request.php ../master.diff > ../formatted.diff + cat ../formatted.diff + echo "check if formatted.diff is empty" + if [ -s ../formatted.diff ]; then + echo "code formatting check succeeded :)" + exit 0 + else + echo "code formatting check failed :(" + patch_url=$(cat ../formatted.diff | nc termbin.com 9999) + echo "Please run" + echo "curl $patch_url | git apply -v" + exit 1 + fi diff --git a/scripts/dev/format_pull_request.php b/scripts/dev/format_pull_request.php new file mode 100644 index 0000000000000..7b2e23e5ceb79 --- /dev/null +++ b/scripts/dev/format_pull_request.php @@ -0,0 +1,86 @@ + 'WebKit', + 'UseTab' => 'ForIndentation', + // clang-format's support for tabs isn't great, and we have to say "4 spaces" to get 1 tab + 'IndentWidth' => 4, + 'TabWidth' => 4, +); +$cmd = array( + 'git diff -U0 --no-color --relative HEAD^ |', + 'clang-format-diff -i -p1 -style=' . escapeshellarg(json_encode($clangFormatOptions)), + '-iregex=' . escapeshellarg('.*\.(c|cc|cpp|c\+\+|cxx|h|hh|hpp|h\+\+|h)$'), +); +$cmd = implode(' ', $cmd); +passthru($cmd, $ret); +if ($ret !== 0) { + fwrite(STDERR, "Error: clang-format-diff failed with exit code {$ret}\n"); + fwrite(STDERR, "cmd:\n{$cmd}\n"); + if (!$force) { + // remove last commit and reset + passthru('git reset --hard HEAD^ --quiet'); + } + exit(1); +} +passthru('git diff'); +if (!$force) { + // remove last commit and reset + passthru('git reset --hard HEAD^ --quiet'); +} From 31af39abf2b54be25acf8f90263993a102f64547 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 09:52:40 +0100 Subject: [PATCH 12/37] run CODE_FORMATTING_CHECK earlier makes it quicker to test this stuff --- .github/workflows/push.yml | 122 ++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4f429ae855831..ed4a6e9b6d55a 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -42,6 +42,67 @@ env: CC: ccache gcc CXX: ccache g++ jobs: + CODE_FORMATTING_CHECK: + name: CODE_FORMATTING_CHECK + if: github.repository_owner == 'php' || github.event_name == 'pull_request' + runs-on: ubuntu + steps: + - name: git checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: apt + run: | + set -x + sudo apt-get update + sudo apt-get install \ + git \ + clang-format \ + php-cli + netcat + - name: check code formatting + run: | + set -x + echo "Checking code formatting" + echo "Generating diff against master" + git fetch origin master + git diff origin/master > ../master.diff + cat ../master.diff + echo 1 check if scripts/dev/format_pull_request.php exists + if [ -f scripts/dev/format_pull_request.php ]; then + echo 1 cp scripts/dev/format_pull_request.php .. + cp scripts/dev/format_pull_request.php .. + else + echo "1 scripts/dev/format_pull_request.php does not exist" + fi + echo "checkout master" + git checkout master + echo 2 check if scripts/dev/format_pull_request.php exists + if [ -f scripts/dev/format_pull_request.php ]; then + echo 2 cp scripts/dev/format_pull_request.php .. + cp scripts/dev/format_pull_request.php .. + else + echo "2 scripts/dev/format_pull_request.php does not exist" + fi + echo "sanity check" + if [ ! -f ../format_pull_request.php ]; then + echo "error: format_pull_request.php does not exist" 1>&2 + exit 1 + fi + echo "run ../format_pull_request.php" + php ../format_pull_request.php ../master.diff > ../formatted.diff + cat ../formatted.diff + echo "check if formatted.diff is empty" + if [ -s ../formatted.diff ]; then + echo "code formatting check succeeded :)" + exit 0 + else + echo "code formatting check failed :(" + patch_url=$(cat ../formatted.diff | nc termbin.com 9999) + echo "Please run" + echo "curl $patch_url | git apply -v" + exit 1 + fi LINUX_X64: if: github.repository_owner == 'php' || github.event_name == 'pull_request' services: @@ -314,64 +375,3 @@ jobs: name: profiles path: ${{ github.workspace }}/benchmark/profiles retention-days: 30 - CODE_FORMATTING_CHECK: - name: CODE_FORMATTING_CHECK - if: github.repository_owner == 'php' || github.event_name == 'pull_request' - runs-on: ubuntu - steps: - - name: git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: apt - run: | - set -x - sudo apt-get update - sudo apt-get install \ - git \ - clang-format \ - php-cli - netcat - - name: check code formatting - run: | - set -x - echo "Checking code formatting" - echo "Generating diff against master" - git fetch origin master - git diff origin/master > ../master.diff - cat ../master.diff - echo 1 check if scripts/dev/format_pull_request.php exists - if [ -f scripts/dev/format_pull_request.php ]; then - echo 1 cp scripts/dev/format_pull_request.php .. - cp scripts/dev/format_pull_request.php .. - else - echo "1 scripts/dev/format_pull_request.php does not exist" - fi - echo "checkout master" - git checkout master - echo 2 check if scripts/dev/format_pull_request.php exists - if [ -f scripts/dev/format_pull_request.php ]; then - echo 2 cp scripts/dev/format_pull_request.php .. - cp scripts/dev/format_pull_request.php .. - else - echo "2 scripts/dev/format_pull_request.php does not exist" - fi - echo "sanity check" - if [ ! -f ../format_pull_request.php ]; then - echo "error: format_pull_request.php does not exist" 1>&2 - exit 1 - fi - echo "run ../format_pull_request.php" - php ../format_pull_request.php ../master.diff > ../formatted.diff - cat ../formatted.diff - echo "check if formatted.diff is empty" - if [ -s ../formatted.diff ]; then - echo "code formatting check succeeded :)" - exit 0 - else - echo "code formatting check failed :(" - patch_url=$(cat ../formatted.diff | nc termbin.com 9999) - echo "Please run" - echo "curl $patch_url | git apply -v" - exit 1 - fi From 08489ed1fd61cb03034f71713cd9b211857c9631 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 10:32:35 +0100 Subject: [PATCH 13/37] temporarily disable the others --- .github/workflows/push.yml | 546 ++++++++++++++++++------------------- 1 file changed, 273 insertions(+), 273 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ed4a6e9b6d55a..163179b208ce6 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -45,7 +45,7 @@ jobs: CODE_FORMATTING_CHECK: name: CODE_FORMATTING_CHECK if: github.repository_owner == 'php' || github.event_name == 'pull_request' - runs-on: ubuntu + runs-on: ubuntu-latest steps: - name: git checkout uses: actions/checkout@v4 @@ -103,275 +103,275 @@ jobs: echo "curl $patch_url | git apply -v" exit 1 fi - LINUX_X64: - if: github.repository_owner == 'php' || github.event_name == 'pull_request' - services: - mysql: - image: mysql:8 - ports: - - 3306:3306 - env: - MYSQL_DATABASE: test - MYSQL_ROOT_PASSWORD: root - postgres: - image: postgres - ports: - - 5432:5432 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: test - firebird: - image: jacobalberty/firebird - ports: - - 3050:3050 - env: - ISC_PASSWORD: test - FIREBIRD_DATABASE: test.fdb - FIREBIRD_USER: test - FIREBIRD_PASSWORD: test - strategy: - fail-fast: false - matrix: - include: - - debug: false - zts: false - asan: false - - debug: true - zts: true - asan: true - name: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}" - runs-on: ubuntu-22.04 - steps: - - name: git checkout - uses: actions/checkout@v4 - - name: apt - uses: ./.github/actions/apt-x64 - - name: LLVM 16 (ASAN-only) - if: ${{ matrix.asan }} - run: | - wget https://apt.llvm.org/llvm.sh - chmod u+x llvm.sh - sudo ./llvm.sh 16 - - name: System info - run: | - echo "::group::Show host CPU info" - lscpu - echo "::endgroup::" - echo "::group::Show installed package versions" - dpkg -l - echo "::endgroup::" - - name: Create MSSQL container - if: ${{ !matrix.asan }} - uses: ./.github/actions/setup-mssql - - name: Setup Caddy server - uses: ./.github/actions/setup-caddy - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - # This duplicates the "job.name" expression above because - # GitHub has no way to query the job name (github.job is the - # job id, not the job name) - key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}" - append-timestamp: false - - name: ./configure - uses: ./.github/actions/configure-x64 - with: - configurationParameters: >- - --${{ matrix.debug && 'enable' || 'disable' }}-debug - --${{ matrix.zts && 'enable' || 'disable' }}-zts - ${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -fno-sanitize=pointer-overflow -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address -fno-sanitize=pointer-overflow" CC=clang-16 CXX=clang++-16' || '' }} - skipSlow: ${{ matrix.asan }} - - name: make - run: make -j$(/usr/bin/nproc) >/dev/null - - name: make install - uses: ./.github/actions/install-linux - - name: Setup - if: ${{ !matrix.asan }} - uses: ./.github/actions/setup-x64 - - name: Test - if: matrix.asan == false - uses: ./.github/actions/test-linux - with: - testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} - - name: Test Tracing JIT - uses: ./.github/actions/test-linux - with: - testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}_Tracing JIT - jitType: tracing - runTestsParameters: >- - -d zend_extension=opcache.so - -d opcache.enable_cli=1 - ${{ matrix.asan && '--asan -x' || '' }} - - name: Verify generated files are up to date - if: ${{ !matrix.asan }} - uses: ./.github/actions/verify-generated-files - MACOS_DEBUG_NTS: - if: github.repository_owner == 'php' || github.event_name == 'pull_request' - strategy: - fail-fast: false - matrix: - include: - - os: 13 - arch: X64 - - os: 14 - arch: ARM64 - name: MACOS_${{ matrix.arch }}_DEBUG_NTS - runs-on: macos-${{ matrix.os }} - steps: - - name: git checkout - uses: actions/checkout@v4 - - name: brew - uses: ./.github/actions/brew - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: "${{github.job}}-${{matrix.os}}-${{hashFiles('main/php_version.h')}}" - append-timestamp: false - - name: ./configure - uses: ./.github/actions/configure-macos - with: - configurationParameters: --enable-debug --disable-zts - - name: make - run: |- - export PATH="$(brew --prefix)/opt/bison/bin:$PATH" - make -j$(sysctl -n hw.logicalcpu) >/dev/null - - name: make install - run: sudo make install - - name: Test Tracing JIT - uses: ./.github/actions/test-macos - with: - testArtifacts: ${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} Tracing JIT - jitType: tracing - runTestsParameters: >- - -d zend_extension=opcache.so - -d opcache.enable_cli=1 - - name: Verify generated files are up to date - uses: ./.github/actions/verify-generated-files - WINDOWS: - if: github.repository_owner == 'php' || github.event_name == 'pull_request' - name: WINDOWS_X64_ZTS - runs-on: windows-2019 - env: - PHP_BUILD_CACHE_BASE_DIR: C:\build-cache - PHP_BUILD_OBJ_DIR: C:\obj - PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk - PHP_BUILD_SDK_BRANCH: php_downloads_server_migration_v1 - PHP_BUILD_CRT: vs16 - PLATFORM: x64 - THREAD_SAFE: "1" - INTRINSICS: AVX2 - PARALLEL: -j2 - OPCACHE: "1" - steps: - - name: git config - run: git config --global core.autocrlf false && git config --global core.eol lf - - name: git checkout - uses: actions/checkout@v4 - - name: Setup - uses: ./.github/actions/setup-windows - - name: Build - run: .github/scripts/windows/build.bat - - name: Test - run: .github/scripts/windows/test.bat - BENCHMARKING: - name: BENCHMARKING - if: github.repository_owner == 'php' || github.event_name == 'pull_request' - runs-on: ubuntu-22.04 - steps: - - name: git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: apt - run: | - set -x - sudo apt-get update - sudo apt-get install \ - bison \ - libgmp-dev \ - libonig-dev \ - libsqlite3-dev \ - openssl \ - re2c \ - valgrind - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: "${{github.job}}-${{hashFiles('main/php_version.h')}}" - append-timestamp: false - - name: ./configure - run: | - set -x - ./buildconf --force - ./configure \ - --disable-debug \ - --enable-mbstring \ - --enable-opcache \ - --enable-option-checking=fatal \ - --enable-sockets \ - --enable-werror \ - --prefix=/usr \ - --with-config-file-scan-dir=/etc/php.d \ - --with-gmp \ - --with-mysqli=mysqlnd \ - --with-openssl \ - --with-pdo-sqlite \ - --with-valgrind - - name: make - run: make -j$(/usr/bin/nproc) >/dev/null - - name: make install - run: | - set -x - sudo make install - sudo mkdir -p /etc/php.d - sudo chmod 777 /etc/php.d - echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini - echo zend_extension=opcache.so >> /etc/php.d/opcache.ini - echo opcache.enable=1 >> /etc/php.d/opcache.ini - echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini - - name: Setup - run: | - git config --global user.name "Benchmark" - git config --global user.email "benchmark@php.net" - sudo service mysql start - mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress" - mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;" - mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;" - - name: git checkout benchmarking-data - uses: actions/checkout@v4 - with: - repository: php/benchmarking-data - ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }} - path: benchmark/repos/data - - name: Benchmark - run: php benchmark/benchmark.php true - - name: Store result - if: github.event_name == 'push' - run: | - set -x - cd benchmark/repos/data - git pull --autostash - if [ -e ".git/MERGE_HEAD" ]; then - echo "Merging, can't proceed" - exit 1 - fi - git add . - if git diff --cached --quiet; then - exit 0 - fi - git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}" - git push - - name: Show diff - if: github.event_name == 'pull_request' - run: |- - set -x - php benchmark/generate_diff.php \ - ${{ github.sha }} \ - $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \ - > $GITHUB_STEP_SUMMARY - - uses: actions/upload-artifact@v4 - with: - name: profiles - path: ${{ github.workspace }}/benchmark/profiles - retention-days: 30 + # LINUX_X64: + # if: github.repository_owner == 'php' || github.event_name == 'pull_request' + # services: + # mysql: + # image: mysql:8 + # ports: + # - 3306:3306 + # env: + # MYSQL_DATABASE: test + # MYSQL_ROOT_PASSWORD: root + # postgres: + # image: postgres + # ports: + # - 5432:5432 + # env: + # POSTGRES_USER: postgres + # POSTGRES_PASSWORD: postgres + # POSTGRES_DB: test + # firebird: + # image: jacobalberty/firebird + # ports: + # - 3050:3050 + # env: + # ISC_PASSWORD: test + # FIREBIRD_DATABASE: test.fdb + # FIREBIRD_USER: test + # FIREBIRD_PASSWORD: test + # strategy: + # fail-fast: false + # matrix: + # include: + # - debug: false + # zts: false + # asan: false + # - debug: true + # zts: true + # asan: true + # name: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}" + # runs-on: ubuntu-22.04 + # steps: + # - name: git checkout + # uses: actions/checkout@v4 + # - name: apt + # uses: ./.github/actions/apt-x64 + # - name: LLVM 16 (ASAN-only) + # if: ${{ matrix.asan }} + # run: | + # wget https://apt.llvm.org/llvm.sh + # chmod u+x llvm.sh + # sudo ./llvm.sh 16 + # - name: System info + # run: | + # echo "::group::Show host CPU info" + # lscpu + # echo "::endgroup::" + # echo "::group::Show installed package versions" + # dpkg -l + # echo "::endgroup::" + # - name: Create MSSQL container + # if: ${{ !matrix.asan }} + # uses: ./.github/actions/setup-mssql + # - name: Setup Caddy server + # uses: ./.github/actions/setup-caddy + # - name: ccache + # uses: hendrikmuhs/ccache-action@v1.2 + # with: + # # This duplicates the "job.name" expression above because + # # GitHub has no way to query the job name (github.job is the + # # job id, not the job name) + # key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}" + # append-timestamp: false + # - name: ./configure + # uses: ./.github/actions/configure-x64 + # with: + # configurationParameters: >- + # --${{ matrix.debug && 'enable' || 'disable' }}-debug + # --${{ matrix.zts && 'enable' || 'disable' }}-zts + # ${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -fno-sanitize=pointer-overflow -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address -fno-sanitize=pointer-overflow" CC=clang-16 CXX=clang++-16' || '' }} + # skipSlow: ${{ matrix.asan }} + # - name: make + # run: make -j$(/usr/bin/nproc) >/dev/null + # - name: make install + # uses: ./.github/actions/install-linux + # - name: Setup + # if: ${{ !matrix.asan }} + # uses: ./.github/actions/setup-x64 + # - name: Test + # if: matrix.asan == false + # uses: ./.github/actions/test-linux + # with: + # testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} + # - name: Test Tracing JIT + # uses: ./.github/actions/test-linux + # with: + # testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}_Tracing JIT + # jitType: tracing + # runTestsParameters: >- + # -d zend_extension=opcache.so + # -d opcache.enable_cli=1 + # ${{ matrix.asan && '--asan -x' || '' }} + # - name: Verify generated files are up to date + # if: ${{ !matrix.asan }} + # uses: ./.github/actions/verify-generated-files + # MACOS_DEBUG_NTS: + # if: github.repository_owner == 'php' || github.event_name == 'pull_request' + # strategy: + # fail-fast: false + # matrix: + # include: + # - os: 13 + # arch: X64 + # - os: 14 + # arch: ARM64 + # name: MACOS_${{ matrix.arch }}_DEBUG_NTS + # runs-on: macos-${{ matrix.os }} + # steps: + # - name: git checkout + # uses: actions/checkout@v4 + # - name: brew + # uses: ./.github/actions/brew + # - name: ccache + # uses: hendrikmuhs/ccache-action@v1.2 + # with: + # key: "${{github.job}}-${{matrix.os}}-${{hashFiles('main/php_version.h')}}" + # append-timestamp: false + # - name: ./configure + # uses: ./.github/actions/configure-macos + # with: + # configurationParameters: --enable-debug --disable-zts + # - name: make + # run: |- + # export PATH="$(brew --prefix)/opt/bison/bin:$PATH" + # make -j$(sysctl -n hw.logicalcpu) >/dev/null + # - name: make install + # run: sudo make install + # - name: Test Tracing JIT + # uses: ./.github/actions/test-macos + # with: + # testArtifacts: ${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} Tracing JIT + # jitType: tracing + # runTestsParameters: >- + # -d zend_extension=opcache.so + # -d opcache.enable_cli=1 + # - name: Verify generated files are up to date + # uses: ./.github/actions/verify-generated-files + # WINDOWS: + # if: github.repository_owner == 'php' || github.event_name == 'pull_request' + # name: WINDOWS_X64_ZTS + # runs-on: windows-2019 + # env: + # PHP_BUILD_CACHE_BASE_DIR: C:\build-cache + # PHP_BUILD_OBJ_DIR: C:\obj + # PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk + # PHP_BUILD_SDK_BRANCH: php_downloads_server_migration_v1 + # PHP_BUILD_CRT: vs16 + # PLATFORM: x64 + # THREAD_SAFE: "1" + # INTRINSICS: AVX2 + # PARALLEL: -j2 + # OPCACHE: "1" + # steps: + # - name: git config + # run: git config --global core.autocrlf false && git config --global core.eol lf + # - name: git checkout + # uses: actions/checkout@v4 + # - name: Setup + # uses: ./.github/actions/setup-windows + # - name: Build + # run: .github/scripts/windows/build.bat + # - name: Test + # run: .github/scripts/windows/test.bat + # BENCHMARKING: + # name: BENCHMARKING + # if: github.repository_owner == 'php' || github.event_name == 'pull_request' + # runs-on: ubuntu-22.04 + # steps: + # - name: git checkout + # uses: actions/checkout@v4 + # with: + # fetch-depth: 0 + # - name: apt + # run: | + # set -x + # sudo apt-get update + # sudo apt-get install \ + # bison \ + # libgmp-dev \ + # libonig-dev \ + # libsqlite3-dev \ + # openssl \ + # re2c \ + # valgrind + # - name: ccache + # uses: hendrikmuhs/ccache-action@v1.2 + # with: + # key: "${{github.job}}-${{hashFiles('main/php_version.h')}}" + # append-timestamp: false + # - name: ./configure + # run: | + # set -x + # ./buildconf --force + # ./configure \ + # --disable-debug \ + # --enable-mbstring \ + # --enable-opcache \ + # --enable-option-checking=fatal \ + # --enable-sockets \ + # --enable-werror \ + # --prefix=/usr \ + # --with-config-file-scan-dir=/etc/php.d \ + # --with-gmp \ + # --with-mysqli=mysqlnd \ + # --with-openssl \ + # --with-pdo-sqlite \ + # --with-valgrind + # - name: make + # run: make -j$(/usr/bin/nproc) >/dev/null + # - name: make install + # run: | + # set -x + # sudo make install + # sudo mkdir -p /etc/php.d + # sudo chmod 777 /etc/php.d + # echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini + # echo zend_extension=opcache.so >> /etc/php.d/opcache.ini + # echo opcache.enable=1 >> /etc/php.d/opcache.ini + # echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini + # - name: Setup + # run: | + # git config --global user.name "Benchmark" + # git config --global user.email "benchmark@php.net" + # sudo service mysql start + # mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress" + # mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;" + # mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;" + # - name: git checkout benchmarking-data + # uses: actions/checkout@v4 + # with: + # repository: php/benchmarking-data + # ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }} + # path: benchmark/repos/data + # - name: Benchmark + # run: php benchmark/benchmark.php true + # - name: Store result + # if: github.event_name == 'push' + # run: | + # set -x + # cd benchmark/repos/data + # git pull --autostash + # if [ -e ".git/MERGE_HEAD" ]; then + # echo "Merging, can't proceed" + # exit 1 + # fi + # git add . + # if git diff --cached --quiet; then + # exit 0 + # fi + # git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}" + # git push + # - name: Show diff + # if: github.event_name == 'pull_request' + # run: |- + # set -x + # php benchmark/generate_diff.php \ + # ${{ github.sha }} \ + # $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \ + # > $GITHUB_STEP_SUMMARY + # - uses: actions/upload-artifact@v4 + # with: + # name: profiles + # path: ${{ github.workspace }}/benchmark/profiles + # retention-days: 30 From d13ed770c98cf6d3abc1fd3e909879bb2909e24b Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 10:35:36 +0100 Subject: [PATCH 14/37] netcat --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 163179b208ce6..9a6168b48d334 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -59,7 +59,7 @@ jobs: git \ clang-format \ php-cli - netcat + netcat-openbsd - name: check code formatting run: | set -x From 58131f14593c628849e62df907361056980d6ef1 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 10:38:57 +0100 Subject: [PATCH 15/37] oops --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9a6168b48d334..3a5eaad493d9d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -58,7 +58,7 @@ jobs: sudo apt-get install \ git \ clang-format \ - php-cli + php-cli \ netcat-openbsd - name: check code formatting run: | From bd6f7c9c2ffabf2808bc45a784a8fe08d98ddff9 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 10:42:15 +0100 Subject: [PATCH 16/37] test --- .github/workflows/push.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 3a5eaad493d9d..155c01ad7c6ae 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -89,6 +89,8 @@ jobs: echo "error: format_pull_request.php does not exist" 1>&2 exit 1 fi + echo git diff.. + git diff echo "run ../format_pull_request.php" php ../format_pull_request.php ../master.diff > ../formatted.diff cat ../formatted.diff From 9d57114622e61f11a3547c7c8e4c9c27ffe22d9d Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 10:44:55 +0100 Subject: [PATCH 17/37] test --- .github/workflows/push.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 155c01ad7c6ae..7db0b0bfc4c1b 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -89,6 +89,10 @@ jobs: echo "error: format_pull_request.php does not exist" 1>&2 exit 1 fi + echo find + find + echo pwd + pwd echo git diff.. git diff echo "run ../format_pull_request.php" From 913529c530394473cac928bc44d0c035883c9936 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 10:49:13 +0100 Subject: [PATCH 18/37] test --- .github/workflows/push.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 7db0b0bfc4c1b..4199d2898f981 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -89,12 +89,12 @@ jobs: echo "error: format_pull_request.php does not exist" 1>&2 exit 1 fi - echo find - find + echo find | head + find | head echo pwd pwd - echo git diff.. - git diff + echo git diff | head + git diff | head echo "run ../format_pull_request.php" php ../format_pull_request.php ../master.diff > ../formatted.diff cat ../formatted.diff From f9d5b910e2e15dacf6ff5a4c40d4d0519c02b0a9 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 10:51:33 +0100 Subject: [PATCH 19/37] test --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4199d2898f981..3dabe6e0f2282 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -67,7 +67,7 @@ jobs: echo "Generating diff against master" git fetch origin master git diff origin/master > ../master.diff - cat ../master.diff + cat ../master.diff | head echo 1 check if scripts/dev/format_pull_request.php exists if [ -f scripts/dev/format_pull_request.php ]; then echo 1 cp scripts/dev/format_pull_request.php .. From 9b68cdf05f589aa6c6936d6dace0a8449ad57912 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 10:57:19 +0100 Subject: [PATCH 20/37] test --- scripts/dev/format_pull_request.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/dev/format_pull_request.php b/scripts/dev/format_pull_request.php index 7b2e23e5ceb79..c368004c7f169 100644 --- a/scripts/dev/format_pull_request.php +++ b/scripts/dev/format_pull_request.php @@ -21,7 +21,12 @@ fwrite(STDERR, ob_get_clean()); exit(1); } -chdir(__DIR__ . '/../../'); // php-src root +// check if we're already in php-src +if (is_dir("Zend")) { + // we're in the root of the php-src +} else { + chdir(__DIR__ . '/../../'); // php-src root +} if (!$force) { $gitStatus = null; system('git diff --quiet --exit-code', $gitStatus); From 0bb20e880b1b49ff18f090a2096232227aa6a3e2 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:01:27 +0100 Subject: [PATCH 21/37] test --- scripts/dev/format_pull_request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dev/format_pull_request.php b/scripts/dev/format_pull_request.php index c368004c7f169..6fad3d7d0f128 100644 --- a/scripts/dev/format_pull_request.php +++ b/scripts/dev/format_pull_request.php @@ -51,7 +51,7 @@ exit(1); } // commit -passthru('git commit -a --message=clangformat --quiet', $ret); +passthru('git commit -a --message=clangformat --author='.escapeshellarg('clangformat ').' --quiet', $ret); if ($ret !== 0) { fwrite(STDERR, "Error: git commit failed with exit code {$ret}\n"); if (!$force) { From 4c39f74c97b54890ef4349a388100d4e45a542c0 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:06:16 +0100 Subject: [PATCH 22/37] test --- scripts/dev/format_pull_request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dev/format_pull_request.php b/scripts/dev/format_pull_request.php index 6fad3d7d0f128..f7f062fceb5e7 100644 --- a/scripts/dev/format_pull_request.php +++ b/scripts/dev/format_pull_request.php @@ -51,7 +51,7 @@ exit(1); } // commit -passthru('git commit -a --message=clangformat --author='.escapeshellarg('clangformat ').' --quiet', $ret); +passthru('git -c user.email="clangformat@example.com" -c user.name=clangformat commit -a --message=clangformat --quiet', $ret); if ($ret !== 0) { fwrite(STDERR, "Error: git commit failed with exit code {$ret}\n"); if (!$force) { From 9fdb233591f0734603b5dbc125f44520a28eb864 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:11:33 +0100 Subject: [PATCH 23/37] test --- .github/workflows/push.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 3dabe6e0f2282..acf20c237608b 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -100,14 +100,14 @@ jobs: cat ../formatted.diff echo "check if formatted.diff is empty" if [ -s ../formatted.diff ]; then - echo "code formatting check succeeded :)" - exit 0 - else echo "code formatting check failed :(" patch_url=$(cat ../formatted.diff | nc termbin.com 9999) echo "Please run" echo "curl $patch_url | git apply -v" exit 1 + else + echo "code formatting check succeeded :)" + exit 0 fi # LINUX_X64: # if: github.repository_owner == 'php' || github.event_name == 'pull_request' From c669b522c611e25eca24478e5b6d4e2fa05ac493 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:15:17 +0100 Subject: [PATCH 24/37] test --- .github/workflows/push.yml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index acf20c237608b..9887310fd6fe1 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -64,41 +64,21 @@ jobs: run: | set -x echo "Checking code formatting" - echo "Generating diff against master" git fetch origin master git diff origin/master > ../master.diff cat ../master.diff | head - echo 1 check if scripts/dev/format_pull_request.php exists if [ -f scripts/dev/format_pull_request.php ]; then - echo 1 cp scripts/dev/format_pull_request.php .. cp scripts/dev/format_pull_request.php .. - else - echo "1 scripts/dev/format_pull_request.php does not exist" fi - echo "checkout master" git checkout master - echo 2 check if scripts/dev/format_pull_request.php exists if [ -f scripts/dev/format_pull_request.php ]; then - echo 2 cp scripts/dev/format_pull_request.php .. cp scripts/dev/format_pull_request.php .. - else - echo "2 scripts/dev/format_pull_request.php does not exist" fi - echo "sanity check" if [ ! -f ../format_pull_request.php ]; then echo "error: format_pull_request.php does not exist" 1>&2 exit 1 fi - echo find | head - find | head - echo pwd - pwd - echo git diff | head - git diff | head - echo "run ../format_pull_request.php" php ../format_pull_request.php ../master.diff > ../formatted.diff - cat ../formatted.diff - echo "check if formatted.diff is empty" if [ -s ../formatted.diff ]; then echo "code formatting check failed :(" patch_url=$(cat ../formatted.diff | nc termbin.com 9999) From d60308181c9336f2e71d3b6763a466c51b312c87 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:17:38 +0100 Subject: [PATCH 25/37] test --- .github/workflows/push.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9887310fd6fe1..e31a28396f67b 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -63,10 +63,8 @@ jobs: - name: check code formatting run: | set -x - echo "Checking code formatting" git fetch origin master git diff origin/master > ../master.diff - cat ../master.diff | head if [ -f scripts/dev/format_pull_request.php ]; then cp scripts/dev/format_pull_request.php .. fi From 6e85ec5f9f436ffc9164fc8a210d6d2a85559a77 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:20:36 +0100 Subject: [PATCH 26/37] test --- test.c | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.c diff --git a/test.c b/test.c new file mode 100644 index 0000000000000..dbbd85ecccc5d --- /dev/null +++ b/test.c @@ -0,0 +1 @@ +int main(){} \ No newline at end of file From 76015e92980766aed84a9d3a69a49409856a1d3f Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:22:57 +0100 Subject: [PATCH 27/37] test --- test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test.c b/test.c index dbbd85ecccc5d..6df39be994b49 100644 --- a/test.c +++ b/test.c @@ -1 +1,5 @@ -int main(){} \ No newline at end of file +#include + +int main(){ + printf("Hello, World!\n");return 0; +} \ No newline at end of file From 7e6fa98c3de9a4483bc6c1599a7cba05d40239db Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:26:26 +0100 Subject: [PATCH 28/37] test --- .github/workflows/push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index e31a28396f67b..a5c84f6ee164c 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -77,6 +77,7 @@ jobs: exit 1 fi php ../format_pull_request.php ../master.diff > ../formatted.diff + cat ../formatted.diff if [ -s ../formatted.diff ]; then echo "code formatting check failed :(" patch_url=$(cat ../formatted.diff | nc termbin.com 9999) From a5ef74adf6813a2600b4a3185c7046c6c2310917 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:30:18 +0100 Subject: [PATCH 29/37] test --- .github/workflows/push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index a5c84f6ee164c..74a555ff2b16f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -78,6 +78,7 @@ jobs: fi php ../format_pull_request.php ../master.diff > ../formatted.diff cat ../formatted.diff + cat ../master.diff if [ -s ../formatted.diff ]; then echo "code formatting check failed :(" patch_url=$(cat ../formatted.diff | nc termbin.com 9999) From 5a77f1dfbf05ee82939eebd0f82e294fc4ee449d Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:38:30 +0100 Subject: [PATCH 30/37] test --- .github/workflows/push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 74a555ff2b16f..4468091f5d581 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -76,6 +76,7 @@ jobs: echo "error: format_pull_request.php does not exist" 1>&2 exit 1 fi + git reset --hard origin/master php ../format_pull_request.php ../master.diff > ../formatted.diff cat ../formatted.diff cat ../master.diff From f7f15b029a71e8b3d4d52e0d9f0b1303300c1729 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:51:28 +0100 Subject: [PATCH 31/37] test --- scripts/dev/format_pull_request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dev/format_pull_request.php b/scripts/dev/format_pull_request.php index f7f062fceb5e7..fd8cac7e068d6 100644 --- a/scripts/dev/format_pull_request.php +++ b/scripts/dev/format_pull_request.php @@ -50,7 +50,7 @@ } exit(1); } -// commit +passthru('git add .'); passthru('git -c user.email="clangformat@example.com" -c user.name=clangformat commit -a --message=clangformat --quiet', $ret); if ($ret !== 0) { fwrite(STDERR, "Error: git commit failed with exit code {$ret}\n"); From ea989544787e85ac2befcff02c2247131c787d1d Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:53:37 +0100 Subject: [PATCH 32/37] test --- .github/workflows/push.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4468091f5d581..f9c1a99787a2f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -78,8 +78,6 @@ jobs: fi git reset --hard origin/master php ../format_pull_request.php ../master.diff > ../formatted.diff - cat ../formatted.diff - cat ../master.diff if [ -s ../formatted.diff ]; then echo "code formatting check failed :(" patch_url=$(cat ../formatted.diff | nc termbin.com 9999) From 930cd107bbea2dc8869fedaf56b9ba9251c43786 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:56:03 +0100 Subject: [PATCH 33/37] test --- .github/workflows/push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index f9c1a99787a2f..156ad73762182 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -79,6 +79,7 @@ jobs: git reset --hard origin/master php ../format_pull_request.php ../master.diff > ../formatted.diff if [ -s ../formatted.diff ]; then + cat ../formatted.diff echo "code formatting check failed :(" patch_url=$(cat ../formatted.diff | nc termbin.com 9999) echo "Please run" From df5d0793f0a7570978db66fe544968eca440c56c Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Sat, 17 Feb 2024 11:59:36 +0100 Subject: [PATCH 34/37] it works :D re-enable CIs --- .github/workflows/push.yml | 544 ++++++++++++++++++------------------- test.c | 5 - 2 files changed, 272 insertions(+), 277 deletions(-) delete mode 100644 test.c diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 156ad73762182..d7feb113d6eb0 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -89,275 +89,275 @@ jobs: echo "code formatting check succeeded :)" exit 0 fi - # LINUX_X64: - # if: github.repository_owner == 'php' || github.event_name == 'pull_request' - # services: - # mysql: - # image: mysql:8 - # ports: - # - 3306:3306 - # env: - # MYSQL_DATABASE: test - # MYSQL_ROOT_PASSWORD: root - # postgres: - # image: postgres - # ports: - # - 5432:5432 - # env: - # POSTGRES_USER: postgres - # POSTGRES_PASSWORD: postgres - # POSTGRES_DB: test - # firebird: - # image: jacobalberty/firebird - # ports: - # - 3050:3050 - # env: - # ISC_PASSWORD: test - # FIREBIRD_DATABASE: test.fdb - # FIREBIRD_USER: test - # FIREBIRD_PASSWORD: test - # strategy: - # fail-fast: false - # matrix: - # include: - # - debug: false - # zts: false - # asan: false - # - debug: true - # zts: true - # asan: true - # name: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}" - # runs-on: ubuntu-22.04 - # steps: - # - name: git checkout - # uses: actions/checkout@v4 - # - name: apt - # uses: ./.github/actions/apt-x64 - # - name: LLVM 16 (ASAN-only) - # if: ${{ matrix.asan }} - # run: | - # wget https://apt.llvm.org/llvm.sh - # chmod u+x llvm.sh - # sudo ./llvm.sh 16 - # - name: System info - # run: | - # echo "::group::Show host CPU info" - # lscpu - # echo "::endgroup::" - # echo "::group::Show installed package versions" - # dpkg -l - # echo "::endgroup::" - # - name: Create MSSQL container - # if: ${{ !matrix.asan }} - # uses: ./.github/actions/setup-mssql - # - name: Setup Caddy server - # uses: ./.github/actions/setup-caddy - # - name: ccache - # uses: hendrikmuhs/ccache-action@v1.2 - # with: - # # This duplicates the "job.name" expression above because - # # GitHub has no way to query the job name (github.job is the - # # job id, not the job name) - # key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}" - # append-timestamp: false - # - name: ./configure - # uses: ./.github/actions/configure-x64 - # with: - # configurationParameters: >- - # --${{ matrix.debug && 'enable' || 'disable' }}-debug - # --${{ matrix.zts && 'enable' || 'disable' }}-zts - # ${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -fno-sanitize=pointer-overflow -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address -fno-sanitize=pointer-overflow" CC=clang-16 CXX=clang++-16' || '' }} - # skipSlow: ${{ matrix.asan }} - # - name: make - # run: make -j$(/usr/bin/nproc) >/dev/null - # - name: make install - # uses: ./.github/actions/install-linux - # - name: Setup - # if: ${{ !matrix.asan }} - # uses: ./.github/actions/setup-x64 - # - name: Test - # if: matrix.asan == false - # uses: ./.github/actions/test-linux - # with: - # testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} - # - name: Test Tracing JIT - # uses: ./.github/actions/test-linux - # with: - # testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}_Tracing JIT - # jitType: tracing - # runTestsParameters: >- - # -d zend_extension=opcache.so - # -d opcache.enable_cli=1 - # ${{ matrix.asan && '--asan -x' || '' }} - # - name: Verify generated files are up to date - # if: ${{ !matrix.asan }} - # uses: ./.github/actions/verify-generated-files - # MACOS_DEBUG_NTS: - # if: github.repository_owner == 'php' || github.event_name == 'pull_request' - # strategy: - # fail-fast: false - # matrix: - # include: - # - os: 13 - # arch: X64 - # - os: 14 - # arch: ARM64 - # name: MACOS_${{ matrix.arch }}_DEBUG_NTS - # runs-on: macos-${{ matrix.os }} - # steps: - # - name: git checkout - # uses: actions/checkout@v4 - # - name: brew - # uses: ./.github/actions/brew - # - name: ccache - # uses: hendrikmuhs/ccache-action@v1.2 - # with: - # key: "${{github.job}}-${{matrix.os}}-${{hashFiles('main/php_version.h')}}" - # append-timestamp: false - # - name: ./configure - # uses: ./.github/actions/configure-macos - # with: - # configurationParameters: --enable-debug --disable-zts - # - name: make - # run: |- - # export PATH="$(brew --prefix)/opt/bison/bin:$PATH" - # make -j$(sysctl -n hw.logicalcpu) >/dev/null - # - name: make install - # run: sudo make install - # - name: Test Tracing JIT - # uses: ./.github/actions/test-macos - # with: - # testArtifacts: ${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} Tracing JIT - # jitType: tracing - # runTestsParameters: >- - # -d zend_extension=opcache.so - # -d opcache.enable_cli=1 - # - name: Verify generated files are up to date - # uses: ./.github/actions/verify-generated-files - # WINDOWS: - # if: github.repository_owner == 'php' || github.event_name == 'pull_request' - # name: WINDOWS_X64_ZTS - # runs-on: windows-2019 - # env: - # PHP_BUILD_CACHE_BASE_DIR: C:\build-cache - # PHP_BUILD_OBJ_DIR: C:\obj - # PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk - # PHP_BUILD_SDK_BRANCH: php_downloads_server_migration_v1 - # PHP_BUILD_CRT: vs16 - # PLATFORM: x64 - # THREAD_SAFE: "1" - # INTRINSICS: AVX2 - # PARALLEL: -j2 - # OPCACHE: "1" - # steps: - # - name: git config - # run: git config --global core.autocrlf false && git config --global core.eol lf - # - name: git checkout - # uses: actions/checkout@v4 - # - name: Setup - # uses: ./.github/actions/setup-windows - # - name: Build - # run: .github/scripts/windows/build.bat - # - name: Test - # run: .github/scripts/windows/test.bat - # BENCHMARKING: - # name: BENCHMARKING - # if: github.repository_owner == 'php' || github.event_name == 'pull_request' - # runs-on: ubuntu-22.04 - # steps: - # - name: git checkout - # uses: actions/checkout@v4 - # with: - # fetch-depth: 0 - # - name: apt - # run: | - # set -x - # sudo apt-get update - # sudo apt-get install \ - # bison \ - # libgmp-dev \ - # libonig-dev \ - # libsqlite3-dev \ - # openssl \ - # re2c \ - # valgrind - # - name: ccache - # uses: hendrikmuhs/ccache-action@v1.2 - # with: - # key: "${{github.job}}-${{hashFiles('main/php_version.h')}}" - # append-timestamp: false - # - name: ./configure - # run: | - # set -x - # ./buildconf --force - # ./configure \ - # --disable-debug \ - # --enable-mbstring \ - # --enable-opcache \ - # --enable-option-checking=fatal \ - # --enable-sockets \ - # --enable-werror \ - # --prefix=/usr \ - # --with-config-file-scan-dir=/etc/php.d \ - # --with-gmp \ - # --with-mysqli=mysqlnd \ - # --with-openssl \ - # --with-pdo-sqlite \ - # --with-valgrind - # - name: make - # run: make -j$(/usr/bin/nproc) >/dev/null - # - name: make install - # run: | - # set -x - # sudo make install - # sudo mkdir -p /etc/php.d - # sudo chmod 777 /etc/php.d - # echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini - # echo zend_extension=opcache.so >> /etc/php.d/opcache.ini - # echo opcache.enable=1 >> /etc/php.d/opcache.ini - # echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini - # - name: Setup - # run: | - # git config --global user.name "Benchmark" - # git config --global user.email "benchmark@php.net" - # sudo service mysql start - # mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress" - # mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;" - # mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;" - # - name: git checkout benchmarking-data - # uses: actions/checkout@v4 - # with: - # repository: php/benchmarking-data - # ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }} - # path: benchmark/repos/data - # - name: Benchmark - # run: php benchmark/benchmark.php true - # - name: Store result - # if: github.event_name == 'push' - # run: | - # set -x - # cd benchmark/repos/data - # git pull --autostash - # if [ -e ".git/MERGE_HEAD" ]; then - # echo "Merging, can't proceed" - # exit 1 - # fi - # git add . - # if git diff --cached --quiet; then - # exit 0 - # fi - # git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}" - # git push - # - name: Show diff - # if: github.event_name == 'pull_request' - # run: |- - # set -x - # php benchmark/generate_diff.php \ - # ${{ github.sha }} \ - # $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \ - # > $GITHUB_STEP_SUMMARY - # - uses: actions/upload-artifact@v4 - # with: - # name: profiles - # path: ${{ github.workspace }}/benchmark/profiles - # retention-days: 30 + LINUX_X64: + if: github.repository_owner == 'php' || github.event_name == 'pull_request' + services: + mysql: + image: mysql:8 + ports: + - 3306:3306 + env: + MYSQL_DATABASE: test + MYSQL_ROOT_PASSWORD: root + postgres: + image: postgres + ports: + - 5432:5432 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: test + firebird: + image: jacobalberty/firebird + ports: + - 3050:3050 + env: + ISC_PASSWORD: test + FIREBIRD_DATABASE: test.fdb + FIREBIRD_USER: test + FIREBIRD_PASSWORD: test + strategy: + fail-fast: false + matrix: + include: + - debug: false + zts: false + asan: false + - debug: true + zts: true + asan: true + name: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}" + runs-on: ubuntu-22.04 + steps: + - name: git checkout + uses: actions/checkout@v4 + - name: apt + uses: ./.github/actions/apt-x64 + - name: LLVM 16 (ASAN-only) + if: ${{ matrix.asan }} + run: | + wget https://apt.llvm.org/llvm.sh + chmod u+x llvm.sh + sudo ./llvm.sh 16 + - name: System info + run: | + echo "::group::Show host CPU info" + lscpu + echo "::endgroup::" + echo "::group::Show installed package versions" + dpkg -l + echo "::endgroup::" + - name: Create MSSQL container + if: ${{ !matrix.asan }} + uses: ./.github/actions/setup-mssql + - name: Setup Caddy server + uses: ./.github/actions/setup-caddy + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + # This duplicates the "job.name" expression above because + # GitHub has no way to query the job name (github.job is the + # job id, not the job name) + key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}" + append-timestamp: false + - name: ./configure + uses: ./.github/actions/configure-x64 + with: + configurationParameters: >- + --${{ matrix.debug && 'enable' || 'disable' }}-debug + --${{ matrix.zts && 'enable' || 'disable' }}-zts + ${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -fno-sanitize=pointer-overflow -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address -fno-sanitize=pointer-overflow" CC=clang-16 CXX=clang++-16' || '' }} + skipSlow: ${{ matrix.asan }} + - name: make + run: make -j$(/usr/bin/nproc) >/dev/null + - name: make install + uses: ./.github/actions/install-linux + - name: Setup + if: ${{ !matrix.asan }} + uses: ./.github/actions/setup-x64 + - name: Test + if: matrix.asan == false + uses: ./.github/actions/test-linux + with: + testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} + - name: Test Tracing JIT + uses: ./.github/actions/test-linux + with: + testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}_Tracing JIT + jitType: tracing + runTestsParameters: >- + -d zend_extension=opcache.so + -d opcache.enable_cli=1 + ${{ matrix.asan && '--asan -x' || '' }} + - name: Verify generated files are up to date + if: ${{ !matrix.asan }} + uses: ./.github/actions/verify-generated-files + MACOS_DEBUG_NTS: + if: github.repository_owner == 'php' || github.event_name == 'pull_request' + strategy: + fail-fast: false + matrix: + include: + - os: 13 + arch: X64 + - os: 14 + arch: ARM64 + name: MACOS_${{ matrix.arch }}_DEBUG_NTS + runs-on: macos-${{ matrix.os }} + steps: + - name: git checkout + uses: actions/checkout@v4 + - name: brew + uses: ./.github/actions/brew + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: "${{github.job}}-${{matrix.os}}-${{hashFiles('main/php_version.h')}}" + append-timestamp: false + - name: ./configure + uses: ./.github/actions/configure-macos + with: + configurationParameters: --enable-debug --disable-zts + - name: make + run: |- + export PATH="$(brew --prefix)/opt/bison/bin:$PATH" + make -j$(sysctl -n hw.logicalcpu) >/dev/null + - name: make install + run: sudo make install + - name: Test Tracing JIT + uses: ./.github/actions/test-macos + with: + testArtifacts: ${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} Tracing JIT + jitType: tracing + runTestsParameters: >- + -d zend_extension=opcache.so + -d opcache.enable_cli=1 + - name: Verify generated files are up to date + uses: ./.github/actions/verify-generated-files + WINDOWS: + if: github.repository_owner == 'php' || github.event_name == 'pull_request' + name: WINDOWS_X64_ZTS + runs-on: windows-2019 + env: + PHP_BUILD_CACHE_BASE_DIR: C:\build-cache + PHP_BUILD_OBJ_DIR: C:\obj + PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk + PHP_BUILD_SDK_BRANCH: php_downloads_server_migration_v1 + PHP_BUILD_CRT: vs16 + PLATFORM: x64 + THREAD_SAFE: "1" + INTRINSICS: AVX2 + PARALLEL: -j2 + OPCACHE: "1" + steps: + - name: git config + run: git config --global core.autocrlf false && git config --global core.eol lf + - name: git checkout + uses: actions/checkout@v4 + - name: Setup + uses: ./.github/actions/setup-windows + - name: Build + run: .github/scripts/windows/build.bat + - name: Test + run: .github/scripts/windows/test.bat + BENCHMARKING: + name: BENCHMARKING + if: github.repository_owner == 'php' || github.event_name == 'pull_request' + runs-on: ubuntu-22.04 + steps: + - name: git checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: apt + run: | + set -x + sudo apt-get update + sudo apt-get install \ + bison \ + libgmp-dev \ + libonig-dev \ + libsqlite3-dev \ + openssl \ + re2c \ + valgrind + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: "${{github.job}}-${{hashFiles('main/php_version.h')}}" + append-timestamp: false + - name: ./configure + run: | + set -x + ./buildconf --force + ./configure \ + --disable-debug \ + --enable-mbstring \ + --enable-opcache \ + --enable-option-checking=fatal \ + --enable-sockets \ + --enable-werror \ + --prefix=/usr \ + --with-config-file-scan-dir=/etc/php.d \ + --with-gmp \ + --with-mysqli=mysqlnd \ + --with-openssl \ + --with-pdo-sqlite \ + --with-valgrind + - name: make + run: make -j$(/usr/bin/nproc) >/dev/null + - name: make install + run: | + set -x + sudo make install + sudo mkdir -p /etc/php.d + sudo chmod 777 /etc/php.d + echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini + echo zend_extension=opcache.so >> /etc/php.d/opcache.ini + echo opcache.enable=1 >> /etc/php.d/opcache.ini + echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini + - name: Setup + run: | + git config --global user.name "Benchmark" + git config --global user.email "benchmark@php.net" + sudo service mysql start + mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress" + mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;" + mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;" + - name: git checkout benchmarking-data + uses: actions/checkout@v4 + with: + repository: php/benchmarking-data + ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }} + path: benchmark/repos/data + - name: Benchmark + run: php benchmark/benchmark.php true + - name: Store result + if: github.event_name == 'push' + run: | + set -x + cd benchmark/repos/data + git pull --autostash + if [ -e ".git/MERGE_HEAD" ]; then + echo "Merging, can't proceed" + exit 1 + fi + git add . + if git diff --cached --quiet; then + exit 0 + fi + git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}" + git push + - name: Show diff + if: github.event_name == 'pull_request' + run: |- + set -x + php benchmark/generate_diff.php \ + ${{ github.sha }} \ + $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \ + > $GITHUB_STEP_SUMMARY + - uses: actions/upload-artifact@v4 + with: + name: profiles + path: ${{ github.workspace }}/benchmark/profiles + retention-days: 30 diff --git a/test.c b/test.c deleted file mode 100644 index 6df39be994b49..0000000000000 --- a/test.c +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main(){ - printf("Hello, World!\n");return 0; -} \ No newline at end of file From 84b6e2525c5016e1453b9261a5081895b200eb72 Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Sat, 17 Feb 2024 19:20:27 +0700 Subject: [PATCH 35/37] Add style CI --- .github/workflows/push.yml | 47 ------------------ .github/workflows/styling.yml | 93 +++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/styling.yml diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index d7feb113d6eb0..52a323c581488 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -42,53 +42,6 @@ env: CC: ccache gcc CXX: ccache g++ jobs: - CODE_FORMATTING_CHECK: - name: CODE_FORMATTING_CHECK - if: github.repository_owner == 'php' || github.event_name == 'pull_request' - runs-on: ubuntu-latest - steps: - - name: git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: apt - run: | - set -x - sudo apt-get update - sudo apt-get install \ - git \ - clang-format \ - php-cli \ - netcat-openbsd - - name: check code formatting - run: | - set -x - git fetch origin master - git diff origin/master > ../master.diff - if [ -f scripts/dev/format_pull_request.php ]; then - cp scripts/dev/format_pull_request.php .. - fi - git checkout master - if [ -f scripts/dev/format_pull_request.php ]; then - cp scripts/dev/format_pull_request.php .. - fi - if [ ! -f ../format_pull_request.php ]; then - echo "error: format_pull_request.php does not exist" 1>&2 - exit 1 - fi - git reset --hard origin/master - php ../format_pull_request.php ../master.diff > ../formatted.diff - if [ -s ../formatted.diff ]; then - cat ../formatted.diff - echo "code formatting check failed :(" - patch_url=$(cat ../formatted.diff | nc termbin.com 9999) - echo "Please run" - echo "curl $patch_url | git apply -v" - exit 1 - else - echo "code formatting check succeeded :)" - exit 0 - fi LINUX_X64: if: github.repository_owner == 'php' || github.event_name == 'pull_request' services: diff --git a/.github/workflows/styling.yml b/.github/workflows/styling.yml new file mode 100644 index 0000000000000..4c53bd081716f --- /dev/null +++ b/.github/workflows/styling.yml @@ -0,0 +1,93 @@ +name: Code Styling Check +on: + push: + paths-ignore: + - docs/* + - NEWS + - UPGRADING + - UPGRADING.INTERNALS + - '**/README.*' + - CONTRIBUTING.md + - CODING_STANDARDS.md + - .cirrus.yml + - .travis.yml + - travis/* + - .circleci/* + branches: + - PHP-8.1 + - PHP-8.2 + - PHP-8.3 + - master + pull_request: + paths-ignore: + - docs/* + - NEWS + - UPGRADING + - UPGRADING.INTERNALS + - '**/README.*' + - CONTRIBUTING.md + - CODING_STANDARDS.md + - .cirrus.yml + - .travis.yml + - travis/* + - .circleci/* + branches: + - '**' +permissions: + contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.url || github.run_id }} + cancel-in-progress: true +jobs: + CODE_FORMATTING_CHECK: + name: CODE_FORMATTING_CHECK +# if: github.repository_owner == 'php' || github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: git checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: apt + run: | + set -x + sudo apt-get update + sudo apt-get install \ + git \ + clang-format \ + php-cli \ + netcat-openbsd + - name: check code formatting + run: | + set -x + git fetch origin master + git diff origin/master > ../master.diff + if [ -f scripts/dev/format_pull_request.php ]; then + cp scripts/dev/format_pull_request.php .. + fi + git checkout master + if [ -f scripts/dev/format_pull_request.php ]; then + cp scripts/dev/format_pull_request.php .. + fi + if [ ! -f ../format_pull_request.php ]; then + echo "error: format_pull_request.php does not exist" 1>&2 + exit 1 + fi + git reset --hard origin/master + php ../format_pull_request.php ../master.diff > ../formatted.diff + if [ -s ../formatted.diff ]; then + cat ../formatted.diff + echo "code formatting check failed :(" + patch_url=$(cat ../formatted.diff | nc termbin.com 9999) + echo "Please run" + echo "curl $patch_url | git apply -v" + exit 1 + else + echo "code formatting check succeeded :)" + exit 0 + fi + - name: 'Upload artifacts' + uses: actions/upload-artifact@v4 + with: + name: 'format.patch' + path: ../formatted.diff From c47e1e83f742ff8e3f94525efc6cc8a27667d265 Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Sat, 17 Feb 2024 19:22:12 +0700 Subject: [PATCH 36/37] t --- .github/workflows/styling.yml | 43 ++++++++--------------------- scripts/dev/format_pull_request.php | 4 +-- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/.github/workflows/styling.yml b/.github/workflows/styling.yml index 4c53bd081716f..67f89dbebd359 100644 --- a/.github/workflows/styling.yml +++ b/.github/workflows/styling.yml @@ -40,15 +40,15 @@ concurrency: cancel-in-progress: true jobs: CODE_FORMATTING_CHECK: - name: CODE_FORMATTING_CHECK + name: Code formatting check # if: github.repository_owner == 'php' || github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - - name: git checkout + - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - - name: apt + - name: Install packages run: | set -x sudo apt-get update @@ -57,37 +57,18 @@ jobs: clang-format \ php-cli \ netcat-openbsd - - name: check code formatting + - name: Check code formatting run: | set -x - git fetch origin master - git diff origin/master > ../master.diff - if [ -f scripts/dev/format_pull_request.php ]; then - cp scripts/dev/format_pull_request.php .. - fi - git checkout master - if [ -f scripts/dev/format_pull_request.php ]; then - cp scripts/dev/format_pull_request.php .. - fi - if [ ! -f ../format_pull_request.php ]; then - echo "error: format_pull_request.php does not exist" 1>&2 - exit 1 - fi - git reset --hard origin/master - php ../format_pull_request.php ../master.diff > ../formatted.diff - if [ -s ../formatted.diff ]; then - cat ../formatted.diff - echo "code formatting check failed :(" - patch_url=$(cat ../formatted.diff | nc termbin.com 9999) - echo "Please run" - echo "curl $patch_url | git apply -v" - exit 1 - else - echo "code formatting check succeeded :)" - exit 0 - fi + echo "foobar" > format.patch - name: 'Upload artifacts' uses: actions/upload-artifact@v4 with: name: 'format.patch' - path: ../formatted.diff + path: format.patch + if-no-files-found: ignore + - name: 'Show summary' + run: | + echo 'Artifact ID is ${{ steps.artifact-upload-step.outputs.artifact-id }}' + echo 'Artifact ID is ${{ steps.artifact-upload-step.outputs.artifact-url }}' + cat 'Run curl ${{ steps.artifact-upload-step.outputs.artifact-url }} | git patch apply' > $GITHUB_STEP_SUMMARY diff --git a/scripts/dev/format_pull_request.php b/scripts/dev/format_pull_request.php index fd8cac7e068d6..6d3d74043e9fa 100644 --- a/scripts/dev/format_pull_request.php +++ b/scripts/dev/format_pull_request.php @@ -14,12 +14,12 @@ $argv = array_values($argv); $argc = count($argv); } -if ($argc !== 2) { +if ($argc !== 2 || in_array('--help', $argv, true)) { ob_start(); echo "Usage: php {$argv[0]} [diff-uri]\n"; echo "example:\nphp {$argv[0]} " . escapeshellarg('https://github.com/php/php-src/pull/13401.diff') . "\n"; fwrite(STDERR, ob_get_clean()); - exit(1); + exit(in_array('--help', $argv, true) === true ? 0 : 1); } // check if we're already in php-src if (is_dir("Zend")) { From bcac384e67a323fb958042195b50617f8f98e52b Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Sat, 17 Feb 2024 20:23:46 +0700 Subject: [PATCH 37/37] WIP --- .github/workflows/styling.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/styling.yml b/.github/workflows/styling.yml index 67f89dbebd359..9fb65a5fb30e1 100644 --- a/.github/workflows/styling.yml +++ b/.github/workflows/styling.yml @@ -63,6 +63,7 @@ jobs: echo "foobar" > format.patch - name: 'Upload artifacts' uses: actions/upload-artifact@v4 + id: artifact-upload-step with: name: 'format.patch' path: format.patch @@ -70,5 +71,5 @@ jobs: - name: 'Show summary' run: | echo 'Artifact ID is ${{ steps.artifact-upload-step.outputs.artifact-id }}' - echo 'Artifact ID is ${{ steps.artifact-upload-step.outputs.artifact-url }}' + echo 'Artifact URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}' cat 'Run curl ${{ steps.artifact-upload-step.outputs.artifact-url }} | git patch apply' > $GITHUB_STEP_SUMMARY