Skip to content

ci: Set HF_HUB_OFFLINE=1 during tests when PR is from a fork#1174

Merged
terrykong merged 1 commit intoNVIDIA-NeMo:mainfrom
chtruong814:chtruong/fork-hf-offline
Sep 22, 2025
Merged

ci: Set HF_HUB_OFFLINE=1 during tests when PR is from a fork#1174
terrykong merged 1 commit intoNVIDIA-NeMo:mainfrom
chtruong814:chtruong/fork-hf-offline

Conversation

@chtruong814
Copy link
Contributor

@chtruong814 chtruong814 commented Sep 21, 2025

What does this PR do ?

Set HF_HUB_OFFLINE=1 during tests when PR is from a fork

Pull requests from forks do not have access to secrets like HF_TOKEN, so their CI tests will fail when downloading HF models.

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • ...

Summary by CodeRabbit

  • New Features

    • None.
  • Tests

    • For forked pull requests, tests now run in offline mode; behavior is unchanged for non-fork runs.
  • Chores

    • CI now detects forked pull requests via a new parameter and propagates it to test jobs across documentation, unit, and functional pipelines for consistent handling.
  • Impact

    • No user-facing changes; improves CI robustness for external contributions.

Signed-off-by: Charlie Truong <chtruong@nvidia.com>
@chtruong814 chtruong814 requested a review from a team as a code owner September 21, 2025 14:57
@chtruong814 chtruong814 added the CI:L1 Run doctests, unit tests, and functional tests label Sep 21, 2025
@github-actions github-actions bot added CI Relating to CI and removed CI:L1 Run doctests, unit tests, and functional tests labels Sep 21, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 21, 2025

📝 Walkthrough

Walkthrough

Adds a new is_fork_pr input to the test-template composite action and plumbs it through the main CI workflow jobs to conditionally set HF_HUB_OFFLINE=1 during docker-based test runs for forked pull requests.

Changes

Cohort / File(s) Change Summary
Composite Action: test-template
\.github/actions/test-template/action.yml
Added input is_fork_pr (default "false"). Updated test run step to include HF_HUB_OFFLINE=1 in docker run when is_fork_pr == 'true'.
CI Workflow: main pipeline
\.github/workflows/cicd-main.yml
Computed is_fork_pr for pull_request events where head repo != base repo. Passed is_fork_pr to test-template for docs, unit, and functional test jobs.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant GH as GitHub Actions
  participant WF as cicd-main.yml
  participant ACT as test-template (composite)
  participant Docker as docker run

  Dev->>GH: Open PR / push
  GH->>WF: Trigger workflow (pull_request or push)
  WF->>WF: Compute is_fork_pr (fork PR if head != base)
  WF->>ACT: Invoke test-template with is_fork_pr
  ACT->>ACT: Check is_fork_pr
  alt Fork PR
    ACT->>Docker: Run tests with env HF_HUB_OFFLINE=1
  else Not fork PR
    ACT->>Docker: Run tests without HF_HUB_OFFLINE
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

CI

Suggested reviewers

  • terrykong

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly captures the primary change: enabling HF_HUB_OFFLINE during CI tests for pull requests originating from forks. It accurately reflects the modifications to .github/actions/test-template/action.yml and .github/workflows/cicd-main.yml described in the changeset. The phrasing is concise, specific, and suitable for a teammate scanning the project history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Test Results For Major Changes ✅ Passed The PR limits its changes to CI workflow logic by introducing an is_fork_pr input and setting HF_HUB_OFFLINE=1 during tests for forked pull requests, which is operationally minor and does not impact runtime behavior, numerics, or performance. The PR description does not present test results, but the custom check passes when the change is minor. Since there is no evidence of feature additions, breaking changes, refactors affecting code paths, or performance-sensitive modifications, test or performance evidence is not required for this check.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
.github/actions/test-template/action.yml (2)

178-179: Also set TRANSFORMERS_OFFLINE for consistency; simplify the conditional flag injection.

Setting only HF_HUB_OFFLINE=1 can still leave Transformers trying online paths. Recommend setting both flags, and (optionally) avoid the “empty expansion + trailing backslash” brittle pattern.

Minimal in-place fix:

-          ${{ inputs.is_fork_pr == 'true' && '--env HF_HUB_OFFLINE=1' || '' }} \
+          ${{ inputs.is_fork_pr == 'true' && '--env HF_HUB_OFFLINE=1 --env TRANSFORMERS_OFFLINE=1' || '' }} \

More robust (optional) approach defined just before docker run:

# before docker run
HF_OFFLINE_FLAGS=""
if [[ "${{ inputs.is_fork_pr }}" == "true" ]]; then
  HF_OFFLINE_FLAGS="--env HF_HUB_OFFLINE=1 --env TRANSFORMERS_OFFLINE=1"
fi

and then:

docker run ... $HF_OFFLINE_FLAGS \

170-178: Optional: Skip passing HF_TOKEN into the container on forks.

Harmless as-is (env will be empty), but you can avoid confusion by gating it:

# example pattern
[[ "${{ inputs.is_fork_pr }}" == "true" ]] || TOKEN_FLAG="--env HF_TOKEN"
docker run ... ${TOKEN_FLAG:-} \
.github/workflows/cicd-main.yml (1)

228-228: Fork detection expression looks good; add quotes and verify non‑PR events.

  • The boolean expression is standard and should short‑circuit, but to avoid YAML boolean coercion, pass it as a quoted string.
  • Please confirm it does not evaluate github.event.pull_request.* on merge_group/workflow_dispatch (shouldn’t due to short‑circuit).

Suggested tweak:

-          is_fork_pr: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
+          is_fork_pr: "${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}"

If preferred, you can also compare to the base repository owner/repo:

- github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
+ github.event.pull_request.head.repo.full_name != github.repository

To verify behavior across event types, you can dispatch a dry-run on merge_group and ensure the input resolves to "false".

Also applies to: 257-257, 281-281

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5faaea8 and 500e627.

📒 Files selected for processing (2)
  • .github/actions/test-template/action.yml (2 hunks)
  • .github/workflows/cicd-main.yml (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build-container / main
  • GitHub Check: Lint check
  • GitHub Check: Lint check
  • GitHub Check: Post automodel integration comment / Comment on PR
  • GitHub Check: Post submodule check comment / Comment on PR
🔇 Additional comments (1)
.github/actions/test-template/action.yml (1)

57-60: LGTM on new input.

The is_fork_pr input is well-documented and defaulted to "false". No issues.

@terrykong terrykong added the CI:docs Run doctest label Sep 22, 2025
@terrykong terrykong enabled auto-merge (squash) September 22, 2025 04:44
@terrykong terrykong merged commit 2d3c43c into NVIDIA-NeMo:main Sep 22, 2025
55 checks passed
PrinsYin pushed a commit to PrinsYin/RL that referenced this pull request Nov 30, 2025
yuanhangsu1986 pushed a commit to yuanhangsu1986/RL-Nemontron-Edge-Omni that referenced this pull request Feb 21, 2026
…NeMo#1174)

Signed-off-by: Charlie Truong <chtruong@nvidia.com>
Signed-off-by: yuanhangs <yuanhangs@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:docs Run doctest CI Relating to CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants