|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +name: Build, Test and Publish cuopt images |
| 17 | + |
| 18 | +on: |
| 19 | + workflow_call: |
| 20 | + inputs: |
| 21 | + branch: |
| 22 | + type: string |
| 23 | + date: |
| 24 | + type: string |
| 25 | + sha: |
| 26 | + type: string |
| 27 | + build_type: |
| 28 | + type: string |
| 29 | + arch: |
| 30 | + type: string |
| 31 | + default: '["amd64", "arm64"]' |
| 32 | + description: 'JSON array of architectures to build for' |
| 33 | + cuda_ver: |
| 34 | + type: string |
| 35 | + default: '["12.8.0"]' |
| 36 | + description: 'JSON array of CUDA versions to build for' |
| 37 | + python_ver: |
| 38 | + type: string |
| 39 | + default: '["3.12.11"]' |
| 40 | + description: 'JSON array of Python versions to build for' |
| 41 | + linux_ver: |
| 42 | + type: string |
| 43 | + default: '["22.04"]' |
| 44 | + description: 'JSON array of Linux versions to build for' |
| 45 | + |
| 46 | + |
| 47 | +defaults: |
| 48 | + run: |
| 49 | + shell: bash |
| 50 | + |
| 51 | +permissions: |
| 52 | + actions: read |
| 53 | + checks: none |
| 54 | + contents: read |
| 55 | + deployments: none |
| 56 | + discussions: none |
| 57 | + id-token: write |
| 58 | + issues: none |
| 59 | + packages: read |
| 60 | + pages: none |
| 61 | + pull-requests: read |
| 62 | + repository-projects: none |
| 63 | + security-events: none |
| 64 | + statuses: none |
| 65 | + |
| 66 | +jobs: |
| 67 | + compute-matrix: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + container: |
| 70 | + image: rapidsai/ci-conda:25.08-latest |
| 71 | + outputs: |
| 72 | + MATRIX: ${{ steps.compute-matrix.outputs.MATRIX }} |
| 73 | + CUOPT_VER: ${{ steps.compute-cuopt-ver.outputs.CUOPT_VER }} |
| 74 | + IMAGE_TAG_PREFIX: ${{ steps.compute-cuopt-ver.outputs.IMAGE_TAG_PREFIX }} |
| 75 | + |
| 76 | + steps: |
| 77 | + - name: Checkout |
| 78 | + uses: actions/checkout@v4 |
| 79 | + with: |
| 80 | + fetch-depth: 0 # unshallow fetch for setuptools-scm |
| 81 | + persist-credentials: false |
| 82 | + |
| 83 | + - name: Compute matrix |
| 84 | + id: compute-matrix |
| 85 | + run: | |
| 86 | + MATRIX=$(jq -c '.' <<EOF |
| 87 | + { |
| 88 | + "arch": ${{ inputs.arch }}, |
| 89 | + "cuda_ver": ${{ inputs.cuda_ver }}, |
| 90 | + "python_ver": ${{ inputs.python_ver }}, |
| 91 | + "linux_ver": ${{ inputs.linux_ver }} |
| 92 | + } |
| 93 | + EOF |
| 94 | + ) |
| 95 | + echo "MATRIX=$MATRIX" >> $GITHUB_OUTPUT |
| 96 | +
|
| 97 | + - name: Install gha-tools |
| 98 | + run: | |
| 99 | + mkdir -p /tmp/gha-tools |
| 100 | + curl -s -L 'https://github.com/rapidsai/gha-tools/releases/latest/download/tools.tar.gz' | tar -xz -C /tmp/gha-tools |
| 101 | + echo "/tmp/gha-tools" >> "${GITHUB_PATH}" |
| 102 | +
|
| 103 | + - name: Compute cuopt version |
| 104 | + id: compute-cuopt-ver |
| 105 | + run: | |
| 106 | + ver=$(rapids-generate-version) |
| 107 | + # Remove starting 0s from version 25.08.0a18 -> 25.8.0a18 |
| 108 | + CUOPT_VER=$(echo "$ver" | sed -E 's/\.0+([0-9])/\.\1/g') |
| 109 | + echo "CUOPT_VER=$CUOPT_VER" >> $GITHUB_OUTPUT |
| 110 | + if rapids-is-release-build; then |
| 111 | + IMAGE_TAG_PREFIX="$CUOPT_VER" |
| 112 | + else |
| 113 | + IMAGE_TAG_PREFIX=$(echo "$CUOPT_VER" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+)a.*/\1a/') |
| 114 | + fi |
| 115 | + echo "IMAGE_TAG_PREFIX=$IMAGE_TAG_PREFIX" >> $GITHUB_OUTPUT |
| 116 | +
|
| 117 | + build-images: |
| 118 | + name: Build images |
| 119 | + needs: compute-matrix |
| 120 | + secrets: inherit |
| 121 | + strategy: |
| 122 | + matrix: ${{ fromJson(needs.compute-matrix.outputs.MATRIX) }} |
| 123 | + uses: ./.github/workflows/build_images.yaml |
| 124 | + with: |
| 125 | + ARCHES: ${{ matrix.arch }} |
| 126 | + CUDA_VER: ${{ matrix.cuda_ver }} |
| 127 | + CUOPT_VER: ${{ needs.compute-matrix.outputs.CUOPT_VER }} |
| 128 | + IMAGE_TAG_PREFIX: ${{ needs.compute-matrix.outputs.IMAGE_TAG_PREFIX }} |
| 129 | + LINUX_VER: ${{ matrix.linux_ver }} |
| 130 | + PYTHON_VER: ${{ matrix.python_ver }} |
| 131 | + |
| 132 | + build-cuopt-multiarch-manifest: |
| 133 | + name: Build cuopt multiarch manifest |
| 134 | + needs: [build-images, compute-matrix] |
| 135 | + strategy: |
| 136 | + matrix: |
| 137 | + CUDA_VER: ${{ fromJson(needs.compute-matrix.outputs.MATRIX).cuda_ver }} |
| 138 | + PYTHON_VER: ${{ fromJson(needs.compute-matrix.outputs.MATRIX).python_ver }} |
| 139 | + runs-on: ubuntu-latest |
| 140 | + steps: |
| 141 | + - name: Checkout code repo |
| 142 | + uses: actions/checkout@v4 |
| 143 | + with: |
| 144 | + fetch-depth: 0 |
| 145 | + - name: Login to DockerHub |
| 146 | + uses: docker/login-action@v3 |
| 147 | + with: |
| 148 | + username: ${{ secrets.CUOPT_DOCKERHUB_USERNAME }} |
| 149 | + password: ${{ secrets.CUOPT_DOCKERHUB_TOKEN }} |
| 150 | + - name: Login to NGC |
| 151 | + uses: docker/login-action@v3 |
| 152 | + with: |
| 153 | + registry: "nvcr.io" |
| 154 | + username: "$oauthtoken" |
| 155 | + password: ${{ secrets.CUOPT_NGC_DOCKER_KEY }} |
| 156 | + - name: Trim CUDA and Python versions |
| 157 | + id: trim |
| 158 | + run: | |
| 159 | + echo "CUDA_SHORT=$(echo '${{ matrix.CUDA_VER }}' | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_OUTPUT |
| 160 | + echo "PYTHON_SHORT=$(echo '${{ matrix.PYTHON_VER }}' | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_OUTPUT |
| 161 | + - name: Create multiarch manifest |
| 162 | + shell: bash |
| 163 | + env: |
| 164 | + CUOPT_VER: ${{ needs.compute-matrix.outputs.CUOPT_VER }} |
| 165 | + CUDA_SHORT: ${{ steps.trim.outputs.CUDA_SHORT }} |
| 166 | + PYTHON_SHORT: ${{ steps.trim.outputs.PYTHON_SHORT }} |
| 167 | + IMAGE_TAG_PREFIX: ${{ needs.compute-matrix.outputs.IMAGE_TAG_PREFIX }} |
| 168 | + BUILD_TYPE: ${{ inputs.build_type }} |
| 169 | + run: bash ci/docker/create_multiarch_manifest.sh |
| 170 | + |
| 171 | + test-images: |
| 172 | + name: Test images |
| 173 | + needs: [build-cuopt-multiarch-manifest, compute-matrix] |
| 174 | + secrets: inherit |
| 175 | + strategy: |
| 176 | + matrix: |
| 177 | + CUDA_VER: ${{ fromJson(needs.compute-matrix.outputs.MATRIX).cuda_ver }} |
| 178 | + PYTHON_VER: ${{ fromJson(needs.compute-matrix.outputs.MATRIX).python_ver }} |
| 179 | + ARCH: ${{ fromJson(needs.compute-matrix.outputs.MATRIX).arch }} |
| 180 | + uses: ./.github/workflows/test_images.yaml |
| 181 | + with: |
| 182 | + ARCH: ${{ matrix.ARCH }} |
| 183 | + CUDA_VER: ${{ matrix.CUDA_VER }} |
| 184 | + PYTHON_VER: ${{ matrix.PYTHON_VER }} |
| 185 | + IMAGE_TAG_PREFIX: ${{ needs.compute-matrix.outputs.IMAGE_TAG_PREFIX }} |
0 commit comments