Skip to content

Commit c7a5484

Browse files
committed
Add test to build on macos using v8 from brew
Change GitHub actions to include more and more detailed tests Rename other workflow targets to better explain the differences between the runs Add more php versions to default build test to ensure complete range is tested Add macos to self-built tests Make artifact names unique per step Extract v8 cache building to run less often to reduce computation costs Ensure to use right architecture on built-target Speed up v8 fetch
1 parent dde1c5a commit c7a5484

File tree

1 file changed

+137
-30
lines changed

1 file changed

+137
-30
lines changed

.github/workflows/build-test.yml

Lines changed: 137 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,17 @@ permissions:
1212
contents: read
1313

1414
jobs:
15-
build:
15+
self-built-v8-cache-warmup:
1616
strategy:
1717
# set in accordance with number of v8-versions, so caching can kick in properly
1818
max-parallel: 2
1919

2020
matrix:
21-
operating-system:
21+
operating-system: # &self-built-v8-operating-systems
2222
- ubuntu-latest
2323
# - windows-latest
24-
# - macos-latest
25-
php-versions:
26-
# - '8.1'
27-
# - '8.2'
28-
- '8.3'
29-
- '8.4'
30-
v8-versions:
24+
- macos-latest
25+
v8-versions: # &self-built-v8-v8-versions
3126
- 10.9.194
3227
# - 11.9.172
3328
- 12.9.203
@@ -36,14 +31,10 @@ jobs:
3631
runs-on: ${{ matrix.operating-system }}
3732

3833
steps:
39-
- name: Checkout code
40-
uses: actions/checkout@v2
41-
42-
- name: Setup PHP
43-
uses: shivammathur/setup-php@v2
44-
with:
45-
php-version: ${{ matrix.php-versions }}
46-
coverage: none
34+
- name: Prepare cache folder v8 ${{ matrix.v8-versions }}
35+
run: |
36+
sudo mkdir -p /opt/v8/self-built/{lib,include}
37+
sudo chown -R $(id -u):$(id -g) /opt/v8/self-built
4738
4839
- name: Restore cache v8 ${{ matrix.v8-versions }} build
4940
id: v8-build-cache
@@ -57,29 +48,56 @@ jobs:
5748
if: steps.v8-build-cache.outputs.cache-hit != 'true'
5849
uses: newkdev/setup-depot-tools@v1.0.1
5950

