Skip to content

Commit

Permalink
Merge pull request #247 from Cadair/publish-runs-on
Browse files Browse the repository at this point in the history
Add support for customising runs-on with publish
  • Loading branch information
astrofrog authored Nov 26, 2024
2 parents 8f5a7d9 + a2acf7b commit d68193b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
- run: python -m pip install PyYAML click
- run: echo $LOAD_BUILD_TARGETS_SCRIPT | base64 --decode > load_build_targets.py
env:
LOAD_BUILD_TARGETS_SCRIPT: aW1wb3J0IGpzb24KaW1wb3J0IG9zCmltcG9ydCByZQoKaW1wb3J0IGNsaWNrCmltcG9ydCB5YW1sCgpNQUNISU5FX1RZUEUgPSB7CiAgICAibGludXgiOiAidWJ1bnR1LWxhdGVzdCIsCiAgICAibWFjb3MiOiAibWFjb3MtMTIiLAogICAgIndpbmRvd3MiOiAid2luZG93cy1sYXRlc3QiLAp9Ck0xX1JVTk5FUiA9ICJtYWNvcy0xNCIKCkNJQldfQlVJTEQgPSBvcy5lbnZpcm9uLmdldCgiQ0lCV19CVUlMRCIsICIqIikKQ0lCV19BUkNIUyA9IG9zLmVudmlyb24uZ2V0KCJDSUJXX0FSQ0hTIiwgImF1dG8iKQoKCkBjbGljay5jb21tYW5kKCkKQGNsaWNrLm9wdGlvbigiLS10YXJnZXRzIiwgZGVmYXVsdD0iIikKZGVmIGxvYWRfYnVpbGRfdGFyZ2V0cyh0YXJnZXRzKToKICAgICIiIlNjcmlwdCB0byBsb2FkIGNpYnVpbGR3aGVlbCB0YXJnZXRzIGZvciBHaXRIdWIgQWN0aW9ucyB3b3JrZmxvdy4iIiIKICAgICMgTG9hZCBsaXN0IG9mIHRhcmdldHMKICAgIHRhcmdldHMgPSB5YW1sLmxvYWQodGFyZ2V0cywgTG9hZGVyPXlhbWwuQmFzZUxvYWRlcikKICAgIHByaW50KGpzb24uZHVtcHModGFyZ2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gICAgICJDSUJXX0FSQ0hTIjogZ2V0X2NpYndfYXJjaHModGFyZ2V0KSwKICAgICAgICAiYXJ0aWZhY3QtbmFtZSI6IGdldF9hcnRpZmFjdF9uYW1lKHRhcmdldCksCiAgICAgICAgKipleHRyYV90YXJnZXRfYXJncywKICAgIH0KCgppZiBfX25hbWVfXyA9PSAiX19tYWluX18iOgogICAgbG9hZF9idWlsZF90YXJnZXRzKCkK
- id: set-outputs
run: python load_build_targets.py --targets "${{ inputs.targets }}"
shell: sh
Expand All @@ -132,7 +132,7 @@ jobs:
build_wheels:
name: Build ${{ matrix.target }} wheels
needs: [targets]
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.runs-on }}
timeout-minutes: ${{ inputs.timeout-minutes }}
strategy:
fail-fast: ${{ inputs.fail-fast }}
Expand All @@ -144,8 +144,13 @@ jobs:
lfs: true
submodules: ${{ inputs.submodules }}
ref: ${{ inputs.checkout_ref }}
- name: Get machine arch
if: ${{ runner.os == 'Linux' }}
id: uname_m
run: |
echo "uname_m=$(uname -m)" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
if: ${{ matrix.CIBW_ARCHS == 'aarch64' }}
if: ${{ runner.os == 'Linux' && (matrix.CIBW_ARCHS != 'auto' && matrix.CIBW_ARCHS != steps.uname_m.outputs.uname_m) }}
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
with:
platforms: all
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
- cp3?-win_amd64
- cp312-manylinux_aarch64
- cp313-manylinux_x86_64
- target: cp311-manylinux_ppc64le
runs-on: ubuntu-latest
timeout-minutes: 30
release_sdist_only:
uses: ./.github/workflows/publish.yml
Expand Down
9 changes: 7 additions & 2 deletions tools/load_build_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_cibw_build(target):


def get_cibw_archs(target):
for arch in ["aarch64", "arm64", "universal2"]:
for arch in ["aarch64", "ppc64le", "s390x", "armv7l", "arm64", "universal2"]:
if target.endswith(arch):
return arch
return CIBW_ARCHS
Expand All @@ -66,12 +66,17 @@ def get_artifact_name(target):


def get_matrix_item(target):
extra_target_args = {}
if isinstance(target, dict):
extra_target_args = target
target = extra_target_args.pop("target")
return {
"target": target,
"os": get_os(target),
"runs-on": get_os(target),
"CIBW_BUILD": get_cibw_build(target),
"CIBW_ARCHS": get_cibw_archs(target),
"artifact-name": get_artifact_name(target),
**extra_target_args,
}


Expand Down

0 comments on commit d68193b

Please sign in to comment.