Skip to content

Commit

Permalink
[ci] Add caching for source-built dependencies on macOS and remove ct…
Browse files Browse the repository at this point in the history
…ypes pin.
  • Loading branch information
Apprentice-Alchemist committed Apr 28, 2024
1 parent c325889 commit 13068c3
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 36 deletions.
54 changes: 36 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,9 @@ jobs:
OPAMYES: 1
MACOSX_DEPLOYMENT_TARGET: 10.13
OCAML_VERSION: 5.1.1
CTYPES: 0.21.1
ZLIB_VERSION: 1.3.1
MBEDTLS_VERSION: 2.28.5
PCRE2_VERSION: 10.42
steps:
- uses: actions/checkout@main
with:
Expand Down Expand Up @@ -485,45 +487,61 @@ jobs:
- name: Print Neko version
run: neko -version 2>&1

- name: Install dependencies
env:
# For compatibility with macOS 10.13
ZLIB_VERSION: 1.3.1
MBEDTLS_VERSION: 2.28.5
PCRE2_VERSION: 10.42
# Zlib, Mbedtls and PCRE2 are built from source and statically linked
# to ensure compatibility with the chosen deployment target
# Deployment target and library versions are defined by env vars in main.yml

- name: Cache native dependencies
id: cache-native-deps
uses: actions/cache@v4
with:
path: |
zlib-${{ env.ZLIB_VERSION }}
mbedtls-${{ env.MBEDTLS_VERSION }}
pcre2-${{ env.PCRE2_VERSION }}
key: ${{ matrix.os }}-${{ env.ZLIB_VERSION }}-${{ env.MBEDTLS_VERSION }}-${{ env.PCRE2_VERSION }}

- name: Install Homebrew & CPAN dependencies
run: |
set -ex
brew update
brew bundle --file=tests/Brewfile --no-upgrade
cpanm IPC::System::Simple
cpanm String::ShellQuote
- name: Build native dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
curl -L https://github.com/madler/zlib/releases/download/v$ZLIB_VERSION/zlib-$ZLIB_VERSION.tar.gz | tar xz
cd zlib-$ZLIB_VERSION
./configure
sudo make && sudo make install
sudo make -j`sysctl -n hw.ncpu`
cd ..
curl -L https://github.com/ARMmbed/mbedtls/archive/v$MBEDTLS_VERSION.tar.gz | tar xz
cd mbedtls-$MBEDTLS_VERSION
sudo make && sudo make install
sudo make -j`sysctl -n hw.ncpu`
cd ..
curl -L https://github.com/PCRE2Project/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-$PCRE2_VERSION.tar.gz | tar xz
cd pcre2-$PCRE2_VERSION
./configure --enable-unicode --enable-pcre2-8 --enable-pcre2-16 --enable-pcre2-32 --enable-unicode-properties --enable-pcre2grep-libz --enable-pcre2grep-libbz2 --enable-jit
sudo make && sudo make install
sudo make -j`sysctl -n hw.ncpu`
cd ..
- name: Install native dependencies
run: |
sudo make -C zlib-$ZLIB_VERSION install
sudo make -C mbedtls-$MBEDTLS_VERSION install
sudo make -C pcre2-$PCRE2_VERSION install
- name: Install OCaml libraries
if: steps.cache-opam.outputs.cache-hit != 'true'
run: |
set -ex
opam init # --disable-sandboxing
opam update
opam switch create ${{env.OCAML_VERSION}}
opam init -c ${{env.OCAML_VERSION}}
eval $(opam env)
opam update
opam env
opam pin add ctypes ${{env.CTYPES}} --yes
opam pin add haxe . --no-action
opam install haxe --deps-only --assume-depexts
opam install . --deps-only --assume-depexts
opam list
ocamlopt -v
Expand All @@ -535,8 +553,8 @@ jobs:
run: |
set -ex
eval $(opam env)
opam config exec -- make -s -j`sysctl -n hw.ncpu` STATICLINK=1 "LIB_PARAMS=/usr/local/lib/libz.a /usr/local/lib/libpcre2-8.a /usr/local/lib/libmbedtls.a /usr/local/lib/libmbedcrypto.a /usr/local/lib/libmbedx509.a -cclib '-framework Security -framework CoreFoundation'" haxe
opam config exec -- make -s haxelib
make -s STATICLINK=1 haxe
make -s haxelib
make -s package_unix package_installer_mac
ls -l out
otool -L ./haxe
Expand Down
50 changes: 33 additions & 17 deletions extra/github-actions/build-mac.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,58 @@
- name: Install dependencies
env:
# For compatibility with macOS 10.13
ZLIB_VERSION: 1.3.1
MBEDTLS_VERSION: 2.28.5
PCRE2_VERSION: 10.42
# Zlib, Mbedtls and PCRE2 are built from source and statically linked
# to ensure compatibility with the chosen deployment target
# Deployment target and library versions are defined by env vars in main.yml

