Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add capability to ignore specific example projects in CI workflows #6820

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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