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

Move testing information from the PR body to checks #962

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -51,6 +51,7 @@ dependencies {
implementation project(':bots:bridgekeeper')
implementation project(':bots:checkout')
implementation project(':bots:censussync')
implementation project(':bots:testinfo')
implementation project(':ci')
implementation project(':vcs')
implementation project(':jcheck')
@@ -86,7 +87,8 @@ images {
'org.openjdk.skara.bots.forward',
'org.openjdk.skara.bots.bridgekeeper',
'org.openjdk.skara.bots.checkout',
'org.openjdk.skara.bots.censussync']
'org.openjdk.skara.bots.censussync',
'org.openjdk.skara.bots.testinfo']
launchers = ['skara-bots': 'org.openjdk.skara.bots.cli/org.openjdk.skara.bots.cli.BotLauncher']
options = ["--module-path", "plugins"]
bundles = ['zip', 'tar.gz']
@@ -417,29 +417,6 @@ private String getStatusMessage(List<Comment> comments, List<Review> reviews, Pu
progressBody.append(warningListToText(allAdditionalErrors));
}

if (pr.sourceRepository().isPresent()) {
var sourceRepo = pr.sourceRepository().get();
var checks = sourceRepo.allChecks(pr.headHash());

var resultSummary = TestResults.summarize(checks);
if (resultSummary.isPresent()) {
progressBody.append(resultSummary.get());
var expiration = TestResults.expiresIn(checks);
expiration.ifPresent(this::setExpiration);
} else {
try {
var headCommit = localRepo.commitMetadata(pr.headHash());
if (headCommit.isPresent()) {
// If the commit is recent, perhaps test results will appear soon
if (headCommit.get().committed().isAfter(ZonedDateTime.now().minus(Duration.ofDays(1)))) {
setExpiration(Duration.ofMinutes(10));
}
}
} catch (IOException ignored) {
}
}
}

if (!integrationBlockers.isEmpty()) {
progressBody.append("\n\n### Integration blocker");
if (integrationBlockers.size() > 1) {
@@ -28,7 +28,6 @@
import org.openjdk.skara.test.*;

import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.nio.file.attribute.PosixFilePermission;
@@ -1754,53 +1753,4 @@ void differentAuthors(TestInfo testInfo) throws IOException {
assertEquals(numComments, pr.comments().size());
}
}

@Test
void preSubmitInSummary(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo);
var tempFolder = new TemporaryDirectory()) {
var author = credentials.getHostedRepository();
var reviewer = credentials.getHostedRepository();
var issues = credentials.getIssueProject();

var censusBuilder = credentials.getCensusBuilder()
.addAuthor(author.forge().currentUser().id())
.addReviewer(reviewer.forge().currentUser().id());
var checkBot = PullRequestBot.newBuilder().repo(author).censusRepo(censusBuilder.build()).issueProject(issues).build();

// Populate the projects repository
var localRepo = CheckableRepository.init(tempFolder.path(), author.repositoryType(), Path.of("appendable.txt"),
Set.of("issues"), null);
var masterHash = localRepo.resolve("master").orElseThrow();
localRepo.push(masterHash, author.url(), "master", true);

// Make a draft PR where we can add some checks
var editHash = CheckableRepository.appendAndCommit(localRepo);
localRepo.push(editHash, author.url(), "preedit", true);
var draftPr = credentials.createPullRequest(author, "master", "preedit", "This is a pull request", true);
var check1 = CheckBuilder.create("ps1", editHash).title("PS1");
draftPr.createCheck(check1.build());
draftPr.updateCheck(check1.complete(true).build());
var check2 = CheckBuilder.create("ps2", editHash).title("PS2");
draftPr.createCheck(check2.build());
draftPr.updateCheck(check2.complete(false).build());
var check3 = CheckBuilder.create("ps3", editHash).title("PS3");
draftPr.createCheck(check3.build());
draftPr.updateCheck(check3.details(URI.create("https://www.example.com")).complete(false).build());

// Now make an actual PR
localRepo.push(editHash, author.url(), "edit", true);
var pr = credentials.createPullRequest(author, "master", "edit", "This is a pull request");

// Check the status
TestBotRunner.runPeriodicItems(checkBot);

// The body should contain the issue title
assertTrue(pr.body().contains("Testing"));
assertTrue(pr.body().contains("| | ps1 | ps2 | ps3 |"));
assertTrue(pr.body().contains("**Failed test tasks**"));
assertTrue(pr.body().contains("- [ps3](https://www.example.com)"));
assertTrue(pr.body().contains("- `ps2`"));
}
}
}

This file was deleted.

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2020, 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.testinfo'
test {
requires 'org.junit.jupiter.api'
requires 'org.openjdk.skara.test'
opens 'org.openjdk.skara.bots.testinfo' to 'org.junit.platform.commons'
}
}

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

testImplementation project(':test')
}