1010 - master
1111 pull_request :
1212 workflow_call :
13+ inputs :
14+ runner :
15+ required : false
16+ type : string
17+ default : " [ubuntu-latest]"
1318
1419jobs :
1520 languages :
@@ -19,14 +24,16 @@ jobs:
1924 outputs :
2025 matrix : ${{ steps.lang.outputs.result }}
2126 continue : ${{ steps.continue.outputs.result }}
22- runs-on : ubuntu-latest
27+ runs-on : ${{ (inputs && inputs.runner && fromJson(inputs.runner)) || ' ubuntu-latest' }}
2328 steps :
2429 - name : Checkout repository
2530 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2631
2732 - name : Get repo languages
2833 id : lang
2934 uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
35+ env :
36+ RUNNER_INPUT : ${{ inputs.runner }}
3037 with :
3138 script : |
3239 // CodeQL supports the following:
6471 'typescript': 'javascript',
6572 }
6673
74+ // Get custom runner input if provided
75+ const runnerInput = process.env.RUNNER_INPUT || '["ubuntu-latest"]'
76+ let customRunners = []
77+ try {
78+ customRunners = JSON.parse(runnerInput)
79+ console.log(`Custom runners provided: ${JSON.stringify(customRunners)}`)
80+ } catch (e) {
81+ console.log(`Failed to parse runner input, using default behavior: ${e}`)
82+ }
83+
84+ const useCustomRunners = customRunners.length > 0 && runnerInput !== '["ubuntu-latest"]'
85+
6786 const repo = context.repo
6887 const response = await github.rest.repos.listLanguages(repo)
6988 let matrix = {
86105 "language": "actions",
87106 "name": "actions",
88107 "os": "ubuntu-latest",
108+ "runner": useCustomRunners ? customRunners : "ubuntu-latest",
89109 "build-mode": "none",
90110 });
91111 }
@@ -104,15 +124,9 @@ jobs:
104124 addedLanguages.add(normalizedKey)
105125
106126 console.log(`Found supported language: ${normalizedKey}`)
107- let osList = ['ubuntu-latest'];
108- if (normalizedKey === 'swift') {
109- osList = ['macos-latest'];
110- }
111- for (let os of osList) {
112- // set name for matrix
113- let name = osList.length === 1 ? normalizedKey : `${normalizedKey}, ${os}`
114127
115- // set category for matrix
128+ if (useCustomRunners) {
129+ // Use custom runners as a group/pool
116130 let category = `/language:${normalizedKey}`
117131 let build_mode = 'none';
118132
@@ -131,14 +145,60 @@ jobs:
131145 build_mode = 'none'
132146 }
133147
134- // add to matrix
148+ // Determine OS based on language (for display purposes)
149+ let os = 'ubuntu-latest'
150+ if (normalizedKey === 'swift') {
151+ os = 'macos-latest'
152+ }
153+
154+ // add to matrix with runner group
135155 matrix['include'].push({
136156 "category": category,
137157 "language": normalizedKey,
138- "name": name ,
158+ "name": normalizedKey ,
139159 "os": os,
160+ "runner": customRunners,
140161 "build-mode": build_mode,
141162 })
163+ } else {
164+ // Use default OS-based behavior
165+ let osList = ['ubuntu-latest'];
166+ if (normalizedKey === 'swift') {
167+ osList = ['macos-latest'];
168+ }
169+ for (let os of osList) {
170+ // set name for matrix
171+ let name = osList.length === 1 ? normalizedKey : `${normalizedKey}, ${os}`
172+
173+ // set category for matrix
174+ let category = `/language:${normalizedKey}`
175+ let build_mode = 'none';
176+
177+ // Set build mode based on language
178+ switch (normalizedKey) {
179+ case 'csharp':
180+ build_mode = 'autobuild'
181+ break
182+ case 'go':
183+ build_mode = 'autobuild'
184+ break
185+ case 'java':
186+ build_mode = 'autobuild'
187+ break
188+ default:
189+ build_mode = 'none'
190+ }
191+
192+ // add to matrix
193+ matrix['include'].push({
194+ "category": category,
195+ "language": normalizedKey,
196+ "name": name,
197+ "os": os,
198+ "runner": os,
199+ "build-mode": build_mode,
200+ })
201+ }
142202 }
143203 }
144204 }
@@ -172,7 +232,7 @@ jobs:
172232 actions : read
173233 contents : read
174234 security-events : write
175- runs-on : ${{ matrix.os || 'ubuntu-latest' }}
235+ runs-on : ${{ matrix.runner }}
176236 strategy :
177237 fail-fast : false
178238 matrix : ${{ fromJson(needs.languages.outputs.matrix) }}
0 commit comments