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 get and list workflow runs from GitHub actions API #204

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*-
* -\-\-
* github-api
* --
* Copyright (C) 2016 - 2020 Spotify AB
* --
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -/-/-
*/

package com.spotify.github.v3.actions.workflowruns;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.spotify.github.GithubStyle;
import com.spotify.github.Parameters;
import org.immutables.value.Value;

import java.util.Optional;

@Value.Immutable
@GithubStyle
@JsonSerialize(as = ImmutableGetWorkflowRunQueryParams.class)
@JsonDeserialize(as = ImmutableGetWorkflowRunQueryParams.class)
public interface GetWorkflowRunQueryParams extends Parameters {
/**
* If true pull requests are omitted from the response (empty array).
* >p<
* Default: false
*/
Optional<Boolean> excludePullRequests();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*-
* -\-\-
* github-api
* --
* Copyright (C) 2016 - 2020 Spotify AB
* --
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -/-/-
*/

package com.spotify.github.v3.actions.workflowruns;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.spotify.github.GithubStyle;
import com.spotify.github.Parameters;
import org.immutables.value.Value;

import java.util.Optional;

@Value.Immutable
@GithubStyle
@JsonSerialize(as = ImmutableListWorkflowRunsQueryParams.class)
@JsonDeserialize(as = ImmutableListWorkflowRunsQueryParams.class)
public interface ListWorkflowRunsQueryParams extends Parameters {
/**
* Returns someone's workflow runs. Use the login for the user who created the push associated with the check suite or workflow run.
*/
Optional<String> actor();

/**
* Returns workflow runs associated with a branch. Use the name of the branch of the push.
*/
Optional<String> branch();

/**
* Returns workflow run triggered by the event you specify. For example, push, pull_request or issue. For more information, see "Events that trigger workflows."
*/
Optional<String> event();

/**
* Returns workflow runs with the check run status or conclusion that you specify. For example, a conclusion can be success or a status can be in_progress. Only GitHub Actions can set a status of waiting, pending, or requested.
* &gt;p&lt;
* Can be one of: completed, action_required, cancelled, failure, neutral, skipped, stale, success, timed_out, in_progress, queued, requested, waiting, pending
*/
Optional<WorkflowRunStatus> status();

/**
* The number of results per page (max 100). For more information, see "Using pagination in the REST API."
* &gt;p&lt;
* Default: 30
*/
Optional<Integer> perPage();

/**
* The page number of the results to fetch. For more information, see "Using pagination in the REST API."
* &gt;p&lt;
* Default: 1
*/
Optional<Integer> page();

/**
* Returns workflow runs created within the given date-time range. Syntax with examples:
* &gt;p&lt;
* &lt;YYYY-MM-DD created:&lt;2016-04-29 matches workflow runs that were created after April 29, 2016.
* &lt;=YYYY-MM-DD created:&lt;=2017-04-01 matches workflow runs that were created on or after April 1, 2017.
* &gt;YYYY-MM-DD pushed:&gt;2012-07-05 matches workflow runs that were pushed to before July 5, 2012.
* &gt;=YYYY-MM-DD created:&gt;=2012-07-04 matches workflow runs that were created on or before July 4, 2012.
* YYYY-MM-DD..YYYY-MM-DD pushed:2016-04-30..2016-07-04 matches workflow runs that were pushed to between the end of April and July of 2016.
* YYYY-MM-DD..* created:2012-04-30..* matches workflow runs created on or after April 30th, 2012 containing the word "cats."
* *..YYYY-MM-DD created:*..2012-07-04 matches workflow runs created on or before July 4th, 2012 containing the word "cats."
* &gt;p&lt;
* You can also add optional time information THH:MM:SS+00:00 after the date, to filter by the hour, minute, and second. That's T, followed by HH:MM:SS (hour-minutes-seconds), and a UTC offset (+00:00).
* &gt;p&lt;
* Query Example
* YYYY-MM-DDTHH:MM:SS+00:00 created:2017-01-01T01:00:00+07:00..2017-03-01T15:30:15+07:00 matches workflow runs created between January 1, 2017 at 1 a.m. with a UTC offset of 07:00 and March 1, 2017 at 3 p.m. with a UTC offset of 07:00.
* YYYY-MM-DDTHH:MM:SSZ created:2016-03-21T14:11:00Z..2016-04-07T20:45:00Z matches workflow runs created between March 21, 2016 at 2:11pm and April 7, 2016 at 8:45pm.
*/
Optional<String> created();

/**
* If true pull requests are omitted from the response (empty array).
* &gt;p&lt;
* Default: false
*/
Optional<Boolean> excludePullRequests();

/**
* Returns workflow runs with the check_suite_id that you specify.
*/
Optional<Integer> checkSuiteId();

/**
* Only returns workflow runs that are associated with the specified head_sha.
*/
Optional<String> headSha();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
/*-
* -\-\-
* github-api
* --
* Copyright (C) 2016 - 2020 Spotify AB
* --
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -/-/-
*/

package com.spotify.github.v3.actions.workflowruns;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.spotify.github.GithubStyle;
import com.spotify.github.v3.User;
import com.spotify.github.v3.prs.PullRequestItem;
import com.spotify.github.v3.repos.PushCommit;
import org.immutables.value.Value;

import javax.annotation.Nullable;
import java.time.ZonedDateTime;
import java.util.List;

@Value.Immutable
@GithubStyle
@JsonDeserialize(as = ImmutableWorkflowRunResponse.class)
public interface WorkflowRunResponse {

/**
* The ID of the Workflow Run.
* (Required)
*/
long id();

/**
* The name of the Workflow Run.
* Not required as per schema.
*/
@Nullable
String name();

/**
* GitHub api node id. See <a href="https://docs.github.com/en/graphql/guides/using-global-node-ids">Using Global Node ids</a>
* (Required)
*/
String nodeId();

/**
* The ID of the associated check suite.
* Not required as per schema.
*/
@Nullable
Long checkSuiteId();

/**
* The node ID of the associated check suite.
* Not required as per schema.
*/
@Nullable
String checkSuiteNodeId();

/**
* The branch of the head commit that points to the version of the workflow being run.
* (Required)
*/
String headBranch();

/**
* The SHA of the head commit that points to the version of the workflow being run.
* (Required)
*/
String headSha();

/**
* The full path of the workflow
* (Required)
*/
String path();

/**
* The auto incrementing run number for the Workflow Run.
* (Required)
*/
Integer runNumber();

/**
* Attempt number of the run, 1 for first attempt and higher if the workflow was re-run.
* Not required as per schema.
*/
@Nullable
Integer runAttempt();

/**
* The event that lead to the trigger of this Workflow Run
* (Required)
*/
String event();

/**
* The status of this Workflow Run.
* (Required)
*/
WorkflowRunStatus status();

/**
* The result of the run.
*/
@Nullable
String conclusion();

/**
* The ID of the parent workflow.
* (Required)
*/
Integer workflowId();

/**
* The URL to the Workflow Run.
* (Required)
*/
String url();

/**
* URL for viewing the Workflow run on a browser
* (Required)
*/
String htmlUrl();

/**
* When the Workflow Run was created
* (Required)
*/
ZonedDateTime createdAt();

/**
* When the Workflow Run was last updated
* (Required)
*/
ZonedDateTime updatedAt();

/**
* The start time of the latest run. Resets on re-run.
* Not required as per schema.
*/
@Nullable
ZonedDateTime runStartedAt();

/**
* The URL to the jobs for the Workflow Run.
* (Required)
*/
String jobsUrl();

/**
* The URL to download the logs for the Workflow Run.
* (Required)
*/
String logsUrl();

/**
* The URL to the associated check suite.
* (Required)
*/
String checkSuiteUrl();

/**
* The URL to the artifacts for the Workflow Run.
* (Required)
*/
String artifactsUrl();

/**
* The URL to cancel the Workflow Run.
* (Required)
*/
String cancelUrl();

/**
* The URL to rerun the Workflow Run.
* (Required)
*/
String rerunUrl();

/**
* The URL to the previous attempted run of this workflow, if one exists.
* Not required as per schema.
*/
@Nullable
String previousAttemptUrl();

/**
* The URL to the workflow.
* (Required)
*/
String workflowUrl();

/**
* The event-specific title associated with the run or the run-name if set, or the value of `run-name` if it is set in the workflow.
* (Required)
*/
String displayTitle();

/**
* Pull requests that are open with a `head_sha` or `head_branch` that matches the Workflow Run. The returned pull requests do not necessarily indicate pull requests that triggered the run.
* (Required)
*/
List<PullRequestItem> pullRequests();

/**
* The GitHub user that triggered the initial Workflow Run. If the Workflow Run is a re-run, this value may differ from triggeringActor. Any workflow re-runs will use the privileges of actor, even if the actor initiating the re-run (triggeringActor) has different privileges.
* Not required as per schema.
*/
@Nullable
User actor();

/**
* The GitHub user that initiated the Workflow Run. If the Workflow Run is a re-run, this value may differ from actor. Any workflow re-runs will use the privileges of actor, even if the actor initiating the re-run (triggeringActor) has different privileges.
* Not required as per schema.
*/
@Nullable
User triggeringActor();

/**
* The head commit that points to the version of code the workflow being run on.
* <p>
* (Required)
*/
PushCommit headCommit();
}

Loading
Loading