Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ jobs:
cp ./LICENSE ./ci/docker/context/LICENSE
cp ./VERSION ./ci/docker/context/VERSION
cp ./thirdparty/THIRD_PARTY_LICENSES ./ci/docker/context/THIRD_PARTY_LICENSES
- name: Copy Commit SHA
- name: Copy Commit SHA, commit time and branch
run: |
git rev-parse HEAD > ./ci/docker/context/COMMIT_SHA
git log -n1 --pretty='%ct' > ./ci/docker/context/COMMIT_TIME
git rev-parse --abbrev-ref HEAD > ./ci/docker/context/BRANCH
Copy link

@coderabbitai coderabbitai bot Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find and read the build_images.yaml file
fd "build_images.yaml" --type f

Repository: NVIDIA/cuopt

Length of output: 38


🏁 Script executed:

#!/bin/bash
# List all files in .github/workflows directory
find .github/workflows -type f -name "*.yaml" -o -name "*.yml" 2>/dev/null | head -20

Repository: NVIDIA/cuopt

Length of output: 505


🏁 Script executed:

#!/bin/bash
# Read the build_images.yaml file with line numbers, focusing on the relevant sections
cat -n .github/workflows/build_images.yaml | head -80

Repository: NVIDIA/cuopt

Length of output: 3036


🏁 Script executed:

#!/bin/bash
# Check if there are any other branch-related operations or context that affects BRANCH usage
grep -n "BRANCH" .github/workflows/build_images.yaml

Repository: NVIDIA/cuopt

Length of output: 129


🏁 Script executed:

#!/bin/bash
# Check if there are other workflows that call this workflow and potentially pass branch info
grep -r "build_images.yaml" .github/workflows/ --include="*.yaml" --include="*.yml"

Repository: NVIDIA/cuopt

Length of output: 152


🏁 Script executed:

#!/bin/bash
# Check how build_images.yaml is called from the parent workflow
grep -A 10 "build_images.yaml" .github/workflows/build_test_publish_images.yaml

Repository: NVIDIA/cuopt

Length of output: 473


Critical: git rev-parse --abbrev-ref HEAD will always capture "HEAD" instead of the actual branch name

Line 62 executes this command after checking out a specific commit SHA (line 47), which puts the repository in a detached HEAD state. In this state, the command always returns HEAD when you're in detached HEAD state, making the BRANCH file incorrect.

Recommended fix: Pass the branch name as an additional workflow input parameter and use it directly:

-          git rev-parse --abbrev-ref HEAD > ./ci/docker/context/BRANCH
+          echo "${{ inputs.branch_name }}" > ./ci/docker/context/BRANCH

Add branch_name to the workflow inputs (around line 8-30) and have the caller pass it.

Alternative: Use git branch -r --contains HEAD | grep -oP 'origin/\K.*' | head -n1 if you need to derive the branch from the commit, though this may return multiple branches if the commit exists on several.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
.github/workflows/build_images.yaml around line 62: the current command writes
the branch as `git rev-parse --abbrev-ref HEAD` but because the checkout uses a
specific commit SHA (detached HEAD) this will always write "HEAD"; change the
workflow to accept a branch_name input and use that input when creating
./ci/docker/context/BRANCH (add branch_name to the workflow inputs and ensure
callers pass it), or if you must derive the branch from the commit, replace the
current command with a remote-branch lookup such as using git branch -r
--contains HEAD piped to extract the origin/<branch> name and take the first
result (handle possible multiple matches).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Iroy30 CUOPT_VER should get you branch details, may be you want to look at it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

- name: Login to NGC
uses: docker/login-action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ RUN mkdir -p /opt/cuopt && \
WORKDIR /opt/cuopt

# Copy all static files in a single layer
COPY ./LICENSE ./VERSION ./THIRD_PARTY_LICENSES ./COMMIT_SHA /opt/cuopt/
COPY ./LICENSE ./VERSION ./THIRD_PARTY_LICENSES ./COMMIT_SHA ./COMMIT_TIME ./BRANCH /opt/cuopt/

# Copy CUDA libraries from the cuda-libs stage
COPY --from=cuda-libs /usr/local/cuda/lib64/libnvrtc* /usr/local/cuda/lib64/
Expand Down