- name: Cache native dependencies
id: cache-native-deps
uses: actions/cache@v4
with:
path: |
zlib-${{ env.ZLIB_VERSION }}
mbedtls-${{ env.MBEDTLS_VERSION }}
pcre2-${{ env.PCRE2_VERSION }}
key: ${{ matrix.os }}-${{ env.ZLIB_VERSION }}-${{ env.MBEDTLS_VERSION }}-${{ env.PCRE2_VERSION }}

- name: Install Homebrew & CPAN dependencies
run: |
set -ex
brew update
brew bundle --file=tests/Brewfile --no-upgrade
cpanm IPC::System::Simple
cpanm String::ShellQuote
- name: Build native dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
curl -L https://github.com/madler/zlib/releases/download/v$ZLIB_VERSION/zlib-$ZLIB_VERSION.tar.gz | tar xz
cd zlib-$ZLIB_VERSION
./configure
sudo make && sudo make install
sudo make -j`sysctl -n hw.ncpu`
cd ..
curl -L https://github.com/ARMmbed/mbedtls/archive/v$MBEDTLS_VERSION.tar.gz | tar xz
cd mbedtls-$MBEDTLS_VERSION
sudo make && sudo make install
sudo make -j`sysctl -n hw.ncpu`
cd ..
curl -L https://github.com/PCRE2Project/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-$PCRE2_VERSION.tar.gz | tar xz
cd pcre2-$PCRE2_VERSION
./configure --enable-unicode --enable-pcre2-8 --enable-pcre2-16 --enable-pcre2-32 --enable-unicode-properties --enable-pcre2grep-libz --enable-pcre2grep-libbz2 --enable-jit
sudo make && sudo make install
sudo make -j`sysctl -n hw.ncpu`
cd ..
- name: Install native dependencies
run: |
sudo make -C zlib-$ZLIB_VERSION install
sudo make -C mbedtls-$MBEDTLS_VERSION install
sudo make -C pcre2-$PCRE2_VERSION install
- name: Install OCaml libraries
if: steps.cache-opam.outputs.cache-hit != 'true'
run: |
set -ex
opam init # --disable-sandboxing
opam update
opam switch create ${{env.OCAML_VERSION}}
opam init -c ${{env.OCAML_VERSION}}
eval $(opam env)
opam update
opam env
opam pin add ctypes ${{env.CTYPES}} --yes
opam pin add haxe . --no-action
opam install haxe --deps-only --assume-depexts
opam install . --deps-only --assume-depexts
opam list
ocamlopt -v
Expand All @@ -48,8 +64,8 @@
run: |
set -ex
eval $(opam env)
opam config exec -- make -s -j`sysctl -n hw.ncpu` STATICLINK=1 "LIB_PARAMS=/usr/local/lib/libz.a /usr/local/lib/libpcre2-8.a /usr/local/lib/libmbedtls.a /usr/local/lib/libmbedcrypto.a /usr/local/lib/libmbedx509.a -cclib '-framework Security -framework CoreFoundation'" haxe
opam config exec -- make -s haxelib
make -s STATICLINK=1 haxe
make -s haxelib
make -s package_unix package_installer_mac
ls -l out
otool -L ./haxe
Expand Down
4 changes: 3 additions & 1 deletion extra/github-actions/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ jobs:
OPAMYES: 1
MACOSX_DEPLOYMENT_TARGET: 10.13
OCAML_VERSION: 5.1.1
CTYPES: 0.21.1
ZLIB_VERSION: 1.3.1
MBEDTLS_VERSION: 2.28.5
PCRE2_VERSION: 10.42
steps:
- uses: actions/checkout@main
with:
Expand Down

0 comments on commit 13068c3

Please sign in to comment.