From e55cac2ea43864c7a5d57142f0eab67e65b28976 Mon Sep 17 00:00:00 2001 From: James Netherton Date: Mon, 25 Nov 2024 14:51:10 +0000 Subject: [PATCH] Add capability to ignore specific example projects in CI workflows --- .../scripts/generate-examples-matrix.groovy | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tooling/scripts/generate-examples-matrix.groovy b/tooling/scripts/generate-examples-matrix.groovy index ff52c26116b5..2741ad6d5ba9 100644 --- a/tooling/scripts/generate-examples-matrix.groovy +++ b/tooling/scripts/generate-examples-matrix.groovy @@ -17,9 +17,24 @@ import groovy.json.JsonOutput; import groovy.json.JsonSlurper +import java.nio.file.Files +import java.nio.file.Paths + final int MAX_GROUPS = 2 final List> GROUPS = new ArrayList<>() final String EXAMPLES_BRANCH = System.getProperty('EXAMPLES_BRANCH') +final String EXAMPLES_IGNORE= System.getProperty('EXAMPLES_IGNORE') + +def ignoredExamples = [] +if (EXAMPLES_IGNORE != null) { + if (EXAMPLES_IGNORE.contains(",")) { + ignoredExamples = EXAMPLES_IGNORE.split(",") + } else if (Files.exists(Paths.get(EXAMPLES_IGNORE))) { + ignoredExamples = Files.readAllLines(Paths.get(EXAMPLES_IGNORE)) + } else { + ignoredExamples.add(EXAMPLES_IGNORE) + } +} int groupId = 0 JsonSlurper jsonSlurper = new JsonSlurper() @@ -30,6 +45,12 @@ try { // Distribute example projects across a bounded set of test groups and output as JSON examples.each { example -> + String projectName = example.link.substring(example.link.lastIndexOf('/') + 1) + + if (ignoredExamples.contains(projectName)) { + return + } + if (GROUPS[groupId] == null) { GROUPS[groupId] = [:] GROUPS[groupId].name = "group-${String.format("%02d", groupId + 1)}" @@ -37,8 +58,6 @@ try { } String separator = GROUPS[groupId].examples == "" ? "" : "," - String projectName = example.link.substring(example.link.lastIndexOf('/') + 1) - GROUPS[groupId].examples = "${GROUPS[groupId].examples}${separator}${projectName}" groupId += 1;