Skip to main content

subspace_client_github/
actions.rs

1//! GitHub Actions, deployments and releases REST client.
2//!
3//! Calls are synchronous and bounded. Dashboard callers run them off the UI
4//! thread. Workflow YAML parsing is pure and reports unsupported or malformed
5//! definitions as [`Definition::Unreadable`].
6
7mod client;
8mod definition;
9mod model;
10mod request;
11mod workflow;
12
13pub use definition::{match_job_dependencies, parse_workflow_definition};
14pub use model::*;
15
16/// GitHub Actions operations using the shared client's credentials and transport.
17pub trait ActionsApi {
18    fn actions_workflows(
19        &self,
20        login: &str,
21        repo: &str,
22    ) -> Result<Page<Workflow>, subspace_core::http::Error>;
23    fn actions_runs(
24        &self,
25        login: &str,
26        repo: &str,
27        filters: &RunFilters,
28    ) -> Result<Page<WorkflowRun>, subspace_core::http::Error>;
29    fn actions_run(
30        &self,
31        login: &str,
32        repo: &str,
33        run_id: u64,
34    ) -> Result<WorkflowRun, subspace_core::http::Error>;
35    fn actions_jobs(
36        &self,
37        login: &str,
38        repo: &str,
39        run_id: u64,
40    ) -> Result<Page<Job>, subspace_core::http::Error>;
41    fn actions_job_log(
42        &self,
43        login: &str,
44        repo: &str,
45        job_id: u64,
46    ) -> Result<JobLog, subspace_core::http::Error>;
47    fn actions_workflow_definition(
48        &self,
49        login: &str,
50        repo: &str,
51        sha: &str,
52        path: &str,
53    ) -> Result<Definition<WorkflowDefinition>, subspace_core::http::Error>;
54    fn actions_pending_deployments(
55        &self,
56        login: &str,
57        repo: &str,
58        run_id: u64,
59    ) -> Result<Vec<PendingDeployment>, subspace_core::http::Error>;
60    fn actions_environments(
61        &self,
62        login: &str,
63        repo: &str,
64    ) -> Result<Page<Environment>, subspace_core::http::Error>;
65    fn actions_deployments(
66        &self,
67        login: &str,
68        repo: &str,
69        environment: Option<&str>,
70    ) -> Result<Page<Deployment>, subspace_core::http::Error>;
71    fn actions_latest_deployment(
72        &self,
73        login: &str,
74        repo: &str,
75        environment: &str,
76    ) -> Result<Option<Deployment>, subspace_core::http::Error> {
77        self.actions_deployments(login, repo, Some(environment))
78            .map(|page| page.items.into_iter().next())
79    }
80    fn actions_releases(
81        &self,
82        login: &str,
83        repo: &str,
84    ) -> Result<Page<Release>, subspace_core::http::Error>;
85    fn actions_tags(
86        &self,
87        login: &str,
88        repo: &str,
89    ) -> Result<Page<TagRef>, subspace_core::http::Error>;
90    fn dispatch_workflow(
91        &self,
92        login: &str,
93        request: &DispatchRequest<'_>,
94    ) -> Result<(), subspace_core::http::Error>;
95    fn rerun_workflow(
96        &self,
97        login: &str,
98        repo: &str,
99        run_id: u64,
100    ) -> Result<(), subspace_core::http::Error>;
101    fn rerun_failed_jobs(
102        &self,
103        login: &str,
104        repo: &str,
105        run_id: u64,
106    ) -> Result<(), subspace_core::http::Error>;
107    fn cancel_workflow(
108        &self,
109        login: &str,
110        repo: &str,
111        run_id: u64,
112    ) -> Result<(), subspace_core::http::Error>;
113    fn review_pending_deployments(
114        &self,
115        login: &str,
116        request: &ReviewPendingRequest<'_>,
117    ) -> Result<(), subspace_core::http::Error>;
118}
119
120#[cfg(test)]
121mod tests;