forked from amphp/ext-uv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(test): setup running tests with cmake and IDE (#2)
feature(test): setup running tests with cmake and IDE Signed-off-by: Dusan Malusev <dusan@dusanmalusev.dev>
- Loading branch information
1 parent
d4c934e
commit cc6eaa8
Showing
16 changed files
with
530 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
Language: Cpp | ||
BasedOnStyle: LLVM | ||
AccessModifierOffset: -4 | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignOperands: false | ||
AlignTrailingComments: false | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BraceWrapping: | ||
AfterCaseLabel: true | ||
AfterClass: true | ||
AfterControlStatement: true | ||
AfterEnum: true | ||
AfterFunction: true | ||
AfterNamespace: false | ||
AfterStruct: true | ||
AfterUnion: true | ||
AfterExternBlock: false | ||
BeforeCatch: true | ||
BeforeElse: true | ||
BeforeLambdaBody: true | ||
BeforeWhile: true | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakBeforeBraces: Custom | ||
BreakConstructorInitializers: AfterColon | ||
BreakConstructorInitializersBeforeComma: false | ||
ColumnLimit: 120 | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
IncludeCategories: | ||
- Regex: '^<.*' | ||
Priority: 1 | ||
- Regex: '^".*' | ||
Priority: 2 | ||
- Regex: '.*' | ||
Priority: 3 | ||
IncludeIsMainRegex: '([-_](test|unittest))?$' | ||
IndentCaseBlocks: true | ||
IndentWidth: 4 | ||
InsertNewlineAtEOF: true | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 2 | ||
NamespaceIndentation: All | ||
SpaceInEmptyParentheses: false | ||
SpacesInAngles: false | ||
SpacesInConditionalStatement: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
TabWidth: 4 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Compile UV extension | ||
description: Compile UV extension | ||
|
||
inputs: | ||
sanitizer: | ||
required: false | ||
description: "ASAN or MSAN" | ||
default: '' | ||
debug: | ||
required: false | ||
description: "Enable debug" | ||
default: 'yes' | ||
static_libuv: | ||
required: false | ||
default: 'no' | ||
description: "Link against static libuv" | ||
libuv_pkgconfig: | ||
required: true | ||
description: "PkgConfig path for Libuv" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Compile uv extension | ||
shell: bash | ||
run: | | ||
export PKG_CONFIG_PATH="$(pkg-config --variable pc_path pkg-config):${{ inputs.libuv_pkgconfig }}" | ||
phpize | ||
./configure \ | ||
${{ inputs.debug == 'yes' && '--enable-debug' || '' }} \ | ||
${{ inputs.sanitizer == 'asan' && '--enable-asan' || '' }} \ | ||
${{ inputs.sanitizer == 'msan' && '--enable-msan' || '' }} \ | ||
${{ inputs.static_libuv == 'yes' && '--enable-libuv-static' || '' }} \ | ||
--enable-ext-testing | ||
make -j$(getconf _NPROCESSORS_ONLN) | ||
sudo make install | ||
env: | ||
CFLAGS: -DZEND_TRACK_ARENA_ALLOC | ||
CC: clang | ||
USE_ZEND_ALLOC: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Install Libuv | ||
description: Install Libuv | ||
|
||
inputs: | ||
version: | ||
required: false | ||
default: "1.48.0" | ||
description: "Libuv version" | ||
sanitizer: | ||
required: false | ||
description: "ASAN or MSAN" | ||
default: '' | ||
|
||
outputs: | ||
install_dir: | ||
value: ${{ steps.values.outputs.install_dir }} | ||
description: "Libuv Install Dir" | ||
pkg_config_path: | ||
value: ${{ steps.values.outputs.pkg_config_path }} | ||
description: "Libuv PkgConfig script path" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Cache Libuv | ||
id: cache-libuv | ||
uses: actions/cache@v4 | ||
with: | ||
path: /opt/libuv | ||
key: libuv-${{ inputs.version }}-${{ runner.arch }}-${{ runner.os }}${{ inputs.sanitizer }} | ||
|
||
- name: Setup cmake | ||
if: steps.cache-libuv.outputs.cache-hit != 'true' | ||
uses: jwlawson/actions-setup-cmake@v2 | ||
with: | ||
cmake-version: "3.24" | ||
|
||
- name: Install Deps | ||
if: steps.cache-libuv.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y pkg-config clang build-essential ninja-build | ||
- name: Install Deps for Sanitizers | ||
if: steps.cache-libuv.outputs.cache-hit != 'true' && inputs.sanitizer != '' | ||
shell: bash | ||
run: | | ||
sudo apt-get install -y libasan8 libubsan1 | ||
sudo sysctl vm.mmap_rnd_bits=28 | ||
- name: Download Libuv | ||
if: steps.cache-libuv.outputs.cache-hit != 'true' | ||
shell: bash | ||
working-directory: /opt | ||
run: | | ||
curl -L "https://github.com/libuv/libuv/archive/v${{ inputs.version }}.tar.gz" | tar xzf - | ||
mv "libuv-${{ inputs.version }}" libuv-src | ||
cd libuv-src && mkdir build | ||
- name: 'Install Libuv' | ||
if: steps.cache-libuv.outputs.cache-hit != 'true' | ||
shell: bash | ||
working-directory: /opt/libuv-src/build | ||
run: | | ||
cmake -G Ninja \ | ||
-DBUILD_TESTING=OFF \ | ||
-DLIBUV_BUILD_SHARED=ON \ | ||
-DASAN=${{ inputs.sanitizer == 'asan' && 'ON' || 'OFF' }} \ | ||
-DMSAN=${{ inputs.sanitizer == 'msan' && 'ON' || 'OFF' }} \ | ||
-DUBSAN=${{ inputs.sanitizer != '' && 'ON' || 'OFF' }} \ | ||
-DCMAKE_INSTALL_PREFIX="/opt/libuv" \ | ||
-DCMAKE_BUILD_TYPE="RelWithInfo" .. | ||
env: | ||
CC: clang | ||
- name: Compile | ||
if: steps.cache-libuv.outputs.cache-hit != 'true' | ||
shell: bash | ||
working-directory: /opt/libuv-src/build | ||
run: sudo ninja install | ||
- name: Add Libuv to the PATH | ||
id: values | ||
shell: bash | ||
run: | | ||
echo "pkg_config_path=/opt/libuv/lib/pkgconfig" >> "$GITHUB_OUTPUT" | ||
echo "install_dir=/opt/libuv" >> "$GITHUB_OUTPUT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Install PHP | ||
description: Install PHP | ||
|
||
inputs: | ||
version: | ||
required: true | ||
description: "PHP version" | ||
phpts: | ||
required: true | ||
description: "nts or ts" | ||
sanitizer: | ||
required: false | ||
default: '' | ||
description: "ASAN or MSAN" | ||
|
||
outputs: | ||
version: | ||
value: ${{ steps.determine-php-version.outputs.version }} | ||
description: "PHP version" | ||
php_binary_dir: | ||
value: ${{ steps.values.outputs.php_binary_dir }} | ||
description: "PHP binary directory" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: apt update | ||
shell: bash | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get remove 'php*' | ||
- name: Determine PHP version | ||
shell: bash | ||
id: determine-php-version | ||
run: | | ||
curl -fsSL 'https://www.php.net/releases/index.php?json&max=1&version=${{ inputs.version }}' -o version.json | ||
echo version="$(jq -r 'keys[0]' version.json)" >> "$GITHUB_OUTPUT" | ||
echo archive="$(jq -r '.[] .source[] | select(.filename |endswith(".xz")) | "https://www.php.net/distributions/" + .filename' version.json)" >> "$GITHUB_OUTPUT" | ||
- name: Cache PHP | ||
id: cache-php | ||
uses: actions/cache@v4 | ||
with: | ||
path: /opt/php | ||
key: php-sanitizers-${{ inputs.sanitizer }}-${{ runner.arch }}-${{ steps.determine-php-version.outputs.version }}-${{ inputs.phpts }} | ||
|
||
- name: Download php | ||
if: steps.cache-php.outputs.cache-hit != 'true' | ||
working-directory: /opt | ||
shell: bash | ||
run: | | ||
mkdir php-src/ | ||
curl -fsSL "${{ steps.determine-php-version.outputs.archive }}" | tar -Jx -C php-src --strip-components=1 | ||
- name: Compile PHP | ||
if: steps.cache-php.outputs.cache-hit != 'true' | ||
shell: bash | ||
working-directory: /opt/php-src | ||
run: | | ||
./configure \ | ||
CFLAGS="-g -O0 -DZEND_TRACK_ARENA_ALLOC" \ | ||
--enable-debug \ | ||
--enable-cli \ | ||
${{ inputs.phpts == 'ts' && '--enable-zts' || '' }} \ | ||
--enable-option-checking=fatal \ | ||
--disable-zend-signals \ | ||
--without-sqlite3 \ | ||
--without-pdo-sqlite \ | ||
--without-libxml \ | ||
--disable-dom \ | ||
--disable-simplexml \ | ||
--disable-xml \ | ||
--disable-xmlreader \ | ||
--disable-xmlwriter \ | ||
--without-pcre-jit \ | ||
--disable-opcache-jit \ | ||
--disable-cgi \ | ||
--disable-phpdbg \ | ||
--without-pear \ | ||
--disable-mbregex \ | ||
${{ inputs.sanitizer == 'msan' && '--enable-memory-sanitizer' || '' }} \ | ||
${{ inputs.sanitizer == 'asan' && '--enable-address-sanitizer' || '' }} \ | ||
--prefix="/opt/php" | ||
make -j"$(getconf _NPROCESSORS_ONLN)" | ||
make install | ||
env: | ||
CC: clang | ||
USE_ZEND_ALLOC: 0 | ||
|
||
- name: Add PHP to the PATH | ||
id: values | ||
shell: bash | ||
run: | | ||
echo "php_binary_dir=/opt/php/bin" >> "$GITHUB_OUTPUT" | ||
echo "/opt/php/bin" >> "$GITHUB_PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.