Skip to content

On destroy - acquire gil #69

On destroy - acquire gil

On destroy - acquire gil #69

name: cross-platform-build
on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]
workflow_dispatch:
workflow_call:
jobs:
build:
strategy:
matrix:
include:
- os: linux-x86_64
runner: arc-runner-set
python: "3.12"
py: "312"
- os: linux-x86_64
runner: arc-runner-set
python: "3.10"
py: "310"
- os: linux-x86_64
runner: arc-runner-set
python: "3.13"
py: "313"
- os: macos-aarch64
runner: macos-14
python: "3.12"
py: "312"
- os: macos-aarch64
runner: macos-14
python: "3.10"
py: "310"
- os: macos-aarch64
runner: macos-14
python: "3.13"
py: "313"
runs-on: ${{ matrix.runner }}
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install Linux packages
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq \
build-essential git cmake ninja-build automake libtool texinfo autoconf \
libc++-dev libc++abi-dev ccache libboost-all-dev pkg-config wget gh \
libatomic1 libjemalloc-dev
sudo find / -type f -name "libatomic.so*" -print -delete 2>/dev/null || echo 'ok'
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16 clang
- name: Install macOS packages
if: runner.os == 'macOS'
run: |
brew install ninja pkg-config automake coreutils libtool autoconf \
texinfo wget ccache boost jemalloc cmake
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Date Stamp
id: date-stamp
run: |
echo "timestamp=$(date -u "+%Y%m%d%H%M_%S")" >> "$GITHUB_OUTPUT"
- name: Compute 3pp cache key
id: third-party-key
run: echo "key=${{ runner.os }}-${{ runner.arch }}-${{ matrix.py }}-static-3pp-$(sha256sum ./assembly/native/build-3pp.sh | cut -c1-16)" >> $GITHUB_OUTPUT
- name: Restore 3pp
uses: actions/cache/restore@v4
with:
path: ${{ runner.temp }}/3pp_clear/
key: ${{ steps.third-party-key.outputs.key }}
- name: Build 3pp
run: ./assembly/native/build-3pp.sh
- name: Check 3pp build status
id: check-third-party
run: |
if grep -q "$NEED_CACHE=true" ${RUNNER_TEMP}/3pp/3pp_status.txt; then
echo "cache=true" >> "$GITHUB_OUTPUT"
else
echo "cache=false" >> "$GITHUB_OUTPUT"
fi
- name: Save 3pp
if: steps.check-third-party.outputs.cache == 'true' && github.event_name != 'pull_request'
uses: actions/cache/save@v4
with:
path: ${{ runner.temp }}/3pp_clear/
key: ${{ steps.third-party-key.outputs.key }}
- name: 3pp structure
run: |
find "${RUNNER_TEMP}/3pp_clear/"
- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: ~/.ccache
key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.py }}-static-ccache
- name: Build TON
run: |
git submodule sync --recursive
git submodule update
./assembly/native/build-universal-static.sh
ccache -sp
- name: Set environment for release
run: |
KERNEL=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
# Map architecture if needed
if [ "$ARCH" = "x86_64" ]; then
ARCH="x86_64"
elif [ "$ARCH" = "arm64" ]; then
ARCH="aarch64"
fi
echo "TARGET_SYSTEM=${ARCH}-${KERNEL}" >> $GITHUB_ENV
echo "RELEASE_NAME=ton-cpython-${{ matrix.py }}-${ARCH}-${KERNEL}-dev" >> $GITHUB_ENV
- name: Save ccache
if: github.event_name != 'pull_request'
uses: actions/cache/save@v4
with:
path: ~/.ccache
key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.py }}-static-ccache
- name: Linked libraries (pre-test)
run: |
set -euxo pipefail
shopt -s nullglob
cd artifacts
files=( python_ton*.so python_ton*.dylib ton_python*.so ton_python*.dylib *.so *.dylib )
if [ ${#files[@]} -eq 0 ]; then
echo "No shared libraries found in artifacts directory to inspect. Contents:";
ls -la
exit 0
fi
echo "Found the following candidate shared libraries:" "${files[@]}"
if [ "${{ runner.os }}" = "macOS" ]; then
for f in "${files[@]}"; do
echo "==== otool -L $f ===="
otool -L "$f" || true
done
else
for f in "${files[@]}"; do
echo "==== ldd $f ===="
ldd "$f" || true
done
fi
- name: Simple binary test
run: cd artifacts; python3 -c 'import python_ton'
- name: Upload artifacts
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_NAME }}
path: artifacts
- name: Create release
if: github.event_name != 'pull_request'
run: |
gh release delete -y "$RELEASE_NAME" || true
gh release create --notes "Your binary sir" "$RELEASE_NAME" artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}