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 jobs from GitHub actions API #205

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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,57 @@
/*-
* -\-\-
* 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.workflowjobs;

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 = ImmutableListWorkflowJobsQueryParams.class)
@JsonDeserialize(as = ImmutableListWorkflowJobsQueryParams.class)
public interface ListWorkflowJobsQueryParams extends Parameters {
Optional<Filter> filter();

/**
* 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();

enum Filter {
latest,
completed_at,
all
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*-
* -\-\-
* 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.workflowjobs;

/**
* The possible status values of a WorkflowJob's status field.
* &gt;p/&lt;
* Value of the status property can be one of: "queued", "in_progress", or "completed". Only GitHub Actions can set a status of "waiting", "pending", or "requested".
* When it’s “completed,” it makes sense to check if it finished successfully. We need a value of the conclusion property.
* Conclusion Can be one of the “success”, “failure”, “neutral”, “cancelled”, “skipped”, “timed_out”, or “action_required”.
* &gt;p/&lt;
* &#064;See <a href="https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository">The GitHub API docs</a>
* &#064;See also <a href="https://github.com/github/rest-api-description/issues/1634#issuecomment-2230666873">GitHub rest api docs issue #1634</a>
*/
public enum WorkflowJobConclusion {
success,
failure,
neutral,
cancelled,
skipped,
timed_out,
action_required
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/*-
* -\-\-
* 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.workflowjobs;

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

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

@Value.Immutable
@GithubStyle
@JsonDeserialize(as = ImmutableWorkflowJobResponse.class)
public interface WorkflowJobResponse {
/**
* The id of the job.
* (Required)
*/
long id();

/**
* The id of the associated workflow run.
* (Required)
*/
long runId();

/**
* (Required)
*/
String runUrl();

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

/**
* (Required)
*/
String nodeId();

/**
* The SHA of the commit that is being run.
* (Required)
*/
String headSha();

/**
* (Required)
*/
String url();

/**
* (Required)
*/
String htmlUrl();

/**
* The phase of the lifecycle that the job is currently in.
* (Required)
*/
WorkflowJobStatus status();

/**
* The outcome of the job.
* (Required)
*/
WorkflowJobConclusion conclusion();

/**
* The time that the job created, in ISO 8601 format.
*/
@Nullable
ZonedDateTime createdAt();

/**
* The time that the job started, in ISO 8601 format.
* (Required)
*/
ZonedDateTime startedAt();

/**
* The time that the job finished, in ISO 8601 format.
* (Required)
*/
ZonedDateTime completedAt();

/**
* The name of the job.
* (Required)
*/
String name();

/**
* Steps in this job.
*/
@Nullable
List<WorkflowJobStep> steps();

/**
* (Required)
*/
String checkRunUrl();

/**
* Labels for the workflow job. Specified by the "runs_on" attribute in the action's workflow file.
* (Required)
*/
List<String> labels();

/**
* The ID of the runner to which this job has been assigned. (If a runner hasn't yet been assigned, this will be null.)
*/
@Nullable
Integer runnerId();

/**
* The name of the runner to which this job has been assigned. (If a runner hasn't yet been assigned, this will be null.)
*/
@Nullable
String runnerName();

/**
* The ID of the runner group to which this job has been assigned. (If a runner hasn't yet been assigned, this will be null.)
*/
@Nullable
Integer runnerGroupId();

/**
* The name of the runner group to which this job has been assigned. (If a runner hasn't yet been assigned, this will be null.)* (Required)
*/
@Nullable
String runnerGroupName();

/**
* The name of the workflow.
* (Required)
*/
String workflowName();

/**
* The name of the current branch.
* (Required)
*/
String headBranch();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*-
* -\-\-
* 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.workflowjobs;

/**
* The possible status values of a WorkflowJob's status field.
* &gt;p/&lt;
* Value of the status property can be one of: "queued", "in_progress", or "completed". Only GitHub Actions can set a status of "waiting", "pending", or "requested".
* When it’s “completed,” it makes sense to check if it finished successfully. We need a value of the conclusion property.
* Conclusion Can be one of the “success”, “failure”, “neutral”, “cancelled”, “skipped”, “timed_out”, or “action_required”.
* &gt;p/&lt;
* &#064;See <a href="https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository">The GitHub API docs</a>
* &#064;See also <a href="https://github.com/github/rest-api-description/issues/1634#issuecomment-2230666873">GitHub rest api docs issue #1634</a>
*/
public enum WorkflowJobStatus {
completed,
in_progress,
queued,
requested,
waiting,
pending
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*-
* -\-\-
* 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.workflowjobs;

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

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

@Value.Immutable
@GithubStyle
@JsonDeserialize(as = ImmutableWorkflowJobStep.class)
public interface WorkflowJobStep {

/**
* The phase of the lifecycle that the job is currently in.
* (Required)
*/
WorkflowJobStatus status();

/**
* The outcome of the job. Only set if status==completed
*/
@Nullable
WorkflowJobConclusion conclusion();

/**
* The name of the job.
* (Required)
*/
String name();

/**
* (Required)
*/
Integer number();

/**
* The time that the step started, in ISO 8601 format.
*/
ZonedDateTime startedAt();

/**
* The time that the job finished, in ISO 8601 format.
*/
ZonedDateTime completedAt();
}
Loading
Loading