Skip to content
Permalink
Browse files

Add tester bot and ci module

Reviewed-by: rwestberg
  • Loading branch information
Erik Helin
Erik Helin committed Nov 12, 2019
1 parent 2a8f113 commit 980b7a8742be8f8f3fccf86c1efb523593e09f76
Showing with 3,356 additions and 0 deletions.
  1. +1 −0 bot/build.gradle
  2. +1 −0 bot/src/main/java/module-info.java
  3. +8 −0 bot/src/main/java/org/openjdk/skara/bot/BotConfiguration.java
  4. +31 −0 bot/src/main/java/org/openjdk/skara/bot/BotRunnerConfiguration.java
  5. +1 −0 bots/bridgekeeper/build.gradle
  6. +3 −0 bots/cli/build.gradle
  7. +1 −0 bots/forward/build.gradle
  8. +1 −0 bots/hgbridge/build.gradle
  9. +1 −0 bots/merge/build.gradle
  10. +1 −0 bots/mirror/build.gradle
  11. +1 −0 bots/mlbridge/build.gradle
  12. +1 −0 bots/notify/build.gradle
  13. +1 −0 bots/pr/build.gradle
  14. +1 −0 bots/submit/build.gradle
  15. +45 −0 bots/tester/build.gradle
  16. +31 −0 bots/tester/src/main/java/module-info.java
  17. +34 −0 bots/tester/src/main/java/org/openjdk/skara/bots/tester/Stage.java
  18. +166 −0 bots/tester/src/main/java/org/openjdk/skara/bots/tester/State.java
  19. +106 −0 bots/tester/src/main/java/org/openjdk/skara/bots/tester/TestBot.java
  20. +66 −0 bots/tester/src/main/java/org/openjdk/skara/bots/tester/TestBotFactory.java
  21. +443 −0 bots/tester/src/main/java/org/openjdk/skara/bots/tester/TestWorkItem.java
  22. +99 −0 bots/tester/src/test/java/org/openjdk/skara/bots/tester/InMemoryContinuousIntegration.java
  23. +63 −0 bots/tester/src/test/java/org/openjdk/skara/bots/tester/InMemoryHost.java
  24. +132 −0 bots/tester/src/test/java/org/openjdk/skara/bots/tester/InMemoryHostedRepository.java
  25. +67 −0 bots/tester/src/test/java/org/openjdk/skara/bots/tester/InMemoryJob.java
  26. +230 −0 bots/tester/src/test/java/org/openjdk/skara/bots/tester/InMemoryPullRequest.java
  27. +391 −0 bots/tester/src/test/java/org/openjdk/skara/bots/tester/StateTests.java
  28. +61 −0 bots/tester/src/test/java/org/openjdk/skara/bots/tester/TestBotTests.java
  29. +952 −0 bots/tester/src/test/java/org/openjdk/skara/bots/tester/TestWorkItemTests.java
  30. +1 −0 bots/topological/build.gradle
  31. +36 −0 ci/build.gradle
  32. +29 −0 ci/src/main/java/module-info.java
  33. +106 −0 ci/src/main/java/org/openjdk/skara/ci/Build.java
  34. +53 −0 ci/src/main/java/org/openjdk/skara/ci/ContinuousIntegration.java
  35. +38 −0 ci/src/main/java/org/openjdk/skara/ci/ContinuousIntegrationFactory.java
  36. +105 −0 ci/src/main/java/org/openjdk/skara/ci/Job.java
  37. +46 −0 ci/src/main/java/org/openjdk/skara/ci/Test.java
  38. +2 −0 settings.gradle
  39. +1 −0 test/build.gradle
@@ -30,6 +30,7 @@ module {
}

