diff --git a/.github/workflows/build-astropy.yml b/.github/workflows/build-astropy.yml new file mode 100644 index 00000000..15fa5fa3 --- /dev/null +++ b/.github/workflows/build-astropy.yml @@ -0,0 +1,115 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on the wheel job of +# https://github.com/astropy/astropy/blob/v8.0.1/.github/workflows/publish.yml, +# which calls OpenAstronomy/github-actions-workflows' publish.yml. +name: Build astropy wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'astropy version to build (git tag without leading v, e.g. 8.0.1)' + required: true + default: '8.0.1' + pull_request: + paths: + - '.github/workflows/build-astropy.yml' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || '8.0.1' }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + # `inputs.version` is empty on pull_request events; default to 8.0.1 there. + ASTROPY_VERSION: ${{ inputs.version || '8.0.1' }} + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + # Upstream's wheel job sets this; pyproject.toml's environment-pass forwards it + # into the container, where extension-helpers turns it into an abi3 build. + EXTENSION_HELPERS_PY_LIMITED_API: 'cp311' + +jobs: + # Upstream also builds musllinux_x86_64, dropped here: numpy is a build and a + # runtime requirement and we publish no musllinux_riscv64 numpy wheel. + build_wheels: + name: Build astropy ${{ inputs.version || '8.0.1' }} cp311-abi3-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 720 + + steps: + - name: Checkout astropy v${{ env.ASTROPY_VERSION }} + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + repository: astropy/astropy + ref: v${{ env.ASTROPY_VERSION }} + persist-credentials: false + + - name: Build wheels + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + output-dir: wheelhouse/ + env: + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # One abi3 wheel, built on cp311 -- the oldest interpreter its tag + # claims -- and re-tested on the newer ones via find_compatible_wheel. + CIBW_BUILD: >- + cp311-manylinux_riscv64 cp312-manylinux_riscv64 + cp313-manylinux_riscv64 cp314-manylinux_riscv64 + # pyproject.toml asks for ["auto", "aarch64"], which needs emulation here. + CIBW_ARCHS: riscv64 + # numpy is a build and a runtime requirement, and only our registry has + # it for riscv64; only-binary keeps a newer PyPI release from winning the + # resolution and then compiling from sdist. + CIBW_ENVIRONMENT: >- + PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + PIP_ONLY_BINARY=numpy + SETUPTOOLS_SCM_PRETEND_VERSION_FOR_ASTROPY=${{ env.ASTROPY_VERSION }} + CIBW_TEST_EXTRAS: test + CIBW_TEST_COMMAND: >- + pytest -Wdefault --astropy-header -m "not hypothesis" + -k "not test_data_out_of_range and not test_set_locale and not TestQuantityTyping" + --strict-markers --pyargs astropy + + - name: Check wheel contents + run: | + python3 - wheelhouse/*.whl <<'EOF' + import sys, zipfile + path = sys.argv[1] + assert "-cp311-abi3-" in path, path + names = zipfile.ZipFile(path).namelist() + exts = [n for n in names if n.endswith(".abi3.so")] + assert len(exts) == 18, exts + licences = {n.split(".dist-info/licenses/", 1)[1] for n in names + if ".dist-info/licenses/" in n and not n.endswith("/")} + assert {"LICENSE.rst", "licenses/ERFA.rst", "licenses/EXPAT_LICENSE.rst", + "licenses/WCSLIB_LICENSE.rst"} <= licences, licences + EOF + + - name: Store wheels + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: astropy-${{ env.ASTROPY_VERSION }}-cp311-abi3-manylinux_riscv64 + path: ./wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish astropy ${{ inputs.version || '8.0.1' }} to GitLab + needs: [build_wheels] + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Publish wheels and open docs PR + uses: riseproject-dev/python-wheels/actions/publish-wheels@main + with: + artifact-pattern: astropy-${{ env.ASTROPY_VERSION }}-*-manylinux_riscv64 + gitlab-username: ${{ vars.GITLAB_DEPLOY_USER }} + gitlab-token: ${{ secrets.GITLAB_DEPLOY_TOKEN }} + gitlab-project-id: ${{ vars.GITLAB_PROJECT_ID }} + gh-token: ${{ secrets.GITHUB_TOKEN }}