|
| 1 | +name: Generate Python (end-of-life versions) |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - release |
| 8 | + paths: |
| 9 | + - ".github/workflows/generate-python.yml" |
| 10 | + - "pkg/python/**" |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + generate: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + timeout-minutes: 20 |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + python-version: [ |
| 24 | + 2.7, 2.7.15, 2.7.16, 2.7.17, 2.7.18, |
| 25 | + 3.3, 3.3.6, 3.3.7, |
| 26 | + 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, |
| 27 | + 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, |
| 28 | + 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, |
| 29 | + 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, |
| 30 | + ] |
| 31 | + arch: [amd64, arm64] |
| 32 | + steps: |
| 33 | + - name: Check out the code |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Install devbox |
| 37 | + uses: jetpack-io/[email protected] |
| 38 | + with: |
| 39 | + enable-cache: true |
| 40 | + |
| 41 | + - name: Setup devbox |
| 42 | + run: devbox run -- echo "done!" |
| 43 | + |
| 44 | + - name: Load devbox shellenv |
| 45 | + uses: HatsuneMiku3939/direnv-action@v1 |
| 46 | + with: |
| 47 | + direnvVersion: 2.32.3 |
| 48 | + |
| 49 | + - name: Set up Go tool cache |
| 50 | + uses: actions/cache@v4 |
| 51 | + with: |
| 52 | + path: ~/.devbox/go |
| 53 | + key: devbox-go-tools.cache-${{ runner.os }}-${{ runner.arch }} |
| 54 | + |
| 55 | + - name: Build |
| 56 | + run: make build |
| 57 | + |
| 58 | + - name: Set up QEMU |
| 59 | + uses: docker/setup-qemu-action@v3 |
| 60 | + with: |
| 61 | + platforms: linux/amd64,linux/arm64 |
| 62 | + |
| 63 | + - name: Set up cache for downloaded files |
| 64 | + uses: actions/cache@v4 |
| 65 | + with: |
| 66 | + path: python-binaries |
| 67 | + key: python-downloaded-${{ runner.os }}-${{ matrix.arch }} |
| 68 | + restore-keys: | |
| 69 | + python-downloaded-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.python-version }} |
| 70 | +
|
| 71 | + - name: Generate Python Offsets for ${{ matrix.python-version }} on ${{ matrix.arch }} |
| 72 | + run: | |
| 73 | + export python_version="${{ matrix.python-version }}" |
| 74 | +
|
| 75 | + if ! ls python-binaries/${{ matrix.arch }}/${{ matrix.python-version }}/libpython"${python_version%.*}"*.so.1.0 1> /dev/null 2>&1; then |
| 76 | + mkdir -p python-binaries/${{ matrix.arch }}/${{ matrix.python-version }} |
| 77 | + 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) |
| 78 | + fi |
| 79 | +
|
| 80 | + mkdir -p offsets-python/${{ matrix.arch }} |
| 81 | + ./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 |
| 82 | +
|
| 83 | + git add offsets-python |
| 84 | +
|
| 85 | + cp $(git diff --name-only --staged | xargs) offsets-python || echo "No new or modified files - offsets |
| 86 | + are up to date" |
| 87 | +
|
| 88 | + - name: Upload Offsets |
| 89 | + uses: actions/upload-artifact@v4 |
| 90 | + with: |
| 91 | + if-no-files-found: ignore |
| 92 | + name: python-${{ matrix.arch }}-${{ matrix.python-version }} |
| 93 | + path: offsets-python |
| 94 | + retention-days: 1 |
| 95 | + |
| 96 | + merge-and-create-branch: |
| 97 | + runs-on: ubuntu-latest |
| 98 | + needs: generate |
| 99 | + permissions: |
| 100 | + contents: write |
| 101 | + pull-requests: write |
| 102 | + steps: |
| 103 | + - name: Check out the code |
| 104 | + uses: actions/checkout@v4 |
| 105 | + |
| 106 | + - name: Install devbox |
| 107 | + uses: jetpack-io/[email protected] |
| 108 | + with: |
| 109 | + enable-cache: true |
| 110 | + |
| 111 | + - name: Setup devbox |
| 112 | + run: devbox run -- echo "done!" |
| 113 | + |
| 114 | + - name: Load devbox shellenv |
| 115 | + uses: HatsuneMiku3939/direnv-action@v1 |
| 116 | + with: |
| 117 | + direnvVersion: 2.32.3 |
| 118 | + |
| 119 | + - name: Set up Go tool cache |
| 120 | + uses: actions/cache@v4 |
| 121 | + with: |
| 122 | + path: ~/.devbox/go |
| 123 | + key: devbox-go-tools.cache-${{ runner.os }}-${{ runner.arch }} |
| 124 | + |
| 125 | + - name: Build |
| 126 | + run: make build |
| 127 | + |
| 128 | + - name: Download all artifacts |
| 129 | + uses: actions/download-artifact@v4 |
| 130 | + with: |
| 131 | + path: offsets-python |
| 132 | + merge-multiple: true |
| 133 | + |
| 134 | + - name: Print the layout files |
| 135 | + run: tree offsets-python |
| 136 | + |
| 137 | + - name: Merge the layout files |
| 138 | + run: | |
| 139 | + target_archs=( |
| 140 | + amd64 |
| 141 | + arm64 |
| 142 | + ) |
| 143 | +
|
| 144 | + rm -rf pkg/python/layout |
| 145 | + rm -rf pkg/python/initialstate |
| 146 | + for arch in "${target_archs[@]}"; do |
| 147 | + mkdir -p pkg/python/layout/"${arch}" |
| 148 | + ./mergelayout -o pkg/python/layout/"${arch}" offsets-python/"${arch}"/layout/python_*.yaml |
| 149 | +
|
| 150 | + mkdir -p pkg/python/initialstate"/${arch}" |
| 151 | + ./mergelayout -o pkg/python/initialstate/"${arch}" offsets-python/"${arch}"/initialstate/python_*.yaml |
| 152 | + done |
| 153 | +
|
| 154 | + # If there are no changes (i.e. no diff exists with the checked-out base branch), |
| 155 | + # no pull request will be created and the action exits silently. |
| 156 | + - name: Create a pull-request |
| 157 | + if: github.event_name != 'pull_request' |
| 158 | + uses: peter-evans/create-pull-request@v6 |
| 159 | + with: |
| 160 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 161 | + commit-message: "chore: update python layouts" |
| 162 | + title: "chore: Update Python layouts" |
| 163 | + branch: update-python-offsets-${{ github.run_number }} |
| 164 | + add-paths: pkg/python/layout, pkg/python/initialstate |
| 165 | + base: main |
| 166 | + labels: chore |
| 167 | + draft: false |
| 168 | + delete-branch: true |
0 commit comments