From 84998ebd7d68d95a176eb36ab35591724a9f5421 Mon Sep 17 00:00:00 2001 From: Bruno Schmitt Date: Tue, 28 Mar 2023 03:03:24 +0200 Subject: [PATCH] [ci] Add workflows --- .github/actions/build-cudaq/action.yml | 63 +++++++++++++ .github/actions/build-cudaq/build_cudaq.sh | 37 ++++++++ .github/actions/check-formatting/action.yml | 61 +++++++++++++ .github/actions/get-llvm-build-id/action.yml | 36 ++++++++ .github/actions/get-llvm-build/action.yml | 64 +++++++++++++ .github/actions/get-llvm-build/build_llvm.sh | 64 +++++++++++++ .github/workflows/build_and_test.yml | 94 ++++++++++++++++++++ .github/workflows/build_dev_image.yml | 88 ++++++++++++++++++ .github/workflows/cleanup_cache.yml | 71 +++++++++++++++ .github/workflows/docker/Dockerfile | 52 +++++++++++ .github/workflows/docker/entrypoint.sh | 12 +++ .github/workflows/llvm_bump.yml | 80 +++++++++++++++++ 12 files changed, 722 insertions(+) create mode 100644 .github/actions/build-cudaq/action.yml create mode 100755 .github/actions/build-cudaq/build_cudaq.sh create mode 100644 .github/actions/check-formatting/action.yml create mode 100644 .github/actions/get-llvm-build-id/action.yml create mode 100644 .github/actions/get-llvm-build/action.yml create mode 100644 .github/actions/get-llvm-build/build_llvm.sh create mode 100644 .github/workflows/build_and_test.yml create mode 100644 .github/workflows/build_dev_image.yml create mode 100644 .github/workflows/cleanup_cache.yml create mode 100644 .github/workflows/docker/Dockerfile create mode 100755 .github/workflows/docker/entrypoint.sh create mode 100644 .github/workflows/llvm_bump.yml diff --git a/.github/actions/build-cudaq/action.yml b/.github/actions/build-cudaq/action.yml new file mode 100644 index 0000000000..d5e6b7d42f --- /dev/null +++ b/.github/actions/build-cudaq/action.yml @@ -0,0 +1,63 @@ +name: 'Build CUDA Quantum' +description: 'Build CUDA Quantum using CCache' + +inputs: + cc: + description: 'C compiler executable' + required: true + cxx: + description: 'C++ compiler executable' + required: true + build-type: + description: 'Build type (e.g., Debug, Release)' + required: true + llvm-prefix: + description: 'LLVM installation prefix' + required: true + +runs: + using: "composite" + steps: + - name: CCache key + id: ccache-key + run: | + echo "base_key=cudaq-${{ runner.os }}-${{ matrix.compiler.cc }}-${{ matrix.compiler.build-type }}" >> $GITHUB_OUTPUT + if [ ${{ github.ref }} != 'refs/heads/main' ]; then + echo "pr_key=-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + fi + shell: bash + + - name: Apt-get update + run: apt-get update + shell: bash + + - name: Set up CCache + uses: hendrikmuhs/ccache-action@v1.2 + with: + append-timestamp: false + key: ${{ steps.ccache-key.outputs.base_key }}${{ steps.ccache-key.outputs.pr_key }} + restore-keys: ${{ steps.ccache-key.outputs.base_key }} + + - name: Build + run: .github/actions/build-cudaq/build_cudaq.sh ${{ inputs.llvm-prefix }} ${{ inputs.build-type }} ${{ inputs.cc }} ${{ inputs.cxx }} ccache + shell: bash + + # We need to remove any previous cache entry so that CCache can write a new + # cache entry for this build + - name: Cleanup cache + if: ${{ github.ref == 'refs/heads/main' }} + env: + GH_TOKEN: ${{ github.token }} + run: | + apt-get install -y --no-install-recommends gh + gh extension install actions/gh-actions-cache + + REPO=${{ github.repository }} + BRANCH=${{ github.ref }} + KEYS=$(gh actions-cache list --key ccache-${{ steps.ccache-key.outputs.base_key }} -R $REPO -B $BRANCH | cut -f 1 ) + + for key in $KEYS + do + gh actions-cache delete $key -R ${{ github.repository }} -B $BRANCH --confirm + done + shell: bash diff --git a/.github/actions/build-cudaq/build_cudaq.sh b/.github/actions/build-cudaq/build_cudaq.sh new file mode 100755 index 0000000000..20b2baaf52 --- /dev/null +++ b/.github/actions/build-cudaq/build_cudaq.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# ============================================================================ # +# Copyright (c) 2022 - 2023 NVIDIA Corporation & Affiliates. # +# All rights reserved. # +# # +# This source code and the accompanying materials are made available under # +# the terms of the Apache License 2.0 which accompanies this distribution. # +# ============================================================================ # + +# This script is intended to be called from the github workflows. + +LLVM_INSTALL_PREFIX=${1} +BUILD_TYPE=${2} +CC=${3} +CXX=${4} +LAUNCHER=${5} + +mkdir build +cd build + +cmake .. \ + -G Ninja \ + -DCMAKE_INSTALL_PREFIX=../install \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ + -DCMAKE_C_COMPILER=$CC \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DCMAKE_C_COMPILER_LAUNCHER=$LAUNCHER \ + -DCMAKE_CXX_COMPILER_LAUNCHER=$LAUNCHER \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DMLIR_DIR=$LLVM_INSTALL_PREFIX/lib/cmake/mlir \ + -DLLVM_DIR=$LLVM_INSTALL_PREFIX/lib/cmake/llvm \ + -DLLVM_EXTERNAL_LIT=$(which lit) \ + -DLLVM_ENABLE_ASSERTIONS=ON \ + -DCUDAQ_ENABLE_PYTHON=ON + +cmake --build . --target install diff --git a/.github/actions/check-formatting/action.yml b/.github/actions/check-formatting/action.yml new file mode 100644 index 0000000000..4d79a2e12e --- /dev/null +++ b/.github/actions/check-formatting/action.yml @@ -0,0 +1,61 @@ +name: 'Check formatting' + +inputs: + llvm-prefix: + description: 'LLVM installation prefix' + required: false + default: /opt/llvm + +runs: + using: "composite" + steps: + # Choose the commit to diff against for linting. This workflow is + # triggered on both pushes and pull requests to main. Hence, we have to + # find out if the pull request target branch is set---it will only be on + # the PR triggered flow). If it's not, then compare against the last commit. + - name: Choose base commit + env: + BASE_REF: ${{ github.base_ref }} + run: | + if [ -z "$BASE_REF" ]; then + DIFF_COMMIT_NAME="HEAD^" + else + DIFF_COMMIT_NAME="$BASE_REF" + fi + echo "DIFF_COMMIT_NAME=$DIFF_COMMIT_NAME" >> $GITHUB_ENV + shell: sh + + # We did a shallow clone, and thus we need to make sure to fetch the base + # commit. + - name: Fetch base commit + run: | + if echo "$DIFF_COMMIT_NAME" | grep -q HEAD; then + DIFF_COMMIT_SHA=$(git rev-parse $DIFF_COMMIT_NAME) + else + git fetch --recurse-submodules=no origin $DIFF_COMMIT_NAME + DIFF_COMMIT_SHA=$(git rev-parse origin/$DIFF_COMMIT_NAME) + fi + echo "DIFF_COMMIT_SHA=$DIFF_COMMIT_SHA" >> $GITHUB_ENV + shell: sh + + - name: clang-format + run: | + cp ${{ inputs.llvm-prefix }}/bin/git-clang-format /usr/bin/ + git config clangFormat.binary ${{ inputs.llvm-prefix }}/bin/clang-format + if ! git clang-format $DIFF_COMMIT_SHA -- ':!:tpls/*' ':!:test'; then + git diff --ignore-submodules > clang-format.patch + echo "::error::Clang-format found formatting problems." \ + "Check the uploaded artifact." + exit 1 + fi + echo "Clang-format found no formatting problems" + exit 0 + shell: sh + + - name: Upload format patches + uses: actions/upload-artifact@v3 + continue-on-error: true + if: ${{ failure() }} + with: + name: clang-format-patch + path: clang-*.patch diff --git a/.github/actions/get-llvm-build-id/action.yml b/.github/actions/get-llvm-build-id/action.yml new file mode 100644 index 0000000000..ce0923529e --- /dev/null +++ b/.github/actions/get-llvm-build-id/action.yml @@ -0,0 +1,36 @@ +name: 'Get LLVM build identifier' + +inputs: + toolchain: + description: 'Toolchain name and version (e.g., gcc-11 and clang-15)' + required: true + +outputs: + id: + description: 'LLVM build unique identifier' + value: ${{ steps.llvm-build-cache-key.outputs.key }} + +runs: + using: "composite" + steps: + - name: Get LLVM commit SHA + id: llvm-commit-sha + run: echo "sha=$(git rev-parse @:./tpls/llvm)" >> $GITHUB_OUTPUT + shell: bash + + - name: Get LLVM configuration hash + id: llvm-config-hash + env: + llvm-build-script: .github/actions/get-llvm-build/build_llvm.sh + run: | + if [[ ${{ runner.os }} == 'Linux' ]]; then + echo "hash=$(md5sum ${{ env.llvm-build-script }} | awk '{print $1}')" >> $GITHUB_OUTPUT + elif [[ ${{ runner.os }} == 'macOS' ]]; then + echo "hash=$(md5 ${{ env.llvm-build-script }} | awk '{print $4}')" >> $GITHUB_OUTPUT + fi + shell: bash + + - name: Create LLVM build cache key + id: llvm-build-cache-key + run: echo "key=llvm-${{ runner.os }}-${{ steps.llvm-commit-sha.outputs.sha }}-${{ steps.llvm-config-hash.outputs.hash }}-${{ inputs.toolchain }}" >> $GITHUB_OUTPUT + shell: bash diff --git a/.github/actions/get-llvm-build/action.yml b/.github/actions/get-llvm-build/action.yml new file mode 100644 index 0000000000..99e6f5be08 --- /dev/null +++ b/.github/actions/get-llvm-build/action.yml @@ -0,0 +1,64 @@ +name: 'Get LLVM build' +description: 'Either restore LLVM from cache or build it' + +inputs: + toolchain: + description: 'Toolchain name and version (e.g., gcc-11 and clang-15)' + required: true + cc: + description: 'C compiler executable' + required: true + cxx: + description: 'C++ compiler executable' + required: true + only-restore: + description: 'Indicates whether LLVM should be built if a cache entry is not found' + default: 'true' + required: false + +runs: + using: "composite" + steps: + - name: Get LLVM build identifier + id: get-llvm-build-id + uses: ./.github/actions/get-llvm-build-id + with: + toolchain: ${{ inputs.toolchain }} + + - name: Try to restoring LLVM from cache + id: restore-llvm-cache + uses: actions/cache/restore@v3 + with: + fail-on-cache-miss: ${{ inputs.only-restore == 'true' }} + path: tpls/llvm/install/llvm/ + key: ${{ steps.get-llvm-build-id.outputs.id }} + + - name: Set up CCache + if: steps.restore-llvm-cache.outputs.cache-hit != 'true' + uses: hendrikmuhs/ccache-action@v1.2 + with: + max-size: 500M + variant: sccache + append-timestamp: false + key: llvm-${{ runner.os }}-${{ inputs.toolchain }} + save: ${{ github.ref == 'refs/heads/main' }} + + - name: Build LLVM + if: steps.restore-llvm-cache.outputs.cache-hit != 'true' + env: + llvm-build-script: .github/actions/get-llvm-build/build_llvm.sh + run: bash ${{ env.llvm-build-script }} Release ${{ inputs.cc }} ${{ inputs.cxx }} sccache + shell: bash + + - name: Store cache key + if: steps.restore-llvm-cache.outputs.cache-hit != 'true' + run: echo "${{ steps.restore-llvm-cache.outputs.cache-primary-key }}" > tpls/llvm/install/llvm/cache-key + shell: bash + + - name: Store LLVM build in the cache + if: steps.restore-llvm-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: tpls/llvm/install/llvm/ + key: ${{ steps.restore-llvm-cache.outputs.cache-primary-key }} + diff --git a/.github/actions/get-llvm-build/build_llvm.sh b/.github/actions/get-llvm-build/build_llvm.sh new file mode 100644 index 0000000000..0eff3c07a4 --- /dev/null +++ b/.github/actions/get-llvm-build/build_llvm.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# ============================================================================ # +# Copyright (c) 2022 - 2023 NVIDIA Corporation & Affiliates. # +# All rights reserved. # +# # +# This source code and the accompanying materials are made available under # +# the terms of the Apache License 2.0 which accompanies this distribution. # +# ============================================================================ # + +# This script is intended to be called from the github workflows. + +BUILD_TYPE=${1:-"Release"} +CC=${2:-"clang"} +CXX=${3:-"clang++"} +LAUNCHER=${4:-""} + +LLVM_PROJECTS="clang;mlir" + +# LLVM library components +LLVM_COMPONENTS="cmake-exports;llvm-headers;llvm-libraries" + +# Clang library components +LLVM_COMPONENTS+=";clang-cmake-exports;clang-headers;clang-libraries;clang-resource-headers" + +# MLIR library components +LLVM_COMPONENTS+=";mlir-cmake-exports;mlir-headers;mlir-libraries" + +# Tools / Utils +LLVM_COMPONENTS+=";llvm-config;clang-format;llc;clang;mlir-tblgen;FileCheck;count;not" + +# Clone LLVM fast +LLVM_SHA=$(git rev-parse @:./tpls/llvm) +cd tpls/llvm +git init +git remote add origin https://github.com/llvm/llvm-project +git fetch --depth=1 origin $LLVM_SHA +git reset --hard FETCH_HEAD + +mkdir build +mkdir -p install/llvm + +# Configure and build +cd build +cmake ../llvm \ + -G Ninja \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ + -DCMAKE_C_COMPILER=$CC \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DCMAKE_C_COMPILER_LAUNCHER=$LAUNCHER \ + -DCMAKE_CXX_COMPILER_LAUNCHER=$LAUNCHER \ + -DCMAKE_INSTALL_PREFIX=../install/llvm \ + -DLLVM_ENABLE_PROJECTS=$LLVM_PROJECTS \ + -DLLVM_DISTRIBUTION_COMPONENTS=$LLVM_COMPONENTS \ + -DLLVM_BUILD_EXAMPLES=OFF \ + -DLLVM_ENABLE_ASSERTIONS=ON \ + -DLLVM_ENABLE_BINDINGS=OFF \ + -DLLVM_ENABLE_LLD=ON \ + -DLLVM_ENABLE_OCAMLDOC=OFF \ + -DLLVM_INSTALL_UTILS=ON \ + -DLLVM_OPTIMIZED_TABLEGEN=ON \ + -DLLVM_TARGETS_TO_BUILD="host" + +cmake --build . --target install-distribution-stripped diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml new file mode 100644 index 0000000000..8d2e54f4a9 --- /dev/null +++ b/.github/workflows/build_and_test.yml @@ -0,0 +1,94 @@ +name: Build and test + +on: + workflow_dispatch: + push: + branches: [main] + paths: + - '.github/workflows/build_and_test.yml' + - '**.cpp' + - '**.h' + - '**.in' + - '**.py' + - '**.mlir' + - '**.qtx' + - '**.qke' + - '**/CMakeLists.txt' + pull_request: + branches: [main] + types: [assigned, opened, synchronize, reopened] + paths: + - '.github/workflows/build_and_test.yml' + - '**.cpp' + - '**.h' + - '**.in' + - '**.py' + - '**.mlir' + - '**.qtx' + - '**.qke' + - '**/CMakeLists.txt' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-test: + name: Build and test + runs-on: ubuntu-latest + container: ghcr.io/${{ github.repository }}-dev:${{ matrix.compiler.cc }}-latest + permissions: + actions: write + strategy: + matrix: + compiler: + - cc: clang-15 + cxx: clang++-15 + build-type: Debug + - cc: gcc-11 + cxx: g++-11 + build-type: Release + - cc: gcc-12 + cxx: g++-12 + build-type: Release + + steps: + - name: Decompress LLVM build + run: tar --posix --use-compress-program=unzstd -C /opt -xf /llvm.tar.tzst + + - name: Get code + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Set git safe + run: git config --global --add safe.directory $PWD + + - name: Get LLVM build id + id: get-llvm-build-id + uses: ./.github/actions/get-llvm-build-id + with: + toolchain: ${{ matrix.compiler.cc }} + + - name: Check LLVM build id + run: | + LLVM_ID="$(cat /opt/llvm/cache-key)" + if [ "$LLVM_ID" != "${{ steps.get-llvm-build-id.outputs.id }}" ]; then + echo "::error::Dev image not updated yet" + exit 1 + fi + + - name: Check formatting + uses: ./.github/actions/check-formatting + + - name: Build + uses: ./.github/actions/build-cudaq + with: + cc: ${{ matrix.compiler.cc }} + cxx: ${{ matrix.compiler.cxx }} + build-type: ${{ matrix.compiler.build-type }} + llvm-prefix: /opt/llvm + + - name: Run tests + run: ctest --output-on-failure --test-dir build + diff --git a/.github/workflows/build_dev_image.yml b/.github/workflows/build_dev_image.yml new file mode 100644 index 0000000000..0e0aa2ca7c --- /dev/null +++ b/.github/workflows/build_dev_image.yml @@ -0,0 +1,88 @@ +name: Build the dev image + +on: + workflow_dispatch: + inputs: + push-image: + description: Push image to registry + required: true + type: boolean + push: + branches: [main] + paths: + - '.github/actions/get-llvm-build' + - '.github/workflows/build_dev_image.yml' + - '.github/workflows/llvm_bump.yml' + - '.github/workflows/scripts/Dockerfile' + - 'tpls/llvm' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-image: + name: Build image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + strategy: + fail-fast: false + matrix: + compiler: + - cc: clang-15 + cxx: clang++-15 + - cc: gcc-11 + cxx: g++-11 + - cc: gcc-12 + cxx: g++-12 + + steps: + - name: Get CUDA Quantum + uses: actions/checkout@v3 + + - name: Get LLVM build + uses: ./.github/actions/get-llvm-build + with: + toolchain: ${{ matrix.compiler.cc }} + cc: ${{ matrix.compiler.cc }} + cxx: ${{ matrix.compiler.cxx }} + only-restore: 'false' + + - name: Compress LLVM build + run: tar --posix --use-compress-program zstdmt -C tpls/llvm/install/ -cf llvm.tar.tzst llvm/ + + - name: Extract metadata + id: metadata + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository }}-dev + flavor: | + latest=true + prefix=${{ matrix.compiler.cc }}-,onlatest=true + tags: | + # workflow dispatch is covered by these + type=schedule,enable=true,pattern=nightly + type=ref,enable=true,event=branch + type=ref,enable=true,prefix=${{ matrix.compiler.cc }}-pr-,event=pr + type=ref,enable=true,event=tag + + - name: Log in to the container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build + uses: docker/build-push-action@v4 + with: + context: . + file: .github/workflows/docker/Dockerfile + build-args: toolchain=${{ matrix.compiler.cxx }} + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }} + platforms: linux/amd64 + push: ${{ github.event_name == 'push' || inputs.push-image == true }} + diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml new file mode 100644 index 0000000000..268fb5149c --- /dev/null +++ b/.github/workflows/cleanup_cache.yml @@ -0,0 +1,71 @@ +name: Cleanup PR caches + +on: + pull_request: + types: [closed] + paths: + - '.github/workflows/build_and_test.yml' + - '**.cpp' + - '**.h' + - '**.in' + - '**.py' + - '**.mlir' + - '**.qtx' + - '**.qke' + - '**/CMakeLists.txt' + + +jobs: + always: + runs-on: ubuntu-latest + name: Cleanup PR cache + permissions: + actions: write + steps: + - name: Get code + uses: actions/checkout@v3 + + - name: Cleanup + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh extension install actions/gh-actions-cache + + REPO=${{ github.repository }} + BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" + KEYS=$(gh actions-cache list --key ccache-cudaq- -R $REPO -B $BRANCH | cut -f 1 ) + + # Setting this to not fail the workflow while deleting cache keys. + set +e + for key in $KEYS + do + gh actions-cache delete $key -R $REPO -B $BRANCH --confirm + done + echo "Done" + + cleanup_main: + if: ${{ github.event.pull_request.merged == true && github.base_ref == 'main' }} + name: Cleanup main cache + runs-on: ubuntu-latest + permissions: + actions: write + steps: + - name: Get code + uses: actions/checkout@v3 + + - name: Cleanup + env: + GH_TOKEN: ${{ github.token }} + run: | + gh extension install actions/gh-actions-cache + + REPO=${{ github.repository }} + BRANCH="refs/heads/main" + KEYS=$(gh actions-cache list --key ccache-cudaq- -R $REPO -B $BRANCH | cut -f 1 ) + + # Setting this to not fail the workflow while deleting cache keys. + set +e + for key in $KEYS + do + gh actions-cache delete $key -R ${{ github.repository }} --confirm + done diff --git a/.github/workflows/docker/Dockerfile b/.github/workflows/docker/Dockerfile new file mode 100644 index 0000000000..7029148493 --- /dev/null +++ b/.github/workflows/docker/Dockerfile @@ -0,0 +1,52 @@ +# ============================================================================ # +# Copyright (c) 2022 - 2023 NVIDIA Corporation & Affiliates. # +# All rights reserved. # +# # +# This source code and the accompanying materials are made available under # +# the terms of the Apache License 2.0 which accompanies this distribution. # +# ============================================================================ # + +# This file builds a development image containing the necessary development +# dependencies for building and testing CUDA Quantum. This does not include the +# CUDA, OpenMPI and other dependencies that some simulator backends might +# require. These backends will be omitted from the build if this environment is +# used. + +# Build additional tools needed for CUDA Quantum documentation generation. +FROM ubuntu:22.04 as doxygenbuild + +RUN apt update \ + && apt install -y wget unzip make cmake flex bison gcc g++ python3 \ + && wget https://github.com/doxygen/doxygen/archive/9a5686aeebff882ebda518151bc5df9d757ea5f7.zip -q -O repo.zip \ + && unzip repo.zip \ + && mv doxygen* repo \ + && cmake -G "Unix Makefiles" repo \ + && cmake --build . --parallel $(nproc) --target install --config Release + +FROM ubuntu:22.04 +SHELL ["/bin/bash", "-c"] +ENTRYPOINT ["/entrypoint.sh"] + +ARG toolchain +ARG DEBIAN_FRONTEND=noninteractive + +ENV HOME=/home SHELL=/bin/bash LANG=C.UTF-8 LC_ALL=C.UTF-8 +ENV PATH="${PATH}:/usr/local/bin" + +ADD llvm.tar.tzst /llvm.tar.tzst +ADD .github/workflows/docker/entrypoint.sh /entrypoint.sh + +COPY --from=doxygenbuild /usr/local/bin/doxygen /usr/local/bin/doxygen + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + git $toolchain ninja-build cmake \ + python3 python3-pip libpython3-dev \ + libblas-dev zstd \ + && python3 -m pip install --no-cache-dir \ + lit pytest numpy sphinx==5.3.* sphinx_rtd_theme enum-tools[sphinx] \ + breathe==4.34.* myst-parser \ + && apt-get autoremove -y --purge \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + diff --git a/.github/workflows/docker/entrypoint.sh b/.github/workflows/docker/entrypoint.sh new file mode 100755 index 0000000000..1e8556026e --- /dev/null +++ b/.github/workflows/docker/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +CONTAINER_ALREADY_STARTED="CONTAINER_ALREADY_STARTED_PLACEHOLDER" +if [ ! -e $CONTAINER_ALREADY_STARTED ]; then + touch $CONTAINER_ALREADY_STARTED + echo "-- Welcome to CUDA Quantum --" + echo "Decompressing LLVM build..." + tar --posix --use-compress-program=unzstd -C /opt -xf llvm.tar.tzst + rm llvm.tar.tzst +fi + +exec "/bin/bash" diff --git a/.github/workflows/llvm_bump.yml b/.github/workflows/llvm_bump.yml new file mode 100644 index 0000000000..8b2e3a9151 --- /dev/null +++ b/.github/workflows/llvm_bump.yml @@ -0,0 +1,80 @@ +name: LLVM bump + +on: + workflow_dispatch: + pull_request: + branches: [main] + types: [opened, synchronize, reopened] + paths: + - '.github/workflows/llvm_bump.yml' + - '.github/actions/get-llvm-build' + - 'tpls/llvm' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + linux-build: + name: Linux build + runs-on: ubuntu-latest + container: ubuntu:22.04 + permissions: + actions: write + strategy: + fail-fast: false + matrix: + compiler: + - cc: clang-15 + cxx: clang++-15 + build-type: Debug + - cc: gcc-11 + cxx: g++-11 + build-type: Release + - cc: gcc-12 + cxx: g++-12 + build-type: Release + + steps: + - name: Install requirements + run: | + apt-get update + apt-get install -y --no-install-recommends software-properties-common gpg gpg-agent + add-apt-repository ppa:apt-fast/stable + apt-get install -y --no-install-recommends apt-fast + apt-fast install -y --no-install-recommends git gh cmake ninja-build ${{ matrix.compiler.cxx }} lld-15 curl libblas-dev zstd python3 python3-pip libpython3-dev + ln -s /usr/bin/ld.lld-15 /usr/bin/ld.lld + + - name: Get code + uses: actions/checkout@v3 + + - name: Set git safe + run: git config --global --add safe.directory $PWD + + - name: Get LLVM build + uses: ./.github/actions/get-llvm-build + with: + toolchain: ${{ matrix.compiler.cc }} + cc: ${{ matrix.compiler.cc }} + cxx: ${{ matrix.compiler.cxx }} + only-restore: 'false' + + - name: Check formatting + uses: ./.github/actions/check-formatting + with: + llvm-prefix: tpls/llvm/install/llvm + + - name: Install python requirements + run: pip install numpy pytest lit + + - name: Build + uses: ./.github/actions/build-cudaq + with: + cc: ${{ matrix.compiler.cc }} + cxx: ${{ matrix.compiler.cxx }} + build-type: ${{ matrix.compiler.build-type }} + llvm-prefix: tpls/llvm/install/llvm + + - name: Run tests + run: ctest --output-on-failure --test-dir build +