Skip to content

Commit

Permalink
Add capability to ignore specific example projects in CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Nov 25, 2024
1 parent e2e789a commit e55cac2
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions tooling/scripts/generate-examples-matrix.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map<String, String>> 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()
Expand All @@ -30,15 +45,19 @@ 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)}"
GROUPS[groupId].examples = ""
}

String separator = GROUPS[groupId].examples == "" ? "" : ","
String projectName = example.link.substring(example.link.lastIndexOf('/') + 1)

GROUPS[groupId].examples = "${GROUPS[groupId].examples}${separator}${projectName}"

groupId += 1;
Expand Down

0 comments on commit e55cac2

Please sign in to comment.