.github/workflows/python.yml: Use Python 3.11 for Windows ARM64. #662
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: Python | |
| on: | |
| push: | |
| branches-ignore: [gh-pages] | |
| paths: | |
| - ".github/workflows/python.yml" | |
| - "python/**" | |
| - "!python/README.md" | |
| - 'c/Make*' | |
| - 'c/*.mk' | |
| - 'c/**/*.[ch]p?p?' | |
| pull_request: | |
| branches-ignore: [gh-pages] | |
| paths: | |
| - ".github/workflows/python.yml" | |
| - "python/**" | |
| - "!python/README.md" | |
| - 'c/Make*' | |
| - 'c/*.mk' | |
| - 'c/**/*.[ch]p?p?' | |
| # Manual run | |
| workflow_dispatch: | |
| release: | |
| types: | |
| - published | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| run-tests: | |
| timeout-minutes: 15 | |
| if: "! contains(github.event.head_commit.message, '[skip ci]')" | |
| name: Test ${{ matrix.os }} (${{ matrix.python-version }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| # When set to true, GitHub cancels all in-progress jobs if any matrix job fails. | |
| fail-fast: false | |
| matrix: | |
| os: [ ubuntu-latest ] | |
| # This must be kept in sync with pyproject.toml and mooplot | |
| # macos-13 is an intel runner, macos-14 is apple silicon | |
| python-version: ['3.10', '3.11', '3.12'] | |
| include: | |
| - os: windows-latest | |
| python-version: '3.10' | |
| - os: macos-14 | |
| python-version: '3.10' | |
| - os: macos-13 | |
| python-version: '3.10' | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python3 -m pip install --upgrade pip | |
| python3 -m pip install tox tox-gh-actions | |
| - name: Run tox | |
| run: tox | |
| working-directory: python | |
| build_sdist: | |
| timeout-minutes: 10 | |
| needs: run-tests | |
| if: "! contains(github.event.head_commit.message, '[skip ci]')" | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| python-version: ['3.10'] | |
| os: [ubuntu-latest] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python3 -m pip install --upgrade pip | |
| python3 -m pip install --upgrade build | |
| - name: Build the packages | |
| run: python3 -m build | |
| working-directory: python | |
| - name: Publish artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: moocore-wheels-sdist-${{ matrix.os }}-${{ matrix.python-version }} | |
| path: python/dist/*.tar.gz | |
| build-doc: | |
| name: Build documentation | |
| needs: build_sdist | |
| if: "! contains(github.event.head_commit.message, '[skip ci]')" | |
| permissions: | |
| contents: write | |
| concurrency: # Recommended if you intend to make multiple deployments in quick succession. | |
| group: web-${{ github.workflow }}-${{ github.ref }} | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout sources 🛎 | |
| uses: actions/checkout@v5 | |
| - name: Setup Python 3.10 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.10' | |
| cache: 'pip' | |
| - name: Ensure Pip and Build | |
| run: | | |
| python3 -m pip install --upgrade pip | |
| python3 -m pip install --upgrade build | |
| - name: Build the package | |
| run: python3 -m build | |
| working-directory: python | |
| - name: install the package | |
| run: python3 -m pip install . | |
| working-directory: python | |
| - name: install the doc build requirements | |
| run: | | |
| python3 -m pip install .[docs] | |
| working-directory: python | |
| - name: Build the docs 🔧 | |
| run: | | |
| make -C doc html | |
| working-directory: python | |
| - name: Deploy 🚀 | |
| if: success() && runner.os == 'Linux' && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| folder: python/doc/_build/html/ # The folder the action should deploy. | |
| target-folder: python | |
| single-commit: true | |
| clean: true | |
| coverage: | |
| timeout-minutes: 15 | |
| needs: build-doc | |
| if: "! contains(github.event.head_commit.message, '[skip ci]')" | |
| name: Coverage ${{ matrix.os }} (${{ matrix.python-version }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| # When set to true, GitHub cancels all in-progress jobs if any matrix job fails. | |
| matrix: | |
| os: [ubuntu-latest] | |
| python-version: ['3.10'] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python3 -m pip install --upgrade pip | |
| python3 -m pip install tox tox-gh-actions | |
| working-directory: python | |
| - name: Run coverage using tox | |
| run: tox -e cov | |
| working-directory: python | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| fail_ci_if_error: true | |
| verbose: true | |
| flags: python | |
| token: ${{secrets.CODECOV_TOKEN}} | |
| directory: python | |
| wheels: | |
| name: 🎡 Build wheels on ${{ matrix.os }} | |
| needs: coverage | |
| runs-on: ${{ matrix.os }} | |
| if: "! contains(github.event.head_commit.message, '[skip ci]')" | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # FIXME: add windows-11-arm and ubuntu-24.04-arm | |
| # https://github.com/scipy/scipy/blob/6b79a4dec1f9ca2db4e49c328d04d293880991c6/.github/workflows/wheels.yml#L78 | |
| # https://github.com/numpy/numpy-release/blob/main/.github/workflows/wheels.yml | |
| # macos-14 is Apple Silicon (arm64), but we build an universal2 wheel. | |
| # The configuration of cibuildwheel can be found in pyproject.toml | |
| os: [ubuntu-22.04, ubuntu-22.04-arm, windows-2025, macos-14] | |
| python-version: ['3.10'] | |
| include: | |
| # 3.11 is the earliest version on windows-arm | |
| - os: windows-11-arm | |
| python-version: "3.11" | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Setup LLVM for Windows ARM64 | |
| if: ${{ matrix.os == 'windows-11-arm' }} | |
| uses: ./.github/windows_arm64_steps | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v2.23.3 | |
| with: | |
| package-dir: python | |
| output-dir: wheelhouse | |
| - name: List wheels | |
| run: ls wheelhouse/*.whl | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: moocore-wheels-${{ matrix.os }}-${{ matrix.python-version }}-${{ strategy.job-index }} | |
| path: wheelhouse/*.whl | |
| upload_pypi: | |
| name: Publish Python 🐍 distribution 📦 to PyPI | |
| needs: [wheels, build_sdist] | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/moocore | |
| permissions: | |
| id-token: write | |
| if: github.event_name == 'release' && github.event.action == 'published' && startsWith(github.ref, 'refs/tags/v') | |
| # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) | |
| # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| # unpacks all moocore artifacts into dist/ | |
| pattern: moocore-wheels-* | |
| path: dist | |
| merge-multiple: true | |
| - name: Display structure of downloaded files | |
| run: ls -R dist | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| verbose: true | |
| # To test: repository-url: https://test.pypi.org/legacy/ | |
| upload: | |
| name: Store wheels | |
| needs: wheels | |
| if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: wheelhouse | |
| pattern: moocore-wheels-* | |
| merge-multiple: true | |
| - name: List wheels | |
| run: ls -l wheelhouse/*.whl | |
| - name: Upload wheels | |
| if: success() && runner.os == 'Linux' && github.event_name == 'push' | |
| run: | | |
| git config --local user.email "actions@github.com" | |
| git config --local user.name "GitHub Actions" | |
| git checkout --orphan new-wheels | |
| git rm -rf . | |
| mv wheelhouse/*.whl . | |
| git add *.whl | |
| git commit --allow-empty -m "Store Python wheels from @ $GITHUB_SHA" | |
| git branch -D wheels | |
| git branch -m wheels | |
| git push --force origin wheels | |
| shell: bash {0} |