All libs #1
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: All libs | |
on: | |
workflow_call: | |
workflow_dispatch: | |
inputs: | |
release-number: | |
description: 'Release Number (e.g. 0.3.0)' | |
required: false | |
default: '' | |
jobs: | |
pr-build: | |
name: Build and test | |
if: startsWith(github.ref, 'refs/heads/pull-request/') | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: ['amd64', 'arm64'] | |
runs-on: ${{ startsWith(github.repository, 'NVIDIA/cudaqx') && format('linux-{0}-cpu8', matrix.platform) || 'ubuntu-latest' }} | |
container: ghcr.io/nvidia/cuda-quantum-devdeps:ext-cu12.0-gcc11-main | |
permissions: | |
actions: write | |
contents: read | |
pull-requests: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
set-safe-directory: true | |
- name: Lookup PR info | |
id: get-pr-info | |
env: | |
GH_TOKEN: ${{ github.token }} | |
uses: nv-gha-runners/get-pr-info@main | |
- name: Export PR info | |
id: export-pr-info | |
run: | | |
echo "pr_number=${{ fromJSON(steps.get-pr-info.outputs.pr-info).number }}" >> $GITHUB_OUTPUT | |
- name: Set release number | |
id: set-release-number | |
run: | | |
# If the user provided a release number, use that. Else if we are | |
# running this from a release branch like releases/v0.3.0, set the | |
# release number from that (e.g. 0.3.0 without the 'v' prefix). | |
if [ -n "${{ inputs.release-number }}" ]; then | |
echo "CUDAQX_QEC_VERSION=${{ inputs.release-number }}" >> $GITHUB_ENV | |
echo "CUDAQX_SOLVERS_VERSION=${{ inputs.release-number }}" >> $GITHUB_ENV | |
# And output to the GitHub Actions summary. | |
echo "Setting CUDAQX_QEC_VERSION=$CUDAQX_QEC_VERSION" >> $GITHUB_STEP_SUMMARY | |
echo "Setting CUDAQX_SOLVERS_VERSION=$CUDAQX_SOLVERS_VERSION" >> $GITHUB_STEP_SUMMARY | |
elif [[ "${{ github.ref_name }}" =~ releases\/v([0-9]+\.[0-9]+\.[0-9]+) ]]; then | |
VERSION="${BASH_REMATCH[1]}" | |
echo "CUDAQX_QEC_VERSION=$VERSION" >> $GITHUB_ENV | |
echo "CUDAQX_SOLVERS_VERSION=$VERSION" >> $GITHUB_ENV | |
# And output to the GitHub Actions summary. | |
echo "Setting CUDAQX_QEC_VERSION=$CUDAQX_QEC_VERSION" >> $GITHUB_STEP_SUMMARY | |
echo "Setting CUDAQX_SOLVERS_VERSION=$CUDAQX_SOLVERS_VERSION" >> $GITHUB_STEP_SUMMARY | |
# ======================================================================== | |
# CUDA Quantum build | |
# ======================================================================== | |
- name: Get required CUDAQ version | |
id: get-cudaq-version | |
uses: ./.github/actions/get-cudaq-version | |
- name: Get CUDAQ build | |
uses: ./.github/actions/get-cudaq-build | |
with: | |
repo: ${{ steps.get-cudaq-version.outputs.repo }} | |
ref: ${{ steps.get-cudaq-version.outputs.ref }} | |
token: ${{ secrets.CUDAQ_ACCESS_TOKEN }} | |
pr-number: ${{ steps.export-pr-info.outputs.pr_number }} | |
platform: ${{ matrix.platform }} | |
# ======================================================================== | |
# Build | |
# ======================================================================== | |
- name: Install build requirements | |
run: | | |
apt install -y --no-install-recommends gfortran libblas-dev libcusolver-dev-12-0 | |
- name: Build | |
id: build | |
uses: ./.github/actions/build-lib | |
with: | |
lib: "all" | |
pr-number: ${{ steps.export-pr-info.outputs.pr_number }} | |
save-ccache: true | |
platform: ${{ matrix.platform }} | |
- name: Save build artifacts | |
if: steps.set-release-number.outputs.CUDAQX_QEC_VERSION | |
run: | | |
apt update && apt install -y --no-install-recommends zip | |
cmake --build ${{ steps.build.outputs.build-dir }} --target zip_installed_files | |
cd ${{ steps.build.outputs.build-dir }} | |
mv installed_files.zip installed_files-${{ matrix.platform }}.zip | |
- name: Upload build artifacts | |
if: steps.set-release-number.outputs.CUDAQX_QEC_VERSION | |
uses: actions/upload-artifact@v4 | |
with: | |
name: installed_files-${{ matrix.platform }}.zip | |
path: ${{ steps.build.outputs.build-dir }}/installed_files.zip | |
# ======================================================================== | |
# Run tests | |
# ======================================================================== | |
# | |
- name: Run tests | |
run: cmake --build ${{ steps.build.outputs.build-dir }} --target run_tests | |
# ======================================================================== | |
# Run python tests | |
# ======================================================================== | |
- name: Install python requirements | |
run: pip install numpy pytest cupy-cuda12x cuquantum-python-cu12 | |
- name: Run Python tests | |
run: cmake --build ${{ steps.build.outputs.build-dir }} --target run_python_tests | |
# ======================================================================== | |
# Run example tests | |
# ======================================================================== | |
- name: Run example tests | |
run: bash scripts/ci/test_examples.sh all | |