Skip to content

Commit a16b2d1

Browse files
authored
ci: Port pre-commit checks to GitHub Actions (#261)
* ci: Port pre-commit checks to GitHub Actions GitHub currently runs security scans and a CPU runner verification job. Run prechecks after security succeeds on push and manual triggers. Use setup-python for Python 3.12 and inline commands to install pre-commit in a virtual environment and run all hooks with caching. Use a native ten-minute step timeout without bootstrap retries or custom command wrappers. Keep internal telemetry out of public logs. Signed-off-by: Kevin Fu <kefu@nvidia.com> * style: Fix pre-commit formatting failures Fix YAPF and clang-format violations in the public source so the pre-commit hooks pass. Signed-off-by: Kevin Fu <kefu@nvidia.com> * ci: Establish the shared CI entry workflow The security workflow directly coordinates prechecks and a noop job that originally verified CPU runner access. Call a reusable ci.yml only after security succeeds so CI jobs share that prerequisite. Keep event triggers and concurrency in security-suite.yml. Remove the noop job because prechecks already exercise the CPU runner pool. Signed-off-by: Kevin Fu <kefu@nvidia.com> * ci: Keep internal CI in the security workflow Internal CI polling currently lives in the reusable CI entry point. Move it into security-suite.yml so routine CI changes stay separate from the fixed security and internal-CI integration contract. Keep both internal CI and the reusable CI call gated on security, and document each workflow's role. Signed-off-by: Kevin Fu <kefu@nvidia.com> --------- Signed-off-by: Kevin Fu <kefu@nvidia.com>
1 parent c276a4d commit a16b2d1

16 files changed

Lines changed: 119 additions & 89 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,74 +13,20 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
# General entry point for CI jobs, called after security checks succeed.
17+
# Add or update CI jobs here or in the reusable workflows called here; keep
18+
# security-suite.yml fixed as the security and internal-CI integration contract.
19+
1620
name: CI
1721

1822
on:
19-
push:
20-
branches:
21-
- 'pull-request/[0-9]+'
22-
workflow_dispatch:
23+
workflow_call:
2324

2425
permissions: {}
2526

26-
concurrency:
27-
group: ci-${{ github.ref }}
28-
cancel-in-progress: true
29-
3027
jobs:
31-
internal-ci:
32-
name: Trigger internal CI
33-
if: >-
34-
vars.EDGE_LLM_INTERNAL_CI_ENABLED == 'true' &&
35-
github.repository == 'NVIDIA/TensorRT-Edge-LLM' &&
36-
startsWith(github.ref, 'refs/heads/pull-request/')
28+
prechecks:
29+
name: Prechecks
3730
permissions:
38-
statuses: read
39-
runs-on: linux-amd64-cpu4
40-
timeout-minutes: 120
41-
steps:
42-
- name: Wait for internal CI
43-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
44-
with:
45-
github-token: ${{ github.token }}
46-
script: |
47-
const trustedCreatorId = 10716935;
48-
const statusContext = 'edgellm/internal-ci';
49-
let pipelineId;
50-
while (true) {
51-
const statuses = await github.paginate(github.rest.repos.listCommitStatusesForRef, {
52-
...context.repo,
53-
ref: context.sha,
54-
per_page: 100,
55-
});
56-
const status = statuses.find(item =>
57-
item.context === statusContext && item.creator?.id === trustedCreatorId
58-
);
59-
const match = /^gitlab-pipeline:([1-9][0-9]*);github-actions:([1-9][0-9]*):([1-9][0-9]*)$/.exec(
60-
status?.description || ''
61-
);
62-
if (
63-
match &&
64-
match[2] === String(context.runId) &&
65-
match[3] === process.env.GITHUB_RUN_ATTEMPT
66-
) {
67-
if (pipelineId && pipelineId !== match[1]) {
68-
throw new Error('Internal pipeline identity changed');
69-
}
70-
pipelineId = match[1];
71-
core.info(`Internal GitLab pipeline ${pipelineId}: ${status.state}`);
72-
if (status.state === 'success') {
73-
await core.summary
74-
.addRaw(`Internal GitLab pipeline: \`${pipelineId}\` (success)\n`)
75-
.write();
76-
return;
77-
}
78-
if (status.state === 'failure' || status.state === 'error') {
79-
await core.summary
80-
.addRaw(`Internal GitLab pipeline: \`${pipelineId}\` (${status.state})\n`)
81-
.write();
82-
throw new Error(`Internal GitLab pipeline ${pipelineId} ${status.state}`);
83-
}
84-
}
85-
await new Promise(resolve => setTimeout(resolve, 15000));
86-
}
31+
contents: read
32+
uses: ./.github/workflows/precheck-jobs.yml
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Precheck jobs
5+
6+
on:
7+
workflow_call:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
pre_commit_checks:
14+
runs-on:
15+
group: nv-cpu-general
16+
labels: linux-amd64-cpu4
17+
env:
18+
PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit
19+
steps:
20+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
21+
with:
22+
persist-credentials: false
23+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
24+
with:
25+
python-version: '3.12'
26+
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
27+
with:
28+
path: .cache/pre-commit/
29+
key: pre-commit-linux-amd64-python312-runner-${{ hashFiles('.pre-commit-config.yaml') }}
30+
- name: Run pre-commit checks
31+
timeout-minutes: 10
32+
shell: bash
33+
run: |
34+
python -m venv venv
35+
venv/bin/python -m pip install pre-commit
36+
venv/bin/python -m pre_commit run --all-files --show-diff-on-failure

‎.github/workflows/security-suite.yml‎

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
name: Security scans
16+
# Fixed entry point for security checks and internal-CI integration.
17+
# Changes to this file require coordination with internal-CI validation to
18+
# avoid rejection. Make routine CI changes through ci.yml instead.
19+
20+
name: CI
1721

1822
on:
1923
push:
@@ -25,7 +29,7 @@ on:
2529
permissions: {}
2630

2731
concurrency:
28-
group: security-suite-${{ github.ref }}
32+
group: ci-${{ github.ref }}
2933
cancel-in-progress: true
3034

3135
jobs:
@@ -47,11 +51,67 @@ jobs:
4751
sast-runs-on: ubuntu-latest
4852
sast-build-mode: none
4953

50-
noop:
51-
name: Verify CPU runner access
54+
ci:
55+
name: CI
56+
needs: security-suite
57+
permissions:
58+
contents: read
59+
uses: ./.github/workflows/ci.yml
60+
61+
internal-ci:
62+
name: Trigger internal CI
5263
needs: security-suite
64+
if: >-
65+
vars.EDGE_LLM_INTERNAL_CI_ENABLED == 'true' &&
66+
github.repository == 'NVIDIA/TensorRT-Edge-LLM' &&
67+
startsWith(github.ref, 'refs/heads/pull-request/')
68+
permissions:
69+
statuses: read
5370
runs-on: linux-amd64-cpu4
54-
timeout-minutes: 5
71+
timeout-minutes: 120
5572
steps:
56-
- name: Verify CPU runner access
57-
run: echo "CPU runner access verified."
73+
- name: Wait for internal CI
74+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
75+
with:
76+
github-token: ${{ github.token }}
77+
script: |
78+
const trustedCreatorId = 10716935;
79+
const statusContext = 'edgellm/internal-ci';
80+
let pipelineId;
81+
while (true) {
82+
const statuses = await github.paginate(github.rest.repos.listCommitStatusesForRef, {
83+
...context.repo,
84+
ref: context.sha,
85+
per_page: 100,
86+
});
87+
const status = statuses.find(item =>
88+
item.context === statusContext && item.creator?.id === trustedCreatorId
89+
);
90+
const match = /^gitlab-pipeline:([1-9][0-9]*);github-actions:([1-9][0-9]*):([1-9][0-9]*)$/.exec(
91+
status?.description || ''
92+
);
93+
if (
94+
match &&
95+
match[2] === String(context.runId) &&
96+
match[3] === process.env.GITHUB_RUN_ATTEMPT
97+
) {
98+
if (pipelineId && pipelineId !== match[1]) {
99+
throw new Error('Internal pipeline identity changed');
100+
}
101+
pipelineId = match[1];
102+
core.info(`Internal GitLab pipeline ${pipelineId}: ${status.state}`);
103+
if (status.state === 'success') {
104+
await core.summary
105+
.addRaw(`Internal GitLab pipeline: \`${pipelineId}\` (success)\n`)
106+
.write();
107+
return;
108+
}
109+
if (status.state === 'failure' || status.state === 'error') {
110+
await core.summary
111+
.addRaw(`Internal GitLab pipeline: \`${pipelineId}\` (${status.state})\n`)
112+
.write();
113+
throw new Error(`Internal GitLab pipeline ${pipelineId} ${status.state}`);
114+
}
115+
}
116+
await new Promise(resolve => setTimeout(resolve, 15000));
117+
}

‎cpp/plugins/allReducePlugin/allReducePlugin.cpp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ int32_t AllReducePlugin::enqueue(PluginTensorDesc const* inputDesc, PluginTensor
335335
return -1;
336336
}
337337

338-
339338
status = executeNcclAllReducePath(registrations.nccl, inDesc, inputs[kIN_TENSOR_IDX], outputs[kOUT_TENSOR_IDX],
340339
numElements, mTpSize, currentDevice, stream);
341340
if (status == AllReduceExecutionStatus::kSuccess)
@@ -466,4 +465,3 @@ extern "C" EDGELLM_PLUGIN_EXPORT bool edgellmUnregisterNcclCommForAllReducePlugi
466465
{
467466
return trt_edgellm::plugins::unregisterNcclAllReducePath(deviceId, ncclComm);
468467
}
469-

‎cpp/plugins/allReducePlugin/allReducePlugin.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,3 @@ extern "C" EDGELLM_PLUGIN_EXPORT bool edgellmRegisterNcclCommForAllReducePlugin(
163163
int deviceId, void* ncclComm, void* ncclAllReduceFunction) noexcept;
164164
extern "C" EDGELLM_PLUGIN_EXPORT bool edgellmUnregisterNcclCommForAllReducePlugin(
165165
int deviceId, void* ncclComm) noexcept;
166-

‎cpp/plugins/fusedNvfp4GemmAllReducePlugin/fusedNvfp4GemmAllReducePlugin.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,6 @@ int32_t FusedNvfp4GemmAllReducePlugin::enqueue(PluginTensorDesc const* inputDesc
639639
globalActScaleTiled, weightSFB, weightScale2, m, N, K, mTpSize, currentDevice, outElements, stream};
640640
AllReduceExecutionStatus status = AllReduceExecutionStatus::kUnavailable;
641641

642-
643642
status = executeGemmNcclAllReducePath(registrations.nccl, executionContext);
644643
if (status == AllReduceExecutionStatus::kSuccess)
645644
{

‎cpp/runtime/multiDevice/multiDevicePluginCommRegistry.cpp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ constexpr char const* kUnregisterNcclPluginSymbol = "edgellmUnregisterNcclCommFo
3434
using RegisterNcclPluginFn = bool (*)(int, void*, void*);
3535
using UnregisterNcclPluginFn = bool (*)(int, void*);
3636

37-
3837
} // namespace
3938

4039
bool registerNcclCommForAllReducePlugin(int32_t deviceId, void* ncclComm) noexcept
@@ -81,6 +80,5 @@ bool unregisterNcclCommForAllReducePlugin(int32_t deviceId, void* ncclComm) noex
8180
return true;
8281
}
8382

