mirror of
https://github.com/awslabs/aws-crt-php.git
synced 2026-08-17 17:47:12 +00:00
Initial Tests & CI (#5)
* Added awscrt_version() and test for it * Added builder.json for CI * Added github actions * Added format-check.sh * Force php5.6 on ubuntu * Updated submodules
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
*Issue #, if available:*
|
||||
|
||||
*Description of changes:*
|
||||
|
||||
|
||||
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
|
||||
@@ -0,0 +1,111 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
- '!main'
|
||||
|
||||
env:
|
||||
BUILDER_VERSION: v0.7.7
|
||||
BUILDER_SOURCE: releases
|
||||
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
|
||||
PACKAGE_NAME: aws-crt-php
|
||||
LINUX_BASE_IMAGE: ubuntu-16-x64
|
||||
RUN: ${{ github.run_id }}-${{ github.run_number }}
|
||||
|
||||
jobs:
|
||||
al2:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
|
||||
- name: Build ${{ env.PACKAGE_NAME }} + consumers
|
||||
run: |
|
||||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u awslabs --password-stdin
|
||||
export DOCKER_IMAGE=docker.pkg.github.com/awslabs/aws-crt-builder/aws-crt-al2-x64:${{ env.BUILDER_VERSION }}
|
||||
docker pull $DOCKER_IMAGE
|
||||
docker run --env GITHUB_REF --env LC_ALL=C.UTF-8 $DOCKER_IMAGE --version=${{env.BUILDER_VERSION}} build -p ${{ env.PACKAGE_NAME }} --spec=downstream
|
||||
|
||||
clang-compat:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
version: [3, 6, 8, 9]
|
||||
steps:
|
||||
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
|
||||
- name: Build ${{ env.PACKAGE_NAME }}
|
||||
run: |
|
||||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u awslabs --password-stdin
|
||||
export DOCKER_IMAGE=docker.pkg.github.com/awslabs/aws-crt-builder/aws-crt-${{ env.LINUX_BASE_IMAGE }}:${{ env.BUILDER_VERSION }}
|
||||
docker pull $DOCKER_IMAGE
|
||||
docker run --env GITHUB_REF --env LC_ALL=C.UTF-8 $DOCKER_IMAGE --version=${{env.BUILDER_VERSION}} build -p ${{ env.PACKAGE_NAME }} --spec=downstream --compiler=clang-${{ matrix.version }}
|
||||
|
||||
gcc-compat:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
version: [4.8, 5, 6, 7, 8]
|
||||
fail-fast: false
|
||||
steps:
|
||||
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
|
||||
- name: Build ${{ env.PACKAGE_NAME }}
|
||||
run: |
|
||||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u awslabs --password-stdin
|
||||
export DOCKER_IMAGE=docker.pkg.github.com/awslabs/aws-crt-builder/aws-crt-${{ env.LINUX_BASE_IMAGE }}:${{ env.BUILDER_VERSION }}
|
||||
docker pull $DOCKER_IMAGE
|
||||
docker run --env GITHUB_REF --env LC_ALL=C.UTF-8 $DOCKER_IMAGE --version=${{env.BUILDER_VERSION}} build -p ${{ env.PACKAGE_NAME }} --spec=downstream --compiler=gcc-${{ matrix.version }}
|
||||
|
||||
# linux-arm:
|
||||
# name: ARM (${{ matrix.arch }})
|
||||
# runs-on: ubuntu-latest
|
||||
# strategy:
|
||||
# matrix:
|
||||
# arch: [armv6, armv7, arm64]
|
||||
# steps:
|
||||
# - name: Build ${{ env.PACKAGE_NAME }}
|
||||
# run: |
|
||||
# python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
|
||||
# chmod a+x builder
|
||||
# ./builder build -p ${{ env.PACKAGE_NAME }} --target=linux-${{ matrix.arch }} --spec=downstream
|
||||
|
||||
# windows-vc16:
|
||||
# runs-on: windows-latest
|
||||
# strategy:
|
||||
# matrix:
|
||||
# arch: [x64]
|
||||
# steps:
|
||||
# - uses: ilammy/msvc-dev-cmd@v1
|
||||
# with:
|
||||
# arch: ${{ matrix.arch }}
|
||||
# uwp: false
|
||||
# spectre: true
|
||||
# - name: Build ${{ env.PACKAGE_NAME }} + consumers
|
||||
# run: |
|
||||
# python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
|
||||
# python builder.pyz build -p ${{ env.PACKAGE_NAME }} --spec=downstream
|
||||
|
||||
# windows-vc14:
|
||||
# runs-on: windows-latest
|
||||
# strategy:
|
||||
# matrix:
|
||||
# arch: [x86, x64]
|
||||
# steps:
|
||||
# - uses: ilammy/msvc-dev-cmd@v1
|
||||
# with:
|
||||
# toolset: 14.0
|
||||
# arch: ${{ matrix.arch }}
|
||||
# uwp: false
|
||||
# spectre: true
|
||||
# - name: Build ${{ env.PACKAGE_NAME }} + consumers
|
||||
# run: |
|
||||
# python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
|
||||
# python builder.pyz build -p ${{ env.PACKAGE_NAME }} downstream
|
||||
|
||||
# osx:
|
||||
# runs-on: macos-latest
|
||||
# steps:
|
||||
# - name: Build ${{ env.PACKAGE_NAME }} + consumers
|
||||
# run: |
|
||||
# python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
|
||||
# chmod a+x builder
|
||||
# ./builder build -p ${{ env.PACKAGE_NAME }} --spec=downstream
|
||||
@@ -0,0 +1,18 @@
|
||||
name: Lint
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Sources
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: clang-format lint
|
||||
uses: DoozyX/[email protected]
|
||||
with:
|
||||
# List of extensions to check
|
||||
extensions: c,h
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "aws-crt-php",
|
||||
"hosts": {
|
||||
"ubuntu": {
|
||||
"pkg_setup": [
|
||||
"add-apt-repository -y ppa:ondrej/php"
|
||||
],
|
||||
"packages": [
|
||||
"autotools-dev",
|
||||
"autoconf",
|
||||
"libtool",
|
||||
"clang",
|
||||
"php5.6-dev"
|
||||
]
|
||||
},
|
||||
"al2": {
|
||||
"packages": [
|
||||
"autoconf",
|
||||
"automake",
|
||||
"libtool",
|
||||
"clang",
|
||||
"php-devel"
|
||||
]
|
||||
}
|
||||
},
|
||||
"build_steps": [
|
||||
["phpize"],
|
||||
["./configure"],
|
||||
["make"]
|
||||
],
|
||||
"test_env": {
|
||||
"NO_INTERACTION": "1"
|
||||
},
|
||||
"test_steps": [
|
||||
["make", "test"]
|
||||
]
|
||||
}
|
||||
@@ -10,6 +10,7 @@ if test "$PHP_AWSCRT" != "no"; then
|
||||
cwd=`pwd`
|
||||
CRT_LIBPATHS="-L${cwd}/build/install/lib64 -L${cwd}/build/install/lib"
|
||||
CRT_LIBS="-laws-c-auth -laws-c-http -laws-c-cal -laws-c-io -laws-c-compression -laws-c-common -ls2n -l:libcrypto.a"
|
||||
PHP_ADD_INCLUDE(${cwd}/build/install/include)
|
||||
PHP_EVAL_LIBLINE([$CRT_LIBPATHS $CRT_LIBS], AWSCRT_SHARED_LIBADD)
|
||||
|
||||
# Shoves the linker line into the Makefile
|
||||
|
||||
+1
-1
Submodule crt/aws-c-auth updated: a492570cfd...f58e2028d1
+1
-1
Submodule crt/aws-c-cal updated: df5da3af5b...61d66740b1
+1
-1
Submodule crt/aws-c-common updated: 1efe886005...fe6ff914db
+1
-1
Submodule crt/aws-c-compression updated: 826d92cc39...f2be13afe4
+1
-1
Submodule crt/aws-c-http updated: cad62791f1...3836661844
+1
-1
Submodule crt/aws-c-io updated: 701279844a...3baeef9906
+1
-1
Submodule crt/s2n updated: 2a7cebb0d7...3c7ae5f57a
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ -z $CLANG_FORMAT ]] ; then
|
||||
CLANG_FORMAT=clang-format
|
||||
fi
|
||||
|
||||
if NOT type $CLANG_FORMAT 2> /dev/null ; then
|
||||
echo "No appropriate clang-format found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FAIL=0
|
||||
SOURCE_FILES=`find src -type f \( -name '*.h' -o -name '*.c' \)`
|
||||
for i in $SOURCE_FILES
|
||||
do
|
||||
$CLANG_FORMAT -output-replacements-xml $i | grep -c "<replacement " > /dev/null
|
||||
if [ $? -ne 1 ]
|
||||
then
|
||||
echo "$i failed clang-format check."
|
||||
FAIL=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $FAIL
|
||||
@@ -9,34 +9,45 @@
|
||||
ZEND_DECLARE_MODULE_GLOBALS(awscrt);
|
||||
|
||||
PHP_INI_BEGIN()
|
||||
STD_PHP_INI_ENTRY("awscrt.log_level", "", PHP_INI_ALL, OnUpdateLongGEZero, log_level, zend_awscrt_globals, awscrt_globals)
|
||||
STD_PHP_INI_ENTRY("awscrt.log_level", "", PHP_INI_ALL, OnUpdateLongGEZero,
|
||||
log_level, zend_awscrt_globals, awscrt_globals)
|
||||
PHP_INI_END()
|
||||
|
||||
static PHP_MINIT_FUNCTION(awscrt)
|
||||
{
|
||||
REGISTER_INI_ENTRIES();
|
||||
return SUCCESS;
|
||||
static PHP_MINIT_FUNCTION(awscrt) {
|
||||
REGISTER_INI_ENTRIES();
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static PHP_MSHUTDOWN_FUNCTION(awscrt)
|
||||
{
|
||||
UNREGISTER_INI_ENTRIES();
|
||||
static PHP_MSHUTDOWN_FUNCTION(awscrt) {
|
||||
UNREGISTER_INI_ENTRIES();
|
||||
|
||||
return SUCCESS;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static PHP_GINIT_FUNCTION(awscrt)
|
||||
{
|
||||
static PHP_GINIT_FUNCTION(awscrt) {
|
||||
#if defined(COMPILE_DL_ASTKIT) && defined(ZTS)
|
||||
ZEND_TSRMLS_CACHE_UPDATE();
|
||||
ZEND_TSRMLS_CACHE_UPDATE();
|
||||
#endif
|
||||
awscrt_globals->log_level = 0;
|
||||
awscrt_globals->log_level = 0;
|
||||
}
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(awscrt_version_arginfo, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
PHP_FUNCTION(awscrt_version) {
|
||||
static const char *version = "1.0.0-dev";
|
||||
RETURN_STRING(version, 0);
|
||||
}
|
||||
/* clang-format off */
|
||||
const zend_function_entry awscrt_functions[] = {
|
||||
PHP_FE(awscrt_version, awscrt_version_arginfo)
|
||||
PHP_FE_END
|
||||
};
|
||||
|
||||
zend_module_entry awscrt_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"awscrt",
|
||||
NULL, /* functions */
|
||||
awscrt_functions, /* functions */
|
||||
PHP_MINIT(awscrt),
|
||||
PHP_MSHUTDOWN(awscrt),
|
||||
NULL, /* RINIT */
|
||||
@@ -49,6 +60,8 @@ zend_module_entry awscrt_module_entry = {
|
||||
NULL, /* RPOSTSHUTDOWN */
|
||||
STANDARD_MODULE_PROPERTIES_EX};
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
#ifdef COMPILE_DL_AWSCRT
|
||||
ZEND_GET_MODULE(awscrt)
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Version: Simple function call
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/common.inc');
|
||||
|
||||
echo awscrt_version();
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
1.0.0-dev
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
// Common setup for tests:
|
||||
?>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
extension_loaded('awscrt') or die('awscrt is not available in this build');
|
||||
?>
|
||||
Reference in New Issue
Block a user