Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure MacOS support by tests #539

Draft
wants to merge 12 commits into
base: php8
Choose a base branch
from
Draft
132 changes: 104 additions & 28 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,14 @@ permissions:
contents: read

jobs:
build:
self-built-v8-cache-warmup:
strategy:
matrix:
operating-system:
operating-system: # &self-built-v8-operating-systems
- ubuntu-latest
# - windows-latest
# - macos-latest
php-versions:
# - '8.1'
# - '8.2'
- '8.3'
# - '8.4'
v8-versions:
- macos-latest
v8-versions: # &self-built-v8-v8-versions
- 10.9.194
# - 11.9.172
- 12.9.203
Expand All @@ -33,14 +28,10 @@ jobs:
runs-on: ${{ matrix.operating-system }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
- name: Prepare cache folder v8 ${{ matrix.v8-versions }}
run: |
sudo mkdir -p /opt/v8/self-built/{lib,include}
sudo chown -R $(id -u):$(id -g) /opt/v8/self-built

- name: Restore cache v8 ${{ matrix.v8-versions }} build
id: v8-build-cache
Expand All @@ -60,23 +51,27 @@ jobs:
# Store extra tools somewhere undisturbing
cd "$(mktemp -d)"

fetch v8
ARCH=$(uname -m)
fetch --nohooks --no-history v8
cd v8

git fetch --tag origin refs/tags/${{ matrix.v8-versions }}
git checkout ${{ matrix.v8-versions }}
gclient sync -D

# Setup GN
# Warnings are no errors - @see https://issues.chromium.org/issues/42203398#comment9
tools/dev/v8gen.py -vv x64.release -- is_component_build=true use_custom_libcxx=false treat_warnings_as_errors=false
tools/dev/v8gen.py -vv ${ARCH}.release -- is_component_build=true use_custom_libcxx=false treat_warnings_as_errors=false

# Build
ninja -C out.gn/x64.release/
ninja -C out.gn/${ARCH}.release/

# Install to /opt/v8/self-built
sudo mkdir -p /opt/v8/self-built/{lib,include}
sudo cp out.gn/x64.release/lib*.so out.gn/x64.release/*_blob.bin out.gn/x64.release/icudtl.dat /opt/v8/self-built/lib/
sudo cp -R include/* /opt/v8/self-built/include/
if [[ "${{ runner.os }}" == "macOS" ]]; then
LIB_EXT=dylib
else
LIB_EXT=so
fi
cp out.gn/${ARCH}.release/lib*.${LIB_EXT} out.gn/${ARCH}.release/*_blob.bin out.gn/${ARCH}.release/icudtl.dat /opt/v8/self-built/lib/
cp -R include/* /opt/v8/self-built/include/

# Go back to origin
cd "${GITHUB_WORKSPACE}"
Expand All @@ -88,6 +83,44 @@ jobs:
path: /opt/v8/self-built
key: ${{ steps.v8-build-cache.outputs.cache-primary-key }}

self-built-v8:
needs: self-built-v8-cache-warmup

strategy:
matrix:
operating-system: # *self-built-v8-operating-systems
- ubuntu-latest
# - windows-latest
- macos-latest
v8-versions: # *self-built-v8-v8-versions
- 10.9.194
# - 11.9.172
- 12.9.203
# - 13.1.104
php-versions:
# - '8.1'
- '8.2'
- '8.3'
- '8.4'

runs-on: ${{ matrix.operating-system }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- name: Download cache v8 ${{ matrix.v8-versions }} build
uses: actions/cache/restore@v4
with:
path: /opt/v8/self-built
key: ${{ runner.os }}-${{ matrix.v8-versions }}-v8-build

- name: Build extension
run: |
phpize
Expand All @@ -99,12 +132,12 @@ jobs:
if: failure()
uses: actions/upload-artifact@v4
with:
name: phpt-test-results
name: phpt-test-results-on-${{ runner.os }}-${{ matrix.v8-versions }}-${{ matrix.php-versions }}
path: |
php_test_results*.txt
tests/*.out

alpine:
alpine-package-manager-apk:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -132,7 +165,50 @@ jobs:
if: failure()
uses: actions/upload-artifact@v4
with:
name: phpt-test-results
name: phpt-test-results-on-alpine
path: |
php_test_results*.txt
tests/*.out

macos-package-manager-brew:
strategy:
matrix:
php-versions:
- '8.2'
- '8.3'
- '8.4'

runs-on: macos-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none

- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Install dependencies
run: |
brew install v8

- name: Build extension
run: |
phpize
./configure --with-v8js=/opt/homebrew CPPFLAGS="-DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX"
make
make test

- name: Archive test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: phpt-test-results-on-macos-brew-${{ matrix.php-versions }}
path: |
php_test_results*.txt
tests/*.out
2 changes: 1 addition & 1 deletion README.MacOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cd /tmp
git clone https://github.com/phpv8/v8js.git
cd v8js
phpize
./configure --with-v8js=/opt/homebrew CPPFLAGS="-DV8_COMPRESS_POINTERS"
./configure --with-v8js=/opt/homebrew CPPFLAGS="-DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX"
make -j4
make test
make install
Expand Down
2 changes: 1 addition & 1 deletion v8js_object_export.cc
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Isolate *isolate, v8::Loca
ce = scope = object->ce;

/* First, check the (case-insensitive) method table */
php_strtolower(lower, name_len);
zend_str_tolower(lower, name_len);
method_name = zend_string_init(lower, name_len, 0);

// toString() -> __tostring()
Expand Down
Loading