84-
8583
} // namespace rt
8684
} // namespace trt_edgellm

‎cpp/runtime/multiDevice/multiDevicePluginCommRegistry.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ bool registerNcclCommForAllReducePlugin(int32_t deviceId, void* ncclComm) noexce
3636
*/
3737
bool unregisterNcclCommForAllReducePlugin(int32_t deviceId, void* ncclComm) noexcept;
3838

39-
4039
} // namespace rt
4140
} // namespace trt_edgellm

‎cpp/runtime/multiDevice/multiDevicePluginResourceFactory.cpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ std::unique_ptr<MultiDevicePluginResources> createTensorParallelPluginResources(
4040
MultiDevicePluginResourceConfig const& config)
4141
{
4242
TensorParallelPluginResourcesConfig const resourcesConfig{
43-
config.groupConfig.size, config.localRanks, config.localDevices, config.backendHandles,
43+
config.groupConfig.size,
44+
config.localRanks,
45+
config.localDevices,
46+
config.backendHandles,
4447
config.ownsBackendHandles,
4548
};
4649
return std::make_unique<TensorParallelPluginResources>(resourcesConfig);

‎cpp/runtime/multiDevice/parallelConfig.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ struct ParallelConfig
6868
ParallelLaunchMode launchMode{ParallelLaunchMode::kThread};
6969
std::vector<int32_t> devices{}; //!< Optional local CUDA device list. Empty means [0, size).
7070

71-
7271
std::string toString() const;
7372
};
7473

0 commit comments

Comments
 (0)