dependencies {
implementation project(':ci')
implementation project(':host')
implementation project(':network')
implementation project(':issuetracker')
@@ -21,6 +21,7 @@
* questions.
*/
module org.openjdk.skara.bot {
requires transitive org.openjdk.skara.ci;
requires transitive org.openjdk.skara.host;
requires transitive org.openjdk.skara.issuetracker;
requires transitive org.openjdk.skara.forge;
@@ -22,6 +22,7 @@
*/
package org.openjdk.skara.bot;

import org.openjdk.skara.ci.ContinuousIntegration;
import org.openjdk.skara.forge.HostedRepository;
import org.openjdk.skara.issuetracker.IssueProject;
import org.openjdk.skara.json.JSONObject;
@@ -49,6 +50,13 @@
*/
IssueProject issueProject(String name);

/**
* Configuration-specific name mapped to a ContinuousIntegration.
* @param name
* @return
*/
ContinuousIntegration continuousIntegration(String name);

/**
* Retrieves the ref name that optionally follows the configuration-specific repository name.
* If not configured, returns the name of the VCS default branch.
@@ -22,6 +22,7 @@
*/
package org.openjdk.skara.bot;

import org.openjdk.skara.ci.ContinuousIntegration;
import org.openjdk.skara.forge.*;
import org.openjdk.skara.host.Credential;
import org.openjdk.skara.issuetracker.*;
@@ -42,6 +43,7 @@
private final JSONObject config;
private final Map<String, Forge> repositoryHosts;
private final Map<String, IssueTracker> issueHosts;
private final Map<String, ContinuousIntegration> continuousIntegrations;
private final Map<String, HostedRepository> repositories;

private BotRunnerConfiguration(JSONObject config, Path cwd) throws ConfigurationError {
@@ -50,6 +52,7 @@ private BotRunnerConfiguration(JSONObject config, Path cwd) throws Configuration

repositoryHosts = parseRepositoryHosts(config, cwd);
issueHosts = parseIssueHosts(config, cwd);
continuousIntegrations = parseContinuousIntegrations(config, cwd);
repositories = parseRepositories(config);
}

@@ -118,6 +121,26 @@ private BotRunnerConfiguration(JSONObject config, Path cwd) throws Configuration
return ret;
}

private Map<String, ContinuousIntegration> parseContinuousIntegrations(JSONObject config, Path cwd) throws ConfigurationError {
Map<String, ContinuousIntegration> ret = new HashMap<>();

if (!config.contains("ci")) {
return ret;
}

for (var entry : config.get("ci").fields()) {
var url = entry.value().get("url").asString();
var ci = ContinuousIntegration.from(URI.create(url), entry.value().asObject());
if (ci.isPresent()) {
ret.put(entry.name(), ci.get());
} else {
throw new ConfigurationError("No continuous integration named with url: " + url);
}
}

return ret;
}

private Map<String, HostedRepository> parseRepositories(JSONObject config) throws ConfigurationError {
Map<String, HostedRepository> ret = new HashMap<>();

@@ -233,6 +256,14 @@ public IssueProject issueProject(String name) {
}
}

@Override
public ContinuousIntegration continuousIntegration(String name) {
if (continuousIntegrations.containsKey(name)) {
return continuousIntegrations.get(name);
}
throw new RuntimeException("Couldn't find continuous integration with name: " + name);
}

@Override
public String repositoryRef(String name) {
try {
@@ -32,6 +32,7 @@ module {
}

dependencies {
implementation project(':ci')
implementation project(':host')
implementation project(':forge')
implementation project(':issuetracker')
@@ -44,8 +44,10 @@ dependencies {
implementation project(':bots:mlbridge')
implementation project(':bots:mirror')
implementation project(':bots:topological')
implementation project(':bots:tester')
implementation project(':bots:submit')
implementation project(':bots:forward')
implementation project(':ci')
implementation project(':vcs')
implementation project(':jcheck')
implementation project(':host')
@@ -74,6 +76,7 @@ images {
'org.openjdk.skara.bots.mlbridge',
'org.openjdk.skara.bots.mirror',
'org.openjdk.skara.bots.submit',
'org.openjdk.skara.bots.tester',
'org.openjdk.skara.bots.topological',
'org.openjdk.skara.bots.forward']
launchers = ['skara-bots': 'org.openjdk.skara.bots.cli/org.openjdk.skara.bots.cli.BotLauncher']
@@ -31,6 +31,7 @@ module {
}

dependencies {
implementation project(':ci')
implementation project(':host')
implementation project(':bot')
implementation project(':forge')
@@ -32,6 +32,7 @@ module {

dependencies {
implementation project(':bot')
implementation project(':ci')
implementation project(':vcs')
implementation project(':host')
implementation project(':forge')
@@ -31,6 +31,7 @@ module {
}

dependencies {
implementation project(':ci')
implementation project(':host')
implementation project(':forge')
implementation project(':issuetracker')
@@ -31,6 +31,7 @@ module {
}

dependencies {
implementation project(':ci')
implementation project(':host')
implementation project(':forge')
implementation project(':issuetracker')
@@ -31,6 +31,7 @@ module {
}

dependencies {
implementation project(':ci')
implementation project(':bot')
implementation project(':mailinglist')
implementation project(':host')
@@ -31,6 +31,7 @@ module {
}

dependencies {
implementation project(':ci')
implementation project(':host')
implementation project(':network')
implementation project(':bot')
@@ -31,6 +31,7 @@ module {
}

dependencies {
implementation project(':ci')
implementation project(':bot')
implementation project(':forge')
implementation project(':issuetracker')
@@ -31,6 +31,7 @@ module {
}

dependencies {
implementation project(':ci')
implementation project(':bot')
implementation project(':host')
implementation project(':forge')
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

module {
name = 'org.openjdk.skara.bots.tester'
test {
requires 'org.junit.jupiter.api'
requires 'org.openjdk.skara.test'
requires 'org.openjdk.skara.host'
opens 'org.openjdk.skara.bots.tester' to 'org.junit.platform.commons'
}
}

dependencies {
implementation project(':bot')
implementation project(':ci')
implementation project(':census')
implementation project(':forge')
implementation project(':host')
implementation project(':issuetracker')
implementation project(':json')
implementation project(':vcs')

testImplementation project(':test')
}
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
module org.openjdk.skara.bots.tester {
requires org.openjdk.skara.bot;
requires org.openjdk.skara.vcs;
requires org.openjdk.skara.ci;

requires java.logging;

provides org.openjdk.skara.bot.BotFactory with org.openjdk.skara.bots.tester.TestBotFactory;
}
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.skara.bots.tester;

enum Stage {
NA,
ERROR,
REQUESTED,
PENDING,
APPROVED,
STARTED,
CANCELLED,
FINISHED
}

0 comments on commit 980b7a8

Please sign in to comment.
You can’t perform that action at this time.