@@ -12,6 +12,8 @@ module.exports = {
1212 findPythonProjects,
1313} ;
1414
15+ const GLOBAL_KEY = "__GLOBAL__" ; // reserved key for commands without a project specified
16+
1517async function run ( ) {
1618 try {
1719 const rootDir = core . getInput ( "root-dir" ) ;
@@ -159,6 +161,54 @@ function generateCommands(projectTomlParsed) {
159161 return commands ;
160162}
161163
164+ /**
165+ * Parse a GitHub Actions input representing what commands to skip for certain projects into
166+ * a map of project → commandToSkip.
167+ *
168+ * Rules:
169+ * - If a project is defined, the project name becomes the key, and the command is its value.
170+ * - If no project is defined, the command goes under the reserved "__GLOBAL__" key.
171+ *
172+ * @param {string } skipsInput - The raw input string.
173+ * @returns {Record<string, string[]> } Object mapping project (or "__GLOBAL__") to its commands to skip.
174+ */
175+ function determineSkips ( skipsInput ) {
176+ const lines = skipsInput
177+ . split ( "\n" )
178+ . map ( ( line ) => line . trim ( ) )
179+ . filter ( ( line ) => line . length > 0 ) ;
180+
181+ const skipsMap = { } ;
182+ for ( const line of lines ) {
183+ const pairs = line . split ( "," ) . map ( ( p ) => p . trim ( ) ) ;
184+
185+ // Get an object where keys are what's before the `=` and values are
186+ // what's after.
187+ const kv = Object . fromEntries (
188+ pairs . map ( ( p ) => {
189+ const [ k , v ] = p . split ( "=" , 2 ) ;
190+ return [ k . trim ( ) , v ?. trim ( ) ] ;
191+ } ) ,
192+ ) ;
193+
194+ let project = kv . project ;
195+ let command = kv . command ;
196+ if ( project && ! command ) {
197+ continue ;
198+ }
199+
200+ project = project ?? GLOBAL_KEY ;
201+ command = command ?? line . trim ( ) ;
202+
203+ let entry = skipsMap [ project ] ;
204+ if ( ! entry ) {
205+ entry = skipsMap [ project ] = [ ] ;
206+ }
207+ entry . push ( command ) ;
208+ }
209+ return skipsMap ;
210+ }
211+
162212function determineInstallCommand ( projectTomlParsed ) {
163213 const buildBackend = getBuildBackend ( projectTomlParsed ) ;
164214
0 commit comments