51+
- name: Set up Clang
52+
if: ${{ matrix.operating-system == 'ubuntu-latest' }}
53+
run: |
54+
sudo apt update
55+
sudo apt install -y clang-19 lld-19
56+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 100
57+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 100
58+
6059
- name: Build v8 ${{ matrix.v8-versions }}
6160
if: steps.v8-build-cache.outputs.cache-hit != 'true'
6261
run: |
6362
# Store extra tools somewhere undisturbing
63+
set -x
6464
cd "$(mktemp -d)"
6565
66-
fetch v8
66+
ARCH=$(uname -m)
67+
if [[ "$ARCH" == "x86_64" ]]; then
68+
V8CONFIG="x64.release"
69+
ARCH_SHORT="x64"
70+
elif [[ "$ARCH" == "arm64" ]]; then
71+
V8CONFIG="arm64.release"
72+
ARCH_SHORT="arm64"
73+
else
74+
echo "Unknown architecture: $ARCH" >&2
75+
exit 1
76+
fi
77+
fetch --nohooks --no-history v8
6778
cd v8
68-
69-
git checkout ${{ matrix.v8-versions }}
70-
gclient sync -D
79+
git fetch --tag origin refs/tags/${{ matrix.v8-versions }} 1>&2 > /dev/null
80+
git checkout ${{ matrix.v8-versions }} 1>&2 > /dev/null
81+
gclient sync -D 1>&2 > /dev/null
7182
7283
# Setup GN
7384
# Warnings are no errors - @see https://issues.chromium.org/issues/42203398#comment9
74-
tools/dev/v8gen.py -vv x64.release -- is_component_build=true use_custom_libcxx=false treat_warnings_as_errors=false
85+
if [[ "${{ runner.os }}" == "macOS" ]]; then
86+
tools/dev/v8gen.py -vv $V8CONFIG -- target_cpu=$ARCH_SHORT v8_target_cpu=$ARCH_SHORT is_component_build=true use_custom_libcxx=true treat_warnings_as_errors=false
87+
else
88+
tools/dev/v8gen.py -vv $V8CONFIG -- is_component_build=true use_custom_libcxx=true treat_warnings_as_errors=false
89+
fi
7590
7691
# Build
77-
ninja -C out.gn/x64.release/
92+
ninja -C out.gn/$V8CONFIG/
7893
79-
# Install to /opt/v8/self-built
80-
sudo mkdir -p /opt/v8/self-built/{lib,include}
81-
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/
82-
sudo cp -R include/* /opt/v8/self-built/include/
94+
if [[ "${{ runner.os }}" == "macOS" ]]; then
95+
LIB_EXT=dylib
96+
else
97+
LIB_EXT=so
98+
fi
99+
cp out.gn/$V8CONFIG/lib*.${LIB_EXT} out.gn/$V8CONFIG/*_blob.bin out.gn/$V8CONFIG/icudtl.dat /opt/v8/self-built/lib/
100+
cp -R include/* /opt/v8/self-built/include/
83101
84102
# Go back to origin
85103
cd "${GITHUB_WORKSPACE}"
@@ -91,6 +109,52 @@ jobs:
91109
path: /opt/v8/self-built
92110
key: ${{ steps.v8-build-cache.outputs.cache-primary-key }}
93111

112+
self-built-v8:
113+
needs: self-built-v8-cache-warmup
114+
115+
strategy:
116+
matrix:
117+
operating-system: # *self-built-v8-operating-systems
118+
- ubuntu-latest
119+
# - windows-latest
120+
- macos-latest
121+
v8-versions: # *self-built-v8-v8-versions
122+
- 10.9.194
123+
# - 11.9.172
124+
- 12.9.203
125+
# - 13.1.104
126+
php-versions:
127+
# - '8.1'
128+
- '8.2'
129+
- '8.3'
130+
- '8.4'
131+
132+
runs-on: ${{ matrix.operating-system }}
133+
134+
steps:
135+
- name: Checkout code
136+
uses: actions/checkout@v2
137+
138+
- name: Setup PHP
139+
uses: shivammathur/setup-php@v2
140+
with:
141+
php-version: ${{ matrix.php-versions }}
142+
coverage: none
143+
144+
- name: Set up Clang
145+
if: ${{ matrix.operating-system == 'ubuntu-latest' }}
146+
run: |
147+
sudo apt update
148+
sudo apt install -y clang-19 lld-19
149+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 100
150+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 100
151+
152+
- name: Download cache v8 ${{ matrix.v8-versions }} build
153+
uses: actions/cache/restore@v4
154+
with:
155+
path: /opt/v8/self-built
156+
key: ${{ runner.os }}-${{ matrix.v8-versions }}-v8-build
157+
94158
- name: Build extension
95159
run: |
96160
phpize
@@ -102,12 +166,12 @@ jobs:
102166
if: failure()
103167
uses: actions/upload-artifact@v4
104168
with:
105-
name: phpt-test-results
169+
name: phpt-test-results-on-${{ runner.os }}-${{ matrix.v8-versions }}-${{ matrix.php-versions }}
106170
path: |
107171
php_test_results*.txt
108172
tests/*.out
109173
110-
alpine:
174+
alpine-package-manager-apk:
111175
runs-on: ubuntu-latest
112176

113177
steps:
@@ -135,7 +199,50 @@ jobs:
135199
if: failure()
136200
uses: actions/upload-artifact@v4
137201
with:
138-
name: phpt-test-results
202+
name: phpt-test-results-on-alpine
203+
path: |
204+
php_test_results*.txt
205+
tests/*.out
206+
207+
macos-package-manager-brew:
208+
strategy:
209+
matrix:
210+
php-versions:
211+
- '8.2'
212+
- '8.3'
213+
- '8.4'
214+
215+
runs-on: macos-latest
216+
217+
steps:
218+
- name: Checkout code
219+
uses: actions/checkout@v2
220+
221+
- name: Setup PHP
222+
uses: shivammathur/setup-php@v2
223+
with:
224+
php-version: ${{ matrix.php-versions }}
225+
coverage: none
226+
227+
- name: Set up Homebrew
228+
uses: Homebrew/actions/setup-homebrew@master
229+
230+
- name: Install dependencies
231+
run: |
232+
brew install v8
233+
234+
- name: Build extension
235+
run: |
236+
phpize
237+
./configure --with-v8js=/opt/homebrew CPPFLAGS="-DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX"
238+
make
239+
make test
240+
241+
- name: Archive test results
242+
if: failure()
243+
uses: actions/upload-artifact@v4
244+
with:
245+
name: phpt-test-results-on-macos-brew-${{ matrix.php-versions }}
139246
path: |
140247
php_test_results*.txt
141248
tests/*.out

0 commit comments

Comments
 (0)