Skip to content

Commit 82617fe

Browse files
authored
Update CI to label-driven testing (#450)
* Initial commit * Disabled lvl 1 flow when lvl 3 is used * Made workflows mutually exclusive * Updated with general label-driven level system * Restore automatic testing on dev/release push * Added inline comments, updated workflow names * Added clarification on dispatch * Streamlined cancel script updated build and test name * Refactored dispatch to simplify and catch unlabel edge-case * Updated to cull dispatch on unlabel when test already run * Overhauled to leverage gh workflow concurrency, streamlined * Removed run culling and streamlined * Significantly simplified dispatch * Updated copyright
1 parent 98ccd2e commit 82617fe

2 files changed

Lines changed: 83 additions & 8 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved.
2+
#
3+
# See LICENSE for license information.
4+
5+
name: PR Automatic CI
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- 'dev'
11+
- 'release_v2.*_rocm'
12+
types: [ opened, labeled, synchronize, reopened ]
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
determine_level:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
test_level: ${{ steps.set_level.outputs.test_level }}
22+
steps:
23+
- name: Determine CI dispatch from labels
24+
id: set_level
25+
uses: actions/github-script@v7
26+
with:
27+
script: |
28+
const parseLevelLabel = (labelName) => {
29+
const m = (labelName || '').match(/^ci-level\s+(\d+)$/i);
30+
return m ? Number(m[1]) : 0;
31+
};
32+
33+
const labels = (context.payload.pull_request.labels || [])
34+
.map(l => parseLevelLabel(l.name));
35+
const action = context.payload.action;
36+
const currentLevel = labels.length ? Math.max(...labels) : 0;
37+
38+
let dispatch = false;
39+
if (action === 'labeled') {
40+
const addedLevel = parseLevelLabel(context.payload.label?.name);
41+
// Only dispatch when the newly added label is (or ties) the highest level.
42+
dispatch = addedLevel > 0 && addedLevel === currentLevel;
43+
} else {
44+
// synchronize, reopened, opened — dispatch at whatever level is set.
45+
dispatch = currentLevel > 0;
46+
}
47+
48+
const level = dispatch ? String(currentLevel) : '';
49+
core.info(`action=${action}, currentLevel=${currentLevel}, dispatch=${dispatch}`);
50+
core.setOutput('test_level', level);
51+
52+
dispatch:
53+
# Run this job if there is a valid level to test, which requires
54+
# that any of the following are true:
55+
# - A ci-level label higher than any existing ci-level label(s) was added
56+
# - A commit was pushed with existing ci-level label(s)
57+
# - The PR was reopened or opened with existing ci-level label(s)
58+
if: ${{ needs.determine_level.outputs.test_level != '' }}
59+
needs: determine_level
60+
name: CI Level ${{ needs.determine_level.outputs.test_level }}
61+
uses: ./.github/workflows/rocm-ci.yml
62+
secrets: inherit
63+
with:
64+
test_level: ${{ needs.determine_level.outputs.test_level }}

.github/workflows/rocm-ci.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,30 @@
22
#
33
# See LICENSE for license information.
44

5-
name: TransformerEngine CI
5+
name: Build and Test Branch
6+
run-name: CI Level ${{ inputs.test_level || '1' }}
67

78
on:
89
push:
910
branches:
1011
- 'dev'
11-
- 'release_v1.*_rocm'
1212
- 'release_v2.*_rocm'
13-
pull_request:
14-
branches:
15-
- 'dev'
16-
- 'release_v1.**_rocm'
17-
- 'release_v2.**_rocm'
13+
workflow_call:
14+
inputs:
15+
test_level:
16+
description: 'Test Level (1-3)'
17+
required: false
18+
default: '1'
19+
type: string
20+
docker_image_override:
21+
description: 'Manual Docker Image (Leave empty to use config file value)'
22+
required: false
23+
type: string
24+
test_config_from_source:
25+
description: 'DEBUG: Use config.json from current source branch instead of dev'
26+
required: false
27+
default: false
28+
type: boolean
1829
workflow_dispatch:
1930
inputs:
2031
test_level:
@@ -36,7 +47,7 @@ concurrency:
3647

3748
jobs:
3849
build_and_test:
39-
name: Build and Test on GPU (${{ matrix.runner }})
50+
name: Build and Test on GPU (${{ matrix.runner }}) - Level ${{ inputs.test_level || '1' }}
4051
timeout-minutes: 720
4152
runs-on: ${{ matrix.runner }}
4253
strategy:

0 commit comments

Comments
 (0)