Skip to content

Commit

Permalink
[Github Actions] [OSX DEBUG] Optimization - Cache Google V8 after bui…
Browse files Browse the repository at this point in the history
…lding
  • Loading branch information
buffer committed Dec 27, 2023
1 parent 426a8f3 commit ee96bab
Showing 1 changed file with 82 additions and 11 deletions.
93 changes: 82 additions & 11 deletions .github/workflows/osx-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,68 @@ name: MacOSX build workflow (debug)
on: [push, pull_request]

jobs:
build-v8:
# If Google V8 is in the workflow cache, don't build it.
# Cloning the repository is still necessary in any case
# to calculate the hash for the cache key
name: Build Google V8
runs-on: [macos-12, macos-13]
outputs:
v8-hash: ${{ steps.build-v8.outputs.v8-hash }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Clone Google V8
run: |
python -m pip install wheel
echo "::group::Clone Google V8"
python setup.py checkout_v8
echo "::endgroup::"
- name: Restore Google V8 from cache
id: restore-v8
uses: actions/cache/restore@main
with:
path: |
v8/out.gn/x64.release.sample/obj/libv8_monolith.a
v8/out.gn/x64.release.sample/icudtl.dat
v8/include
key: ${{ runner.os }}-build-v8-${{ hashFiles('v8/src/**') }}

- name: Build Google V8
id: build-v8
if: ${{ steps.restore-v8.outputs.cache-hit != 'true' }}
continue-on-error: false
run: |
echo "v8-hash=${{ hashFiles('v8/src/**') }}" >> "$GITHUB_OUTPUT"
python -m pip install wheel
echo "::group::v8"
python setup.py v8
echo "::endgroup::"
- name: Save Google V8 to cache
uses: actions/cache/save@main
if: ${{ steps.restore-v8.outputs.cache-hit != 'true' }}
with:
# Save compiled binary and header files. This will save an
# additional clone of Google V8 for the linker
path: |
v8/out.gn/x64.release.sample/obj/libv8_monolith.a
v8/out.gn/x64.release.sample/icudtl.dat
v8/include
key: ${{ runner.os }}-build-v8-${{ hashFiles('v8/src/**') }}

build:
name: Build wheel on ${{ matrix.os }}
needs: build-v8
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12, macos-13]
python-version: ['3.12']
boost-version: ['1.84.0']
boost-version-snake: ['1_84_0']

steps:
- name: Checkout repository
Expand All @@ -20,30 +75,46 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Download Boost
id: download-boost
uses: suisei-cn/[email protected]
with:
url: https://boostorg.jfrog.io/artifactory/main/release/${{ matrix.boost-version }}/sourc
e/boost_${{ matrix.boost-version-snake }}.zip

- name: Install Boost
id: install-boost
run: |
unzip -q ${{ steps.download-boost.outputs.filename }}
cd boost_${{ matrix.boost-version-snake }}
./bootstrap.sh
sudo ./b2 install -j 8 --with-system --with-python --with-filesystem --with-iostreams --w
ith-date_time --with-thread

- name: Restore Google V8 from cache
id: restore-v8
uses: actions/cache/restore@main
with:
path: |
v8/out.gn/x64.release.sample/obj/libv8_monolith.a
v8/out.gn/x64.release.sample/icudtl.dat
v8/include
key: ${{ runner.os }}-build-v8-${{ needs.build-v8.outputs.v8-hash }}

- name: Install dependencies
run: |
pip install --upgrade pip setuptools delocate wheel pytest pytest-order
brew update
brew install boost
brew install boost-python3 --ignore-dependencies
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
- name: Build wheel
run: |
python setup.py v8
python setup.py sdist bdist_wheel -d stpyv8-${{ matrix.os }}-${{ matrix.python-version }}-debug
python setup.py sdist bdist_wheel --skip-build-v8 -d stpyv8-${{ matrix.os }}-${{ matrix.python-version }}-debug
env:
STPYV8_DEBUG: 1

- name: Repair wheel
run: |
delocate-wheel stpyv8-${{ matrix.os }}-${{ matrix.python-version }}-debug/stpyv8*.whl
- name: Uninstall boost
run: |
brew uninstall boost boost-python3
- name: Install wheel
run: |
python -m pip install --find-links=stpyv8-${{ matrix.os }}-${{ matrix.python-version }}-debug stpyv8
Expand Down

0 comments on commit ee96bab

Please sign in to comment.