Skip to content

Updated CI workflows to avoid race conditions on PRs with concurrency label #6807

Updated CI workflows to avoid race conditions on PRs with concurrency label

Updated CI workflows to avoid race conditions on PRs with concurrency label #6807

Workflow file for this run

name: Wheel::Any::None
# **What it does**: Builds a pure python wheel for Linux (ubuntu-latest) and store it as an artifact.
# Python version: 3.9.
# **Why we have it**: To test the wheel build in the python layer, with no compilation.
# **Who does it impact**: Wheels to be uploaded to PyPI.
on:
pull_request:
push:
branches:
- master
release:
types: [published]
workflow_dispatch:
concurrency:
group: wheel_noarch-${{ github.ref }}
cancel-in-progress: true
jobs:
determine_runner:
name: Determine runner type to use
uses: ./.github/workflows/determine-workflow-runner.yml
with:
default_runner: ubuntu-latest
build-pure-python-wheel:
if: |
github.event_name != 'pull_request' ||
contains(github.event.pull_request.labels.*.name, 'ci:build_wheels') ||
github.event_name == 'workflow_dispatch'
needs: [determine_runner]
strategy:
matrix:
pl_backend: ["lightning_gpu", "lightning_kokkos", "lightning_qubit"]
timeout-minutes: 30
name: Linux - Pure Python wheels - ${{ matrix.pl_backend }} (Python 3.9)
runs-on: ${{ needs.determine_runner.outputs.runner_group }}
steps:
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v4
with:
path: main
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Install CMake and ninja
run: |
python -m pip install --upgrade cmake ninja
- name: Build wheels
if: ${{ matrix.pl_backend == 'lightning_qubit'}}
run: |
python -m pip install --upgrade pip wheel
cd main
PL_BACKEND="${{ matrix.pl_backend }}" python setup.py bdist_wheel
env:
SKIP_COMPILATION: True
- name: Validate wheels
if: ${{ matrix.pl_backend == 'lightning_qubit'}}
run: |
python -m pip install twine
python -m twine check main/dist/*.whl
- uses: actions/upload-artifact@v3
if: |
matrix.pl_backend == 'lightning_qubit' &&
(github.event_name == 'release' || github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master')
with:
name: pure-python-wheels-${{ matrix.pl_backend }}.zip
path: main/dist/*.whl
- name: Build source dist
if: ${{ matrix.pl_backend != 'lightning_qubit'}}
run: |
python -m pip install --upgrade pip wheel
cd main
PL_BACKEND="${{ matrix.pl_backend }}" python setup.py sdist
env:
SKIP_COMPILATION: True
- uses: actions/upload-artifact@v3
if: ${{ matrix.pl_backend != 'lightning_qubit' && (github.event_name == 'release' || github.ref == 'refs/heads/master') }}
with:
name: pure-source-dist-${{ matrix.pl_backend }}.tar.gz
path: main/dist/*.tar.gz
upload-pypi:
needs: build-pure-python-wheel
strategy:
matrix:
pl_backend: ["lightning_gpu", "lightning_kokkos", "lightning_qubit"]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
if: |
matrix.pl_backend == 'lightning_qubit' &&
github.event_name == 'release'
with:
name: pure-python-wheels-${{ matrix.pl_backend }}.zip
path: dist
- name: Upload wheels to PyPI
if: ${{ matrix.pl_backend == 'lightning_qubit' && github.event_name == 'release' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- uses: actions/download-artifact@v3
if: ${{ matrix.pl_backend != 'lightning_qubit' && github.event_name == 'release' }}
with:
name: pure-source-dist-${{ matrix.pl_backend }}.tar.gz
path: dist