fix TestBindSimple and TestBindCgoPackage #219
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ '**' ] | |
| env: | |
| TAGS: "-tags=ci" | |
| COVERAGE: "-coverpkg=github.com/go-python/gopy/..." | |
| # Init() in main_test will make sure all backends are available if | |
| # GOPY_TRAVIS_CI is set | |
| GOPY_TRAVIS_CI: 1 | |
| GOTRACEBACK: crash | |
| GO111MODULE: auto | |
| jobs: | |
| build: | |
| name: Build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| go-version: [1.25.x, 1.24.x, 1.23.x, 1.22.x, 1.21.x] | |
| platform: [ubuntu-latest, windows-latest, macos-15-intel] | |
| #platform: [ubuntu-latest, macos-latest, windows-latest] | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| cache: true | |
| - name: Install Linux packages | |
| if: matrix.platform == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install curl libffi-dev python3-cffi python3-pip | |
| # install pybindgen | |
| python3 -m pip install --user -U pybindgen | |
| # install goimports | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| - name: Install Windows packages | |
| if: matrix.platform == 'windows-latest' | |
| run: | | |
| # install pybindgen and psutil (for memory tracking in tests) | |
| python -m pip install -U pybindgen psutil | |
| # install goimports | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| - name: Install macOS packages | |
| if: matrix.platform == 'macos-15-intel' | |
| run: | | |
| # install pybindgen | |
| python3 -m pip install --user -U pybindgen | |
| # install goimports | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| - name: Build-Linux | |
| if: matrix.platform == 'ubuntu-latest' | |
| run: | | |
| make | |
| - name: Test Linux | |
| if: matrix.platform == 'ubuntu-latest' | |
| run: | | |
| make test | |
| - name: Build-Windows | |
| if: matrix.platform == 'windows-latest' | |
| run: | | |
| go build -v ./... | |
| - name: Test Windows | |
| if: matrix.platform == 'windows-latest' | |
| run: | | |
| go test -v ./... | |
| - name: Build-macOS | |
| if: matrix.platform == 'macos-15-intel' | |
| run: | | |
| make | |
| - name: Test macOS | |
| if: matrix.platform == 'macos-15-intel' | |
| run: | | |
| make test | |
| - name: Symbol diagnostic (macOS Intel) | |
| if: always() && matrix.platform == 'macos-15-intel' | |
| continue-on-error: true | |
| env: | |
| GOFLAGS: "-mod=mod" | |
| run: | | |
| echo "=== building test packages for symbol analysis ===" | |
| go build -o /tmp/gopy_diag . | |
| DIAGDIR=$(mktemp -d) | |
| CWD=$(pwd) | |
| mkdir -p "$DIAGDIR/gilstring" "$DIAGDIR/simple" | |
| printf 'module dummy\nrequire github.com/go-python/gopy v0.0.0\nreplace github.com/go-python/gopy => %s\n' \ | |
| "$CWD" > "$DIAGDIR/gilstring/go.mod" | |
| printf 'module dummy\nrequire github.com/go-python/gopy v0.0.0\nreplace github.com/go-python/gopy => %s\n' \ | |
| "$CWD" > "$DIAGDIR/simple/go.mod" | |
| /tmp/gopy_diag build -vm=python3 -output="$DIAGDIR/gilstring" ./_examples/gilstring 2>&1 | tail -3 | |
| /tmp/gopy_diag build -vm=python3 -output="$DIAGDIR/simple" ./_examples/simple 2>&1 | tail -3 | |
| GIL_SO=$(find "$DIAGDIR/gilstring" -name "_gilstring*.so" 2>/dev/null | head -1) | |
| SIM_SO=$(find "$DIAGDIR/simple" -name "_simple*.so" 2>/dev/null | head -1) | |
| echo "gilstring: $GIL_SO" | |
| echo "simple: $SIM_SO" | |
| [ -n "$GIL_SO" ] && [ -n "$SIM_SO" ] || { echo "SKIP: .so files not found"; exit 0; } | |
| echo "" | |
| echo "=== shared dynamic symbols ===" | |
| nm "$GIL_SO" | awk '$2~/^[A-Z]$/{print $3}' | sort > /tmp/diag_g1.txt | |
| nm "$SIM_SO" | awk '$2~/^[A-Z]$/{print $3}' | sort > /tmp/diag_g2.txt | |
| echo "total shared: $(comm -12 /tmp/diag_g1.txt /tmp/diag_g2.txt | wc -l | tr -d ' ')" | |
| echo "critical CGo bridge symbols shared between both .so files:" | |
| comm -12 /tmp/diag_g1.txt /tmp/diag_g2.txt \ | |
| | grep -E "crosscall|cgo_topofstack|x_cgo_init|x_cgo_inittls|cgo_yield|cgo_panic" \ | |
| || echo " (none)" | |
| echo "" | |
| echo "=== indirect symbol table / PLT stubs in gilstring (otool -Iv) ===" | |
| TOTAL=$(otool -Iv "$GIL_SO" | grep -c '0x' || true) | |
| echo "total indirect entries: $TOTAL" | |
| otool -Iv "$GIL_SO" \ | |
| | grep -E "crosscall|cgo_topofstack|x_cgo_init|x_cgo_inittls|cgo_yield|cgo_panic" \ | |
| || echo " (none of the critical CGo symbols appear as PLT stubs)" | |
| echo "" | |
| echo "=== indirect symbol table / PLT stubs in simple (otool -Iv) ===" | |
| TOTAL=$(otool -Iv "$SIM_SO" | grep -c '0x' || true) | |
| echo "total indirect entries: $TOTAL" | |
| otool -Iv "$SIM_SO" \ | |
| | grep -E "crosscall|cgo_topofstack|x_cgo_init|x_cgo_inittls|cgo_yield|cgo_panic" \ | |
| || echo " (none of the critical CGo symbols appear as PLT stubs)" | |
| echo "" | |
| echo "=== runtime: which library wins in the global namespace ===" | |
| GIL_SO="$GIL_SO" SIM_SO="$SIM_SO" python3 << 'PYEOF' | |
| import ctypes, os | |
| GLOBAL = getattr(ctypes, 'RTLD_GLOBAL', 8) | |
| gil = ctypes.CDLL(os.environ['GIL_SO'], mode=GLOBAL) | |
| sim = ctypes.CDLL(os.environ['SIM_SO'], mode=GLOBAL) | |
| glb = ctypes.CDLL(None) | |
| for s in ['crosscall2', '_cgo_topofstack', 'x_cgo_init', 'x_cgo_inittls', '_cgo_yield', 'x_cgo_mmap']: | |
| try: | |
| a1 = ctypes.cast(getattr(gil, s), ctypes.c_void_p).value | |
| a2 = ctypes.cast(getattr(sim, s), ctypes.c_void_p).value | |
| ag = ctypes.cast(getattr(glb, s), ctypes.c_void_p).value | |
| who = 'gilstring' if ag == a1 else ('simple' if ag == a2 else 'other') | |
| print(' %-35s -> %-12s (global=%s)' % (s, who, hex(ag) if ag else 'N/A')) | |
| except Exception as e: | |
| print(' %-35s error: %s' % (s, e)) | |
| PYEOF | |
| - name: Upload-Coverage | |
| if: matrix.platform == 'ubuntu-latest' | |
| uses: codecov/codecov-action@v4 |