mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-12 00:11:22 +00:00
343 lines
12 KiB
HTML
343 lines
12 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>GHCheckRun.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">GitHub API for Java</a> > <a href="index.source.html" class="el_package">org.kohsuke.github</a> > <span class="el_source">GHCheckRun.java</span></div><h1>GHCheckRun.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
|
import edu.umd.cs.findbugs.annotations.NonNull;
|
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
import org.kohsuke.github.GHWorkflowRun.Conclusion;
|
|
import org.kohsuke.github.GHWorkflowRun.Status;
|
|
import org.kohsuke.github.internal.EnumUtils;
|
|
import org.kohsuke.github.internal.Previews;
|
|
|
|
import java.io.IOException;
|
|
import java.net.URL;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
|
|
/**
|
|
* Represents a check run.
|
|
*
|
|
* @see <a href="https://developer.github.com/v3/checks/runs/">documentation</a>
|
|
*/
|
|
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD", "URF_UNREAD_FIELD" },
|
|
justification = "JSON API")
|
|
<span class="fc" id="L27">public class GHCheckRun extends GHObject {</span>
|
|
|
|
@JsonProperty("repository")
|
|
GHRepository owner;
|
|
|
|
private String status;
|
|
private String conclusion;
|
|
private String name;
|
|
private String headSha;
|
|
private String nodeId;
|
|
private String externalId;
|
|
private String startedAt;
|
|
private String completedAt;
|
|
private URL htmlUrl;
|
|
private URL detailsUrl;
|
|
private Output output;
|
|
private GHApp app;
|
|
private GHPullRequest[] pullRequests;
|
|
private GHCheckSuite checkSuite;
|
|
|
|
GHCheckRun wrap(GHRepository owner) {
|
|
<span class="fc" id="L48"> this.owner = owner;</span>
|
|
<span class="fc" id="L49"> wrap(owner.root);</span>
|
|
<span class="fc" id="L50"> return this;</span>
|
|
}
|
|
|
|
GHCheckRun wrap(GitHub root) {
|
|
<span class="fc" id="L54"> this.root = root;</span>
|
|
<span class="pc bpc" id="L55" title="1 of 2 branches missed."> if (owner != null) {</span>
|
|
<span class="fc" id="L56"> owner.wrap(root);</span>
|
|
<span class="pc bpc" id="L57" title="1 of 4 branches missed."> if (pullRequests != null && pullRequests.length != 0) {</span>
|
|
<span class="fc bfc" id="L58" title="All 2 branches covered."> for (GHPullRequest singlePull : pullRequests) {</span>
|
|
<span class="fc" id="L59"> singlePull.wrap(owner);</span>
|
|
}
|
|
}
|
|
|
|
}
|
|
<span class="pc bpc" id="L64" title="1 of 2 branches missed."> if (checkSuite != null) {</span>
|
|
<span class="pc bpc" id="L65" title="1 of 2 branches missed."> if (owner != null) {</span>
|
|
<span class="fc" id="L66"> checkSuite.wrap(owner);</span>
|
|
} else {
|
|
<span class="nc" id="L68"> checkSuite.wrap(root);</span>
|
|
}
|
|
}
|
|
<span class="pc bpc" id="L71" title="1 of 2 branches missed."> if (app != null) {</span>
|
|
<span class="fc" id="L72"> app.wrapUp(root);</span>
|
|
}
|
|
|
|
<span class="fc" id="L75"> return this;</span>
|
|
}
|
|
|
|
GHPullRequest[] wrap() {
|
|
<span class="nc" id="L79"> return pullRequests;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets status of the check run.
|
|
*
|
|
* @return Status of the check run
|
|
* @see Status
|
|
*/
|
|
@WithBridgeMethods(value = String.class, adapterMethod = "statusAsStr")
|
|
public Status getStatus() {
|
|
<span class="fc" id="L90"> return Status.from(status);</span>
|
|
}
|
|
|
|
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getStatus")
|
|
private Object statusAsStr(Status status, Class type) {
|
|
<span class="nc" id="L95"> return status;</span>
|
|
}
|
|
|
|
<span class="fc" id="L98"> public static enum Status {</span>
|
|
<span class="fc" id="L99"> QUEUED, IN_PROGRESS, COMPLETED, UNKNOWN;</span>
|
|
|
|
public static Status from(String value) {
|
|
<span class="fc" id="L102"> return EnumUtils.getNullableEnumOrDefault(Status.class, value, Status.UNKNOWN);</span>
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
<span class="fc" id="L107"> return name().toLowerCase(Locale.ROOT);</span>
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Gets conclusion of a completed check run.
|
|
*
|
|
* @return Status of the check run
|
|
* @see Conclusion
|
|
*/
|
|
@WithBridgeMethods(value = String.class, adapterMethod = "conclusionAsStr")
|
|
public Conclusion getConclusion() {
|
|
<span class="fc" id="L119"> return Conclusion.from(conclusion);</span>
|
|
}
|
|
|
|
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "Bridge method of getConclusion")
|
|
private Object conclusionAsStr(Conclusion conclusion, Class type) {
|
|
<span class="nc" id="L124"> return conclusion;</span>
|
|
}
|
|
|
|
/**
|
|
* Final conclusion of the check.
|
|
*
|
|
* From <a href="https://docs.github.com/en/rest/reference/checks#create-a-check-run--parameters">Check Run
|
|
* Parameters - <code>conclusion</code></a>.
|
|
*/
|
|
<span class="fc" id="L133"> public static enum Conclusion {</span>
|
|
<span class="fc" id="L134"> ACTION_REQUIRED, CANCELLED, FAILURE, NEUTRAL, SUCCESS, SKIPPED, STALE, TIMED_OUT, UNKNOWN;</span>
|
|
|
|
public static Conclusion from(String value) {
|
|
<span class="fc" id="L137"> return EnumUtils.getNullableEnumOrDefault(Conclusion.class, value, Conclusion.UNKNOWN);</span>
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
<span class="fc" id="L142"> return name().toLowerCase(Locale.ROOT);</span>
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Gets the custom name of this check run.
|
|
*
|
|
* @return Name of the check run
|
|
*/
|
|
public String getName() {
|
|
<span class="fc" id="L152"> return name;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the HEAD SHA.
|
|
*
|
|
* @return sha for the HEAD commit
|
|
*/
|
|
public String getHeadSha() {
|
|
<span class="fc" id="L161"> return headSha;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the pull requests participated in this check run.
|
|
*
|
|
* Note this field is only populated for events. When getting a {@link GHCheckRun} outside of an event, this is
|
|
* always empty.
|
|
*
|
|
* @return the list of {@link GHPullRequest}s for this check run. Only populated for events.
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public List<GHPullRequest> getPullRequests() throws IOException {
|
|
<span class="pc bpc" id="L175" title="2 of 4 branches missed."> if (pullRequests != null && pullRequests.length != 0) {</span>
|
|
<span class="fc bfc" id="L176" title="All 2 branches covered."> for (GHPullRequest singlePull : pullRequests) {</span>
|
|
// Only refresh if we haven't do so before
|
|
<span class="fc" id="L178"> singlePull.refresh(singlePull.getTitle());</span>
|
|
}
|
|
<span class="fc" id="L180"> return Collections.unmodifiableList(Arrays.asList(pullRequests));</span>
|
|
}
|
|
<span class="nc" id="L182"> return Collections.emptyList();</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the HTML URL: https://github.com/[owner]/[repo-name]/runs/[check-run-id], usually an GitHub Action page of
|
|
* the check run.
|
|
*
|
|
* @return HTML URL
|
|
*/
|
|
@Override
|
|
public URL getHtmlUrl() {
|
|
<span class="fc" id="L193"> return htmlUrl;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the global node id to access most objects in GitHub.
|
|
*
|
|
* @see <a href="https://developer.github.com/v4/guides/using-global-node-ids/">documentation</a>
|
|
* @return Global node id
|
|
*/
|
|
public String getNodeId() {
|
|
<span class="fc" id="L203"> return nodeId;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets a reference for the check run on the integrator's system.
|
|
*
|
|
* @return Reference id
|
|
*/
|
|
public String getExternalId() {
|
|
<span class="fc" id="L212"> return externalId;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the details URL from which to find full details of the check run on the integrator's site.
|
|
*
|
|
* @return Details URL
|
|
*/
|
|
public URL getDetailsUrl() {
|
|
<span class="fc" id="L221"> return detailsUrl;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the start time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
|
|
*
|
|
* @return Timestamp of the start time
|
|
*/
|
|
public Date getStartedAt() {
|
|
<span class="fc" id="L230"> return GitHubClient.parseDate(startedAt);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the completed time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
|
|
*
|
|
* @return Timestamp of the completed time
|
|
*/
|
|
public Date getCompletedAt() {
|
|
<span class="fc" id="L239"> return GitHubClient.parseDate(completedAt);</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the GitHub app this check run belongs to, included in response.
|
|
*
|
|
* @return GitHub App
|
|
*/
|
|
public GHApp getApp() {
|
|
<span class="fc" id="L248"> return app;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the check suite this check run belongs to
|
|
*
|
|
* @return Check suite
|
|
*/
|
|
public GHCheckSuite getCheckSuite() {
|
|
<span class="fc" id="L257"> return checkSuite;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets an output for a check run.
|
|
*
|
|
* @return Output of a check run
|
|
*/
|
|
public Output getOutput() {
|
|
<span class="fc" id="L266"> return output;</span>
|
|
}
|
|
|
|
/**
|
|
* Represents an output in a check run to include summary and other results.
|
|
*
|
|
* @see <a href="https://developer.github.com/v3/checks/runs/#output-object">documentation</a>
|
|
*/
|
|
<span class="fc" id="L274"> public static class Output {</span>
|
|
private String title;
|
|
private String summary;
|
|
private String text;
|
|
private int annotationsCount;
|
|
private URL annotationsUrl;
|
|
|
|
/**
|
|
* Gets the title of check run.
|
|
*
|
|
* @return title of check run
|
|
*/
|
|
public String getTitle() {
|
|
<span class="fc" id="L287"> return title;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the summary of the check run, note that it supports Markdown.
|
|
*
|
|
* @return summary of check run
|
|
*/
|
|
public String getSummary() {
|
|
<span class="fc" id="L296"> return summary;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the details of the check run, note that it supports Markdown.
|
|
*
|
|
* @return Details of the check run
|
|
*/
|
|
public String getText() {
|
|
<span class="fc" id="L305"> return text;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the annotation count of a check run.
|
|
*
|
|
* @return annotation count of a check run
|
|
*/
|
|
public int getAnnotationsCount() {
|
|
<span class="fc" id="L314"> return annotationsCount;</span>
|
|
}
|
|
|
|
/**
|
|
* Gets the URL of annotations.
|
|
*
|
|
* @return URL of annotations
|
|
*/
|
|
public URL getAnnotationsUrl() {
|
|
<span class="fc" id="L323"> return annotationsUrl;</span>
|
|
}
|
|
}
|
|
|
|
<span class="fc" id="L327"> public static enum AnnotationLevel {</span>
|
|
<span class="fc" id="L328"> NOTICE, WARNING, FAILURE</span>
|
|
}
|
|
|
|
/**
|
|
* Updates this check run.
|
|
*
|
|
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
|
|
*/
|
|
@Preview(Previews.ANTIOPE)
|
|
@Deprecated
|
|
public @NonNull GHCheckRunBuilder update() {
|
|
<span class="fc" id="L339"> return new GHCheckRunBuilder(owner, getId());</span>
|
|
}
|
|
|
|
}
|
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html> |