Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use matrix instead of separate jobs in generated CI workflow #225

Open
djc opened this issue Oct 27, 2023 · 2 comments
Open

Use matrix instead of separate jobs in generated CI workflow #225

djc opened this issue Oct 27, 2023 · 2 comments

Comments

@djc
Copy link

djc commented Oct 27, 2023

Currently the generated CI workflow has something like this:

jobs:
  linux:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --find-interpreter
          sccache: 'true'
          manylinux: auto
      - name: Upload wheels
        uses: actions/upload-artifact@v3
        with:
          name: wheels
          path: dist

  windows:
    runs-on: windows-latest
    strategy:
      matrix:
        target: [x64, x86]
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.10'
          architecture: ${{ matrix.target }}
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --find-interpreter
          sccache: 'true'
      - name: Upload wheels
        uses: actions/upload-artifact@v3
        with:
          name: wheels
          path: dist

  macos:
    runs-on: macos-latest
    strategy:
      matrix:
        target: [x86_64, aarch64]
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --find-interpreter
          sccache: 'true'
      - name: Upload wheels
        uses: actions/upload-artifact@v3
        with:
          name: wheels
          path: dist

The only difference between the different jobs seems to be the use of manylinux: auto? Assuming that that would do the right thing on non-Linux platform, it would be nice to use a matrix instead to use one job that runs over a matrix of platforms and targets. Especially since we can then also set a python variable in the matrix to produce wheels for multiple Python versions.

Here's my adapted version:

  build:
    strategy:
      matrix:
        target: [x86_64]
        python: [3.9, "3.10", "3.11"]
        include:
          - os: ubuntu-latest
            target: x86_64
          - os: windows-latest
            target: x64
          - os: macos-latest
            target: aarch64

    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python }}
      - name: Build wheels
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --find-interpreter
          sccache: 'true'
          manylinux: auto
      - name: Upload wheels
        uses: actions/upload-artifact@v3
        with:
          name: wheels
          path: dist

(Personally I think it makes sense to avoid generating binaries for pretty obscure platforms by default.)

@djc
Copy link
Author

djc commented Oct 27, 2023

(So far I'm not actually getting my proposed matrix to work, seems like there's a bug with the matrix setup.)

@davidhewitt
Copy link
Member

Closely related to #166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants