Skip to content

Commit 459332b

Browse files
committed
Filter RPMs by the TESTING_FARM_GIT_URL, if present
1 parent 0e5fd32 commit 459332b

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

src/main/java/org/fedoraproject/javapackages/validator/Main.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,13 @@ protected Map<String, Validator> select(Map<String, Validator> validators) throw
526526
return validators;
527527
}
528528

529-
protected List<NamedResult> execute(Collection<Validator> validators) throws Exception {
529+
protected Iterable<RpmPackage> findRpms() throws Exception {
530530
var rpms = new ArrayList<RpmPackage>();
531+
Iterators.addAll(rpms, ArgFileIterator.create(parameters.argPaths));
532+
return rpms;
533+
}
534+
535+
protected List<NamedResult> execute(Collection<Validator> validators) throws Exception {
531536
/*
532537
parameters.argUrls.parallelStream().forEach(path -> {
533538
RpmPackage rpm;
@@ -541,7 +546,7 @@ protected List<NamedResult> execute(Collection<Validator> validators) throws Exc
541546
}
542547
});
543548
*/
544-
Iterators.addAll(rpms, ArgFileIterator.create(parameters.argPaths));
549+
var rpms = findRpms();
545550
var resultList = new ArrayList<>(validators).parallelStream().map(validator -> {
546551
var oldClassLoader = Thread.currentThread().getContextClassLoader();
547552
try {

src/main/java/org/fedoraproject/javapackages/validator/MainTmt.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55
import java.io.OutputStream;
66
import java.io.PrintStream;
7+
import java.net.URI;
78
import java.nio.charset.StandardCharsets;
89
import java.nio.file.Files;
910
import java.nio.file.Path;
@@ -31,11 +32,16 @@
3132
import org.fedoraproject.javapackages.validator.spi.Validator;
3233
import org.yaml.snakeyaml.Yaml;
3334

35+
import io.kojan.javadeptools.rpm.RpmPackage;
36+
3437
public class MainTmt extends Main {
3538
private Path TMT_TEST_DATA = null;
3639
private Path TMT_TREE = null;
40+
private Optional<URI> TESTING_FARM_GIT_URL = Optional.empty();
3741
private Map<String, List<LogEntry>> additionalLogs = new TreeMap<>();
3842

43+
private static final Pattern URL_PACKAGE_NAME_PATTERN = Pattern.compile(".*/rpms/(.*)");
44+
3945
private static String getenv(String key) {
4046
var result = System.getenv(key);
4147
if (result == null) {
@@ -47,13 +53,19 @@ private static String getenv(String key) {
4753
public static Main create() {
4854
var tmtTestData = Path.of(getenv("TMT_TEST_DATA"));
4955
var tmtTree = Path.of(getenv("TMT_TREE"));
50-
return create(tmtTestData, tmtTree);
56+
var testingFarmGitUrl = Optional.ofNullable(System.getenv("TESTING_FARM_GIT_URL")).map(URI::create);
57+
return create(tmtTestData, tmtTree, testingFarmGitUrl);
5158
}
5259

5360
public static Main create(Path tmtTestData, Path tmtTree) {
61+
return create(tmtTestData, tmtTree, Optional.empty());
62+
}
63+
64+
public static Main create(Path tmtTestData, Path tmtTree, Optional<URI> testingFarmGitUrl) {
5465
var result = new MainTmt();
5566
result.TMT_TEST_DATA = tmtTestData;
5667
result.TMT_TREE = tmtTree;
68+
result.TESTING_FARM_GIT_URL = testingFarmGitUrl;
5769
return result;
5870
}
5971

@@ -210,6 +222,24 @@ protected Map<String, Validator> select(Map<String, Validator> validators) throw
210222
return validators;
211223
}
212224

225+
@Override
226+
protected Iterable<RpmPackage> findRpms() throws Exception {
227+
logger.debug("TESTING_FARM_GIT_URL: {0}", Decorated.plain(TESTING_FARM_GIT_URL.map(String::valueOf).orElse("")));
228+
var rpms = new ArrayList<RpmPackage>();
229+
var it = ArgFileIterator.create(parameters.argPaths);
230+
while (it.hasNext()) {
231+
var rpm = it.next();
232+
if (TESTING_FARM_GIT_URL.isPresent()) {
233+
var matcher = URL_PACKAGE_NAME_PATTERN.matcher(TESTING_FARM_GIT_URL.get().getPath());
234+
if (matcher.matches() && !matcher.group(1).equals(rpm.getInfo().getSourceName())) {
235+
continue;
236+
}
237+
}
238+
rpms.add(rpm);
239+
}
240+
return rpms;
241+
}
242+
213243
private static String getFormattedDuration(Instant startTime, Instant endTime) {
214244
var duration = Duration.between(startTime, endTime);
215245
// TODO Wait for resolution within TF

0 commit comments

Comments
 (0)