Skip to content

Commit 5cf3b39

Browse files
Further unify pr and non-pr workflow jobs
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
1 parent 00998b9 commit 5cf3b39

File tree

4 files changed

+66
-110
lines changed

4 files changed

+66
-110
lines changed

.github/workflows/_pr_gate.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,48 @@ on:
1414

1515
jobs:
1616
check-file-changes:
17-
if: startsWith(github.ref, 'refs/heads/pull-request/')
1817
runs-on: ubuntu-latest
1918
outputs:
20-
any_changed: ${{ steps.changed-tests.outputs.any_changed }}
19+
any_changed: ${{ steps.changed-tests.outputs.any_changed || steps.non-pr.outputs.any_changed }}
2120
steps:
22-
- uses: actions/checkout@v6
21+
# For non-PR triggers (schedule, workflow_dispatch), always run tests
22+
- id: non-pr
23+
if: "!startsWith(github.ref, 'refs/heads/pull-request/')"
24+
run: echo "any_changed=true" >> $GITHUB_OUTPUT
25+
- if: startsWith(github.ref, 'refs/heads/pull-request/')
26+
uses: actions/checkout@v6
2327
with:
2428
fetch-depth: 0
25-
- id: get-pr-info
29+
- if: startsWith(github.ref, 'refs/heads/pull-request/')
30+
id: get-pr-info
2631
uses: nv-gha-runners/get-pr-info@main
27-
# Get commit from main branch that is present in the PR to use as base for changed files
28-
- id: calculate-merge-base
32+
# Extract SHAs from pr-info JSON via shell to avoid fromJSON on potentially-empty outputs
33+
- if: startsWith(github.ref, 'refs/heads/pull-request/')
34+
id: pr-shas
2935
env:
30-
PR_SHA: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).head.sha }}
31-
BASE_SHA: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).base.sha }}
36+
PR_INFO: ${{ steps.get-pr-info.outputs.pr-info }}
37+
run: |
38+
echo "head_sha=$(echo "$PR_INFO" | jq -r '.head.sha')" >> $GITHUB_OUTPUT
39+
echo "base_sha=$(echo "$PR_INFO" | jq -r '.base.sha')" >> $GITHUB_OUTPUT
40+
# Get commit from main branch that is present in the PR to use as base for changed files
41+
- if: startsWith(github.ref, 'refs/heads/pull-request/')
42+
id: calculate-merge-base
3243
run: |
33-
(echo -n "merge-base="; git merge-base "$BASE_SHA" "$PR_SHA") | tee --append "${GITHUB_OUTPUT}"
34-
- name: Check for changes in test-relevant directories
44+
(echo -n "merge-base="; git merge-base "${{ steps.pr-shas.outputs.base_sha }}" "${{ steps.pr-shas.outputs.head_sha }}") | tee --append "${GITHUB_OUTPUT}"
45+
- if: startsWith(github.ref, 'refs/heads/pull-request/')
46+
name: Check for changes in test-relevant directories
3547
id: changed-tests
3648
uses: step-security/changed-files@v46.0.5
3749
with:
3850
base_sha: ${{ steps.calculate-merge-base.outputs.merge-base }}
39-
sha: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).head.sha }}
51+
sha: ${{ steps.pr-shas.outputs.head_sha }}
4052
files: ${{ inputs.files }}
4153
fail_on_initial_diff_error: true
4254
wait-checks:
4355
needs: [check-file-changes]
44-
if: needs.check-file-changes.outputs.any_changed == 'true'
56+
if: >-
57+
startsWith(github.ref, 'refs/heads/pull-request/') &&
58+
needs.check-file-changes.outputs.any_changed == 'true'
4559
uses: ./.github/workflows/_wait_for_checks.yml
4660
permissions:
4761
checks: read

.github/workflows/example_tests.yml

