|
| 1 | +name: "Git Bisect" |
| 2 | + |
| 3 | +defaults: |
| 4 | + run: |
| 5 | + shell: bash --noprofile --norc -euo pipefail {0} |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + runner: |
| 11 | + description: "Runner label" |
| 12 | + required: false |
| 13 | + default: linux-amd64-cpu16 |
| 14 | + type: string |
| 15 | + good_ref: |
| 16 | + description: "Good ref/sha/tag/branch. Defaults to latest release tag. Accepts '-Nd' (e.g., '-14d') to mean 'origin/main as of N days ago'." |
| 17 | + required: false |
| 18 | + type: string |
| 19 | + bad_ref: |
| 20 | + description: "Bad ref/sha/tag/branch. Defaults to main. Accepts '-Nd' (e.g., '-14d') to mean 'origin/main as of N days ago'." |
| 21 | + required: false |
| 22 | + type: string |
| 23 | + launch_args: |
| 24 | + description: "Arguments for .devcontainer/launch.sh -d" |
| 25 | + required: false |
| 26 | + default: "" |
| 27 | + type: string |
| 28 | + preset: |
| 29 | + description: "CMake preset" |
| 30 | + required: false |
| 31 | + default: "" |
| 32 | + type: string |
| 33 | + cmake_options: |
| 34 | + description: "Additional options passed to CMake preset configure (e.g. -DVAR=ON)" |
| 35 | + required: false |
| 36 | + default: "" |
| 37 | + type: string |
| 38 | + build_targets: |
| 39 | + description: "Space separated ninja build targets" |
| 40 | + required: false |
| 41 | + default: "" |
| 42 | + type: string |
| 43 | + ctest_targets: |
| 44 | + description: "Space separated CTest targets" |
| 45 | + required: false |
| 46 | + default: "" |
| 47 | + type: string |
| 48 | + lit_precompile_tests: |
| 49 | + description: "Space-separated libcudacxx lit test paths to precompile without execution" |
| 50 | + required: false |
| 51 | + default: "" |
| 52 | + type: string |
| 53 | + lit_tests: |
| 54 | + description: "Space-separated libcudacxx lit test paths to execute" |
| 55 | + required: false |
| 56 | + default: "" |
| 57 | + type: string |
| 58 | + workflow_call: |
| 59 | + inputs: |
| 60 | + runner: |
| 61 | + description: "Runner label" |
| 62 | + required: false |
| 63 | + default: linux-amd64-cpu16 |
| 64 | + type: string |
| 65 | + good_ref: |
| 66 | + description: "Good ref/sha/tag/branch. Defaults to latest release tag. Accepts '-Nd' (e.g., '-14d') to mean 'origin/main as of N days ago'." |
| 67 | + required: false |
| 68 | + type: string |
| 69 | + bad_ref: |
| 70 | + description: "Bad ref/sha/tag/branch. Defaults to HEAD. Accepts '-Nd' (e.g., '-14d') to mean 'origin/main as of N days ago'." |
| 71 | + required: false |
| 72 | + type: string |
| 73 | + launch_args: |
| 74 | + description: "Arguments for .devcontainer/launch.sh -d" |
| 75 | + required: false |
| 76 | + default: "" |
| 77 | + type: string |
| 78 | + preset: |
| 79 | + description: "CMake preset" |
| 80 | + required: false |
| 81 | + default: "" |
| 82 | + type: string |
| 83 | + cmake_options: |
| 84 | + description: "Additional options passed to CMake preset configure (e.g. -DVAR=ON)" |
| 85 | + required: false |
| 86 | + default: "" |
| 87 | + type: string |
| 88 | + build_targets: |
| 89 | + description: "Space separated ninja build targets" |
| 90 | + required: false |
| 91 | + default: "" |
| 92 | + type: string |
| 93 | + ctest_targets: |
| 94 | + description: "Space separated CTest targets" |
| 95 | + required: false |
| 96 | + default: "" |
| 97 | + type: string |
| 98 | + lit_precompile_tests: |
| 99 | + description: "Space-separated libcudacxx lit test paths to precompile without execution" |
| 100 | + required: false |
| 101 | + default: "" |
| 102 | + type: string |
| 103 | + lit_tests: |
| 104 | + description: "Space-separated libcudacxx lit test paths to execute" |
| 105 | + required: false |
| 106 | + default: "" |
| 107 | + type: string |
| 108 | + |
| 109 | +jobs: |
| 110 | + # Hash all of the inputs and generate a descriptive, but unique, name for the bisect job. |
| 111 | + # This is necessary because GitHub Actions does not provide an easy way to get the numeric |
| 112 | + # job id from within a running job, unless the name is unique across the entire run. |
| 113 | + generate-job-name: |
| 114 | + name: Generate Unique Job Name |
| 115 | + runs-on: ubuntu-latest |
| 116 | + outputs: |
| 117 | + job-name: ${{ steps.set-name.outputs.unique-name }} |
| 118 | + steps: |
| 119 | + - name: Set unique name |
| 120 | + id: set-name |
| 121 | + run: | |
| 122 | + # Hash the inputs to create a unique identifier |
| 123 | + input_string=$(cat <<HASH |
| 124 | + ${{ inputs.runner }} |
| 125 | + ${{ inputs.launch_args }} |
| 126 | + ${{ inputs.preset }} |
| 127 | + ${{ inputs.cmake_options }} |
| 128 | + ${{ inputs.build_targets }} |
| 129 | + ${{ inputs.ctest_targets }} |
| 130 | + ${{ inputs.lit_precompile_tests }} |
| 131 | + ${{ inputs.lit_tests }} |
| 132 | + ${{ inputs.good_ref }} |
| 133 | + ${{ inputs.bad_ref }} |
| 134 | + HASH |
| 135 | + ) |
| 136 | + hash=$(echo -n "$input_string" | sha256sum | awk '{print $1}') |
| 137 | + short_hash=${hash:0:8} |
| 138 | +
|
| 139 | + function sanitize() { |
| 140 | + echo "$1" | tr -cd '[:alnum:]-' |
| 141 | + } |
| 142 | +
|
| 143 | + function compress() { |
| 144 | + input=$1 |
| 145 | + input_length=${#input} |
| 146 | +
|
| 147 | + # "begin.and.end" -> "begin_d.end" |
| 148 | + delim="_" |
| 149 | + keep_chars=5 |
| 150 | + compressed_str=${input:0:keep_chars}$delim${input: -keep_chars} |
| 151 | + compressed_length=${#compressed_str} |
| 152 | +
|
| 153 | + if [[ $input_length -gt $compressed_length ]]; then |
| 154 | + echo "$compressed_str" |
| 155 | + else |
| 156 | + echo "$input" |
| 157 | + fi |
| 158 | + } |
| 159 | +
|
| 160 | + preset=$(sanitize "${{ inputs.preset }}") |
| 161 | + good_ref=$(sanitize "${{ inputs.good_ref }}") |
| 162 | + bad_ref=$(sanitize "${{ inputs.bad_ref }}") |
| 163 | + build_targets=$(sanitize "${{ inputs.build_targets }}") |
| 164 | + ctest_targets=$(sanitize "${{ inputs.ctest_targets }}") |
| 165 | + lit_precompile_tests=$(sanitize "${{ inputs.lit_precompile_tests }}") |
| 166 | + lit_tests=$(sanitize "${{ inputs.lit_tests }}") |
| 167 | +
|
| 168 | + build_targets_part=$(compress "$build_targets") |
| 169 | + ctest_targets_part=$(compress "$ctest_targets") |
| 170 | +
|
| 171 | + # Parse "--cuda XX.Y" / "-c XX.Y" and "--host <str>" / "-H <str>" |
| 172 | + launch_args="${{ inputs.launch_args }}" |
| 173 | + cuda_version="ctk$(grep -oP '(?:--cuda|-c)\s+\K\S+' <<< "$launch_args" || true)" |
| 174 | + host_name=$(grep -oP '(?:--host|-H)\s+\K\S+' <<< "$launch_args" || true) |
| 175 | +
|
| 176 | + # Parse `amd64/arm64` and -gpu-<gpu_name> from runner name. |
| 177 | + # Ex: 'linux-amd64-gpu-rtxa6000-latest-1' |
| 178 | + runner=${{ inputs.runner }} |
| 179 | + cpu_arch=$(echo "${runner}" | grep -oP '(?:^|-)\K(?:amd64|arm64)(?=-)' || true) |
| 180 | + gpu_name=$(echo "${runner}" | grep -oP '(?:-gpu-)\K[^-]+' || true) |
| 181 | +
|
| 182 | + # Vars to include in unique name: |
| 183 | + declare -a vars=( |
| 184 | + "cuda_version" |
| 185 | + "host_name" |
| 186 | + "preset" |
| 187 | + "build_targets_part" |
| 188 | + "ctest_targets_part" |
| 189 | + "lit_precompile_tests" |
| 190 | + "lit_tests" |
| 191 | + "gpu_name" |
| 192 | + "cpu_arch" |
| 193 | + "short_hash" |
| 194 | + ) |
| 195 | + unique_name="bisect" |
| 196 | + for var in "${vars[@]}"; do |
| 197 | + val=${!var} |
| 198 | + if [[ -n "$val" ]]; then |
| 199 | + unique_name+="-$val" |
| 200 | + fi |
| 201 | + done |
| 202 | +
|
| 203 | + echo "Unique job name: $unique_name" |
| 204 | + echo "unique-name=$unique_name" >> "$GITHUB_OUTPUT" |
| 205 | +
|
| 206 | + bisect: |
| 207 | + needs: [generate-job-name] |
| 208 | + name: ${{ needs.generate-job-name.outputs.job-name }} |
| 209 | + runs-on: ${{ inputs.runner }} |
| 210 | + permissions: |
| 211 | + id-token: write |
| 212 | + contents: read |
| 213 | + steps: |
| 214 | + - name: Checkout repository |
| 215 | + uses: actions/checkout@v4 |
| 216 | + with: |
| 217 | + persist-credentials: false |
| 218 | + fetch-depth: 0 # FULL history |
| 219 | + fetch-tags: true # Ensure tags are present |
| 220 | + |
| 221 | + - name: Get AWS credentials for sccache bucket |
| 222 | + uses: aws-actions/configure-aws-credentials@v4 |
| 223 | + with: |
| 224 | + role-to-assume: arn:aws:iam::279114543810:role/gha-oidc-NVIDIA |
| 225 | + aws-region: us-east-2 |
| 226 | + role-duration-seconds: 43200 # 12 hours |
| 227 | + |
| 228 | + - name: Prepare AWS config for devcontainer |
| 229 | + run: | |
| 230 | + # The devcontainer will mount this path to the home directory |
| 231 | + aws_dir="${{ github.workspace }}/.aws" |
| 232 | + mkdir -p "${aws_dir}" |
| 233 | + cat > "${aws_dir}/config" <<EOF |
| 234 | + [default] |
| 235 | + bucket=rapids-sccache-devs |
| 236 | + region=us-east-2 |
| 237 | + EOF |
| 238 | + cat > "${aws_dir}/credentials" <<EOF |
| 239 | + [default] |
| 240 | + aws_access_key_id=${AWS_ACCESS_KEY_ID} |
| 241 | + aws_session_token=${AWS_SESSION_TOKEN} |
| 242 | + aws_secret_access_key=${AWS_SECRET_ACCESS_KEY} |
| 243 | + EOF |
| 244 | + chmod 0600 "${aws_dir}/credentials" |
| 245 | + chmod 0664 "${aws_dir}/config" |
| 246 | + - name: Run git bisect |
| 247 | + env: |
| 248 | + GITHUB_TOKEN: ${{ github.token }} |
| 249 | + LAUNCH_ARGS: ${{ inputs.launch_args }} |
| 250 | + GITHUB_REPOSITORY: ${{ github.repository }} |
| 251 | + # AWS credentials from the configure-aws-credentials action |
| 252 | + AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }} |
| 253 | + AWS_SESSION_TOKEN: ${{ env.AWS_SESSION_TOKEN }} |
| 254 | + AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }} |
| 255 | + AWS_REGION: ${{ env.AWS_REGION }} |
| 256 | + run: | |
| 257 | + echo -e "\e[1;34mLaunching devcontainer and running git bisect...\e[0m" |
| 258 | +
|
| 259 | + GPU_ARGS="" |
| 260 | + if [[ "${{ inputs.runner }}" == *"-gpu-"* ]]; then |
| 261 | + if [[ ! "${LAUNCH_ARGS}" =~ "--gpus" ]]; then |
| 262 | + echo "GPU runner detected; enabling '--gpus all'" |
| 263 | + GPU_ARGS="--gpus all" |
| 264 | + else |
| 265 | + echo "GPU runner detected, but '--gpus' already present in LAUNCH_ARGS" |
| 266 | + fi |
| 267 | + fi |
| 268 | +
|
| 269 | + # Grab the url for this step summary |
| 270 | + run="$GITHUB_RUN_ID" |
| 271 | + attempt="${GITHUB_RUN_ATTEMPT:-1}" |
| 272 | + server="${GITHUB_SERVER_URL:-https://github.com}" |
| 273 | + repo="$GITHUB_REPOSITORY" |
| 274 | + job_name="${{ needs.generate-job-name.outputs.job-name }}" |
| 275 | + job_id=$( |
| 276 | + gh api --paginate \ |
| 277 | + repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs \ |
| 278 | + --jq ".jobs[] | select(.name | endswith(\"${job_name}\")) | .id" |
| 279 | + ) || : |
| 280 | +
|
| 281 | + GHA_LOG_URL="$server/$repo/actions/runs/$run/job/$job_id" |
| 282 | + STEP_SUMMARY_URL="$server/$repo/actions/runs/$run/attempts/$attempt#summary-$job_id" |
| 283 | +
|
| 284 | + echo -e "\e[1;34mGHA Log URL: $GHA_LOG_URL\e[0m" |
| 285 | + echo -e "\e[1;34mBisection Results: $STEP_SUMMARY_URL\e[0m" |
| 286 | +
|
| 287 | + mkdir -p /tmp/shared |
| 288 | + rc=0 |
| 289 | + set -x |
| 290 | + .devcontainer/launch.sh -d ${LAUNCH_ARGS} ${GPU_ARGS} \ |
| 291 | + --env "AWS_ROLE_ARN=" \ |
| 292 | + --env "AWS_REGION=${AWS_REGION}" \ |
| 293 | + --env "SCCACHE_REGION=${AWS_REGION}" \ |
| 294 | + --env "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" \ |
| 295 | + --env "AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}" \ |
| 296 | + --env "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" \ |
| 297 | + --env "GITHUB_REPOSITORY=${GITHUB_REPOSITORY}" \ |
| 298 | + --env "LAUNCH_ARGS=${LAUNCH_ARGS} ${GPU_ARGS}" \ |
| 299 | + --env "STEP_SUMMARY_URL=${STEP_SUMMARY_URL}" \ |
| 300 | + --env "GHA_LOG_URL=${GHA_LOG_URL}" \ |
| 301 | + --volume "/tmp/shared:/tmp/shared" \ |
| 302 | + -- ./ci/util/git_bisect.sh \ |
| 303 | + --summary-file "/tmp/shared/summary.md" \ |
| 304 | + --good-ref "${{ inputs.good_ref }}" \ |
| 305 | + --bad-ref "${{ inputs.bad_ref }}" \ |
| 306 | + --preset "${{ inputs.preset }}" \ |
| 307 | + --cmake-options "${{ inputs.cmake_options }}" \ |
| 308 | + --build-targets "${{ inputs.build_targets }}" \ |
| 309 | + --ctest-targets "${{ inputs.ctest_targets }}" \ |
| 310 | + --lit-precompile-tests "${{ inputs.lit_precompile_tests }}" \ |
| 311 | + --lit-tests "${{ inputs.lit_tests }}" \ |
| 312 | + || rc=$? |
| 313 | + set +x |
| 314 | +
|
| 315 | + # Append the summary (if any) to the GitHub step summary |
| 316 | + if [[ -d /tmp/shared ]]; then |
| 317 | + find /tmp/shared -type f -exec cat {} \; >> "$GITHUB_STEP_SUMMARY" || : |
| 318 | + fi |
| 319 | +
|
| 320 | + echo -e "\e[1;34mGHA Log URL: $GHA_LOG_URL\e[0m" |
| 321 | + echo -e "\e[1;34mBisection Results: $STEP_SUMMARY_URL\e[0m" |
| 322 | +
|
| 323 | + exit $rc |
0 commit comments