Skip to content

Commit aacf18e

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 aacf18e

File tree

1 file changed

+138
-30
lines changed

1 file changed

+138
-30
lines changed

.github/workflows/build-test.yml

Lines changed: 138 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,57 @@ 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+
# Run gn gen with args as v8gen does not override target_cpu properly
87+
gn gen out.gn/$V8CONFIG --args='target_cpu="'$ARCH_SHORT'" v8_target_cpu="'$ARCH_SHORT'" is_component_build=true use_custom_libcxx=true treat_warnings_as_errors=false'
88+
else
89+
tools/dev/v8gen.py -vv $V8CONFIG -- is_component_build=true use_custom_libcxx=true treat_warnings_as_errors=false
90+
fi
7591
7692
# Build
77-
ninja -C out.gn/x64.release/
93+
ninja -C out.gn/$V8CONFIG/
7894
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/
95+
if [[ "${{ runner.os }}" == "macOS" ]]; then
96+
LIB_EXT=dylib
97+
else
98+
LIB_EXT=so
99+
fi
100+
cp out.gn/$V8CONFIG/lib*.${LIB_EXT} out.gn/$V8CONFIG/*_blob.bin out.gn/$V8CONFIG/icudtl.dat /opt/v8/self-built/lib/
101+
cp -R include/* /opt/v8/self-built/include/
83102
84103
# Go back to origin
85104
cd "${GITHUB_WORKSPACE}"
@@ -91,6 +110,52 @@ jobs:
91110
path: /opt/v8/self-built
92111
key: ${{ steps.v8-build-cache.outputs.cache-primary-key }}
93112

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

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

0 commit comments

Comments
 (0)