Lines changed: 18 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
tests/examples/**
3131
3232
##### PyTorch Example Tests (speculative_decoding requires 26.01 image) #####
33-
torch-pr:
33+
torch:
3434
needs: [pr-gate]
35-
if: startsWith(github.ref, 'refs/heads/pull-request/') && needs.pr-gate.outputs.any_changed == 'true'
36-
strategy: &torch_strategy
35+
if: needs.pr-gate.outputs.any_changed == 'true'
36+
strategy:
3737
fail-fast: false
3838
matrix:
3939
example: [llm_distill, llm_qat, llm_sparsity, diffusers_sparsity]
@@ -47,21 +47,9 @@ jobs:
4747
example: ${{ matrix.example }}
4848
timeout_minutes: 30
4949
pip_install_extras: "[hf,dev-test]"
50-
runner: linux-amd64-gpu-rtxpro6000-latest-1
51-
52-
torch-non-pr:
53-
if: ${{ !startsWith(github.ref, 'refs/heads/pull-request/') }}
54-
strategy: *torch_strategy
55-
uses: ./.github/workflows/_example_tests_runner.yml
56-
secrets: inherit
57-
with:
58-
docker_image: "nvcr.io/nvidia/pytorch:${{ matrix.docker_image || '26.03' }}-py3"
59-
example: ${{ matrix.example }}
60-
timeout_minutes: 30
61-
pip_install_extras: "[hf,dev-test]"
62-
runner: linux-amd64-gpu-rtxpro6000-latest-2
50+
runner: ${{ startsWith(github.ref, 'refs/heads/pull-request/') && 'linux-amd64-gpu-rtxpro6000-latest-1' || 'linux-amd64-gpu-rtxpro6000-latest-2' }}
6351

64-
##### TensorRT-LLM Example Tests #####
52+
##### TensorRT-LLM Example Tests (pr/non-pr split: non-pr runs extra autodeploy+eval examples) #####
6553
trtllm-pr:
6654
needs: [pr-gate]
6755
if: startsWith(github.ref, 'refs/heads/pull-request/') && needs.pr-gate.outputs.any_changed == 'true'
@@ -92,39 +80,23 @@ jobs:
9280
runner: linux-amd64-gpu-rtxpro6000-latest-2
9381

9482
##### Megatron Example Tests #####
95-
megatron-pr:
83+
megatron:
9684
needs: [pr-gate]
97-
if: startsWith(github.ref, 'refs/heads/pull-request/') && needs.pr-gate.outputs.any_changed == 'true'
98-
strategy: &nemo_strategy
99-
fail-fast: false
100-
matrix:
101-
example: [megatron_bridge]
102-
uses: ./.github/workflows/_example_tests_runner.yml
103-
secrets: inherit
104-
with:
105-
docker_image: "nvcr.io/nvidia/nemo:26.02"
106-
example: ${{ matrix.example }}
107-
timeout_minutes: 30
108-
pip_install_extras: "[hf,puzzletron,dev-test]"
109-
runner: linux-amd64-gpu-rtxpro6000-latest-1
110-
111-
megatron-non-pr:
112-
if: ${{ !startsWith(github.ref, 'refs/heads/pull-request/') }}
113-
strategy: *nemo_strategy
85+
if: needs.pr-gate.outputs.any_changed == 'true'
11486
uses: ./.github/workflows/_example_tests_runner.yml
11587
secrets: inherit
11688
with:
11789
docker_image: "nvcr.io/nvidia/nemo:26.02"
118-
example: ${{ matrix.example }}
90+
example: megatron_bridge
11991
timeout_minutes: 30
12092
pip_install_extras: "[hf,puzzletron,dev-test]"
121-
runner: linux-amd64-gpu-rtxpro6000-latest-2
93+
runner: ${{ startsWith(github.ref, 'refs/heads/pull-request/') && 'linux-amd64-gpu-rtxpro6000-latest-1' || 'linux-amd64-gpu-rtxpro6000-latest-2' }}
12294

12395
##### ONNX/TensorRT Example Tests #####
124-
onnx-pr:
96+
onnx:
12597
needs: [pr-gate]
126-
if: startsWith(github.ref, 'refs/heads/pull-request/') && needs.pr-gate.outputs.any_changed == 'true'
127-
strategy: &onnx_strategy
98+
if: needs.pr-gate.outputs.any_changed == 'true'
99+
strategy:
128100
fail-fast: false
129101
matrix:
130102
example: [diffusers, torch_onnx]
@@ -134,33 +106,22 @@ jobs:
134106
docker_image: "nvcr.io/nvidia/tensorrt:26.02-py3"
135107
example: ${{ matrix.example }}
136108
pip_install_extras: "[onnx,hf,dev-test]"
137-
runner: linux-amd64-gpu-rtxpro6000-latest-1
138-
139-
onnx-non-pr:
140-
if: ${{ !startsWith(github.ref, 'refs/heads/pull-request/') }}
141-
strategy: *onnx_strategy
142-
uses: ./.github/workflows/_example_tests_runner.yml
143-
secrets: inherit
144-
with:
145-
docker_image: "nvcr.io/nvidia/tensorrt:26.02-py3"
146-
example: ${{ matrix.example }}
147-
pip_install_extras: "[onnx,hf,dev-test]"
148-
runner: linux-amd64-gpu-rtxpro6000-latest-2
109+
runner: ${{ startsWith(github.ref, 'refs/heads/pull-request/') && 'linux-amd64-gpu-rtxpro6000-latest-1' || 'linux-amd64-gpu-rtxpro6000-latest-2' }}
149110

150111
##### Required Check for PR #####
151112
example-pr-required-check:
152113
# Run even if example tests are skipped
153114
if: ${{ startsWith(github.ref, 'refs/heads/pull-request/') && always() }}
154-
needs: [pr-gate, torch-pr, trtllm-pr, megatron-pr, onnx-pr]
115+
needs: [pr-gate, torch, trtllm-pr, megatron, onnx]
155116
runs-on: ubuntu-latest
156117
steps:
157-
- name: Required GPU tests did not succeed
118+
- name: Required example tests did not succeed
158119
if: |
159120
needs.pr-gate.result != 'success' ||
160121
(needs.pr-gate.outputs.any_changed == 'true' && (
161-
needs.torch-pr.result != 'success' ||
122+
needs.torch.result != 'success' ||
162123
needs.trtllm-pr.result != 'success' ||
163-
needs.megatron-pr.result != 'success' ||
164-
needs.onnx-pr.result != 'success'
124+
needs.megatron.result != 'success' ||
125+
needs.onnx.result != 'success'
165126
))
166127
run: exit 1

.github/workflows/gpu_tests.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ jobs:
3030
tests/gpu/**
3131
tests/gpu_megatron/**
3232
tests/gpu_trtllm/**
33-
gpu-tests-pr:
33+
34+
gpu-tests:
3435
needs: [pr-gate]
3536
if: needs.pr-gate.outputs.any_changed == 'true'
36-
strategy: &gpu_strategy
37+
strategy:
3738
fail-fast: false
3839
matrix:
3940
include:
@@ -47,15 +48,15 @@ jobs:
4748
- example: gpu_trtllm
4849
timeout: 30
4950
container_image: tensorrt-llm/release:1.3.0rc10
50-
runs-on: linux-amd64-gpu-rtxpro6000-latest-1
51+
runs-on: ${{ startsWith(github.ref, 'refs/heads/pull-request/') && 'linux-amd64-gpu-rtxpro6000-latest-1' || 'linux-amd64-gpu-rtxpro6000-latest-2' }}
5152
timeout-minutes: ${{ matrix.timeout }}
52-
container: &gpu_container
53+
container:
5354
image: nvcr.io/nvidia/${{ matrix.container_image }}
5455
env:
5556
GIT_DEPTH: 1000 # For correct version
5657
PIP_CONSTRAINT: "" # Disable pip constraint for upgrading packages
5758
HF_TOKEN: ${{ secrets.HF_TOKEN }}
58-
steps: &gpu_steps
59+
steps:
5960
- uses: actions/checkout@v6
6061
- uses: nv-gha-runners/setup-proxy-cache@main
6162
- name: Setup environment variables
@@ -75,19 +76,13 @@ jobs:
7576
flags: gpu
7677
fail_ci_if_error: false # test may be skipped if relevant file changes are not detected
7778
verbose: true
78-
gpu-tests-non-pr:
79-
if: ${{ !startsWith(github.ref, 'refs/heads/pull-request/') }}
80-
strategy: *gpu_strategy
81-
runs-on: linux-amd64-gpu-rtxpro6000-latest-2
82-
timeout-minutes: ${{ matrix.timeout }}
83-
container: *gpu_container
84-
steps: *gpu_steps
79+
8580
gpu-pr-required-check:
86-
# Run even if gpu-tests-pr is skipped
81+
# Run even if gpu-tests is skipped
8782
if: ${{ startsWith(github.ref, 'refs/heads/pull-request/') && always() }}
88-
needs: [pr-gate, gpu-tests-pr]
83+
needs: [pr-gate, gpu-tests]
8984
runs-on: ubuntu-latest
9085
steps:
9186
- name: Required GPU tests did not succeed
92-
if: ${{ needs.pr-gate.result != 'success' || (needs.pr-gate.outputs.any_changed == 'true' && needs.gpu-tests-pr.result != 'success') }}
87+
if: ${{ needs.pr-gate.result != 'success' || (needs.pr-gate.outputs.any_changed == 'true' && needs.gpu-tests.result != 'success') }}
9388
run: exit 1

.github/workflows/regression_tests.yml

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,19 @@ jobs:
3232
examples/dataset/**
3333
modelopt_recipes/general/speculative_decoding/**
3434
tools/launcher/**
35-
regression-tests-pr:
35+
36+
regression-tests:
3637
needs: [pr-gate]
3738
if: needs.pr-gate.outputs.any_changed == 'true'
38-
strategy: &regression_strategy
39-
fail-fast: false
40-
matrix:
41-
include:
42-
- example: regression
43-
timeout: 15
44-
container_image: pytorch:26.01-py3
45-
runs-on: linux-amd64-gpu-rtxpro6000-latest-1
46-
timeout-minutes: ${{ matrix.timeout }}
47-
container: &regression_container
48-
image: nvcr.io/nvidia/${{ matrix.container_image }}
39+
runs-on: ${{ startsWith(github.ref, 'refs/heads/pull-request/') && 'linux-amd64-gpu-rtxpro6000-latest-1' || 'linux-amd64-gpu-rtxpro6000-latest-2' }}
40+
timeout-minutes: 15
41+
container:
42+
image: nvcr.io/nvidia/pytorch:26.01-py3
4943
env:
5044
GIT_DEPTH: 1000 # For correct version
5145
PIP_CONSTRAINT: "" # Disable pip constraint for upgrading packages
5246
HF_TOKEN: ${{ secrets.HF_TOKEN }}
53-
steps: &regression_steps
47+
steps:
5448
- uses: actions/checkout@v6
5549
- uses: nv-gha-runners/setup-proxy-cache@main
5650
- name: Setup environment variables
@@ -60,9 +54,7 @@ jobs:
6054
env:
6155
COVERAGE_PROCESS_START: ${{ github.workspace }}/pyproject.toml
6256
COVERAGE_FILE: ${{ github.workspace }}/.coverage
63-
run: |
64-
pip install nox
65-
nox -s ${{ matrix.example }}
57+
run: python -m pip install nox && nox -s regression
6658
- name: Upload regression coverage to Codecov
6759
uses: codecov/codecov-action@v5
6860
with:
@@ -71,21 +63,15 @@ jobs:
7163
flags: regression
7264
fail_ci_if_error: false # test may be skipped if relevant file changes are not detected
7365
verbose: true
74-
regression-tests-non-pr:
75-
if: ${{ !startsWith(github.ref, 'refs/heads/pull-request/') }}
76-
strategy: *regression_strategy
77-
runs-on: linux-amd64-gpu-rtxpro6000-latest-2
78-
timeout-minutes: ${{ matrix.timeout }}
79-
container: *regression_container
80-
steps: *regression_steps
66+
8167
regression-pr-required-check:
82-
# Run even if regression-tests-pr is skipped
68+
# Run even if regression-tests is skipped
8369
if: ${{ startsWith(github.ref, 'refs/heads/pull-request/') && always() }}
84-
needs: [pr-gate, regression-tests-pr]
70+
needs: [pr-gate, regression-tests]
8571
runs-on: ubuntu-latest
8672
steps:
8773
- name: Required regression tests did not succeed
8874
if: |
8975
needs.pr-gate.result != 'success' ||
90-
(needs.pr-gate.outputs.any_changed == 'true' && needs.regression-tests-pr.result != 'success')
76+
(needs.pr-gate.outputs.any_changed == 'true' && needs.regression-tests.result != 'success')
9177
run: exit 1

0 commit comments

Comments
 (0)