Skip to content

Merge pull request #53 from parca-dev/kakkoyun-update-python-versions #89

Merge pull request #53 from parca-dev/kakkoyun-update-python-versions

Merge pull request #53 from parca-dev/kakkoyun-update-python-versions #89

name: Generate Python
on:
workflow_call:
push:
branches:
- main
- release
paths:
- ".github/workflows/generate-python.yml"
- "pkg/python/**"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
generate:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
python-version: [
2.7, 2.7.15, 2.7.16, 2.7.17, 2.7.18,
3.3, 3.3.6, 3.3.7,
3.4, 3.4.2, 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7, 3.4.8, 3.4.9, 3.4.10,
3.5.0, 3.5.1, 3.5.2, 3.5.3, 3.5.4, 3.5.5, 3.5.6, 3.5.7, 3.5.8, 3.5.9, 3.5.10,
3.6.0, 3.6.1, 3.6.2, 3.6.3, 3.6.4, 3.6.5, 3.6.6, 3.6.7, 3.6.8, 3.6.9, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15,
3.7.0, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.7.10, 3.7.11, 3.7.12, 3.7.13, 3.7.14, 3.7.15, 3.7.16, 3.7.17,
3.8.0, 3.8.1, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.8.10, 3.8.11, 3.8.12, 3.8.13, 3.8.14, 3.8.15, 3.8.16, 3.8.17, 3.8.18, 3.8.19,
3.9.0, 3.9.1, 3.9.2, 3.9.3, 3.9.4, 3.9.5, 3.9.6, 3.9.7, 3.9.8, 3.9.9, 3.9.10, 3.9.11, 3.9.12, 3.9.13, 3.9.14, 3.9.15, 3.9.16, 3.9.17, 3.9.18, 3.9.19,
3.10.0, 3.10.1, 3.10.2, 3.10.3, 3.10.4, 3.10.5, 3.10.6, 3.10.7, 3.10.8, 3.10.9, 3.10.10, 3.10.11, 3.10.12, 3.10.13, 3.10.14,
3.11.0, 3.11.1, 3.11.2, 3.11.3, 3.11.4, 3.11.5, 3.11.6, 3.11.7, 3.11.8, 3.11.9,
3.12.0, 3.12.1, 3.12.2, 3.12.3,
3.13.0a4
]
arch: [amd64, arm64]
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Install devbox
uses: jetpack-io/[email protected]
with:
enable-cache: true
- name: Setup devbox
run: devbox run -- echo "done!"
- name: Load devbox shellenv
uses: HatsuneMiku3939/direnv-action@v1
with:
direnvVersion: 2.32.3
- name: Set up Go tool cache
uses: actions/cache@v4
with:
path: ~/.devbox/go
key: devbox-go-tools.cache-${{ runner.os }}-${{ runner.arch }}
- name: Build
run: make build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up cache for downloaded files
uses: actions/cache@v4
with:
path: python-binaries
key: python-downloaded-${{ runner.os }}-${{ matrix.arch }}
restore-keys: |
python-downloaded-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.python-version }}
- name: Generate Python Offsets for ${{ matrix.python-version }} on ${{ matrix.arch }}
run: |
export python_version="${{ matrix.python-version }}"
if ! ls python-binaries/${{ matrix.arch }}/${{ matrix.python-version }}/libpython"${python_version%.*}"*.so.1.0 1> /dev/null 2>&1; then
mkdir -p python-binaries/${{ matrix.arch }}/${{ matrix.python-version }}
docker run --rm --platform "linux/${{ matrix.arch }}" -v "${PWD}"/python-binaries/${{ matrix.arch }}/${{ matrix.python-version }}:/tmp -w /tmp docker.io/library/python:${{ matrix.python-version }} bash -c 'cp /usr/local/lib/libpython"${python_version%.*}"*.so.1.0 /tmp' || exit 0 # (some containers of python do not have arm64 version)
fi
mkdir -p offsets-python/${{ matrix.arch }}
./structlayout -r python -v ${{ matrix.python-version }} -o offsets-python/${{ matrix.arch }} python-binaries/${{ matrix.arch }}/${{ matrix.python-version }}/libpython"${python_version%.*}"*.so.1.0
git add offsets-python
cp $(git diff --name-only --staged | xargs) offsets-python || echo "No new or modified files - offsets
are up to date"
- name: Upload Offsets
uses: actions/upload-artifact@v4
with:
if-no-files-found: ignore
name: python-${{ matrix.arch }}-${{ matrix.python-version }}
path: offsets-python
retention-days: 1
merge-and-create-branch:
runs-on: ubuntu-latest
needs: generate
permissions:
contents: write
pull-requests: write
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Install devbox
uses: jetpack-io/[email protected]
with:
enable-cache: true
- name: Setup devbox
run: devbox run -- echo "done!"
- name: Load devbox shellenv
uses: HatsuneMiku3939/direnv-action@v1
with:
direnvVersion: 2.32.3
- name: Set up Go tool cache
uses: actions/cache@v4
with:
path: ~/.devbox/go
key: devbox-go-tools.cache-${{ runner.os }}-${{ runner.arch }}
- name: Build
run: make build
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: offsets-python
merge-multiple: true
- name: Print the layout files
run: tree offsets-python
- name: Merge the layout files
run: |
target_archs=(
amd64
arm64
)
rm -rf pkg/python/layout
rm -rf pkg/python/initialstate
for arch in "${target_archs[@]}"; do
mkdir -p pkg/python/layout/"${arch}"
./mergelayout -o pkg/python/layout/"${arch}" offsets-python/"${arch}"/layout/python_*.yaml
mkdir -p pkg/python/initialstate"/${arch}"
./mergelayout -o pkg/python/initialstate/"${arch}" offsets-python/"${arch}"/initialstate/python_*.yaml
done
# If there are no changes (i.e. no diff exists with the checked-out base branch),
# no pull request will be created and the action exits silently.
- name: Create a pull-request
if: github.event_name != 'pull_request'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update python layouts"
title: "chore: Update Python layouts"
branch: update-python-offsets-${{ github.run_number }}
add-paths: pkg/python/layout, pkg/python/initialstate
base: main
labels: chore
draft: false
delete-branch: true