Skip to content

Commit

Permalink
Merge branch 'main' into feat-pydantic-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
alithethird authored Sep 27, 2024
2 parents 2f70824 + 30fcc50 commit e46ebc4
Show file tree
Hide file tree
Showing 39 changed files with 1,352 additions and 485 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ jobs:
uses: canonical/operator-workflows/.github/workflows/test.yaml@main
secrets: inherit
with:
self-hosted-runner: true
self-hosted-runner-label: "edge"
self-hosted-runner: false
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[project]
name = "github-runner-manager"
version = "0.2.0"
version = "0.3.0"
authors = [
{ name = "Canonical IS DevOps", email = "[email protected]" },
]
Expand Down Expand Up @@ -46,7 +46,7 @@ omit = [
]

[tool.coverage.report]
fail_under = 79
fail_under = 80
show_missing = true


Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fabric >=3,<4
ghapi
jinja2
kombu==5.4.0
kombu==5.4.2
openstacksdk>=3,<4
pydantic==2.8.2
pymongo==4.9.1
34 changes: 29 additions & 5 deletions src-docs/github_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,43 @@ Delete the self-hosted runner from GitHub.

---

<a href="../src/github_runner_manager/github_client.py#L203"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/github_client.py#L244"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_job_info`

```python
get_job_info(
get_job_info(path: GitHubRepo, job_id: str) → JobInfo
```

Get information about a job identified by the job id.



**Args:**

- <b>`path`</b>: GitHub repository path in the format '<owner>/<repo>'.
- <b>`job_id`</b>: The job id.



**Returns:**
The JSON response from the API.

---

<a href="../src/github_runner_manager/github_client.py#L203"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_job_info_by_runner_name`

```python
get_job_info_by_runner_name(
path: GitHubRepo,
workflow_run_id: str,
runner_name: str
) → JobStats
) → JobInfo
```

Get information about a job for a specific workflow run.
Get information about a job for a specific workflow run identified by the runner name.



Expand All @@ -107,7 +131,7 @@ Get information about a job for a specific workflow run.

**Raises:**

- <b>`TokenError`</b>: if there was an error with the Github token crdential provided.
- <b>`TokenError`</b>: if there was an error with the Github token credential provided.
- <b>`JobNotFoundError`</b>: If no jobs were found.


Expand Down
44 changes: 35 additions & 9 deletions src-docs/manager.cloud_runner_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ Represent state of the instance hosting the runner.

<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L97"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `CloudInitStatus`
Represents the state of cloud-init script.

The cloud init script is used to launch ephemeral GitHub runners. If the script is being initialized, GitHub runner is listening for jobs or GitHub runner is running the job, the cloud-init script should report "running" status.

Refer to the official documentation on cloud-init status: https://cloudinit.readthedocs.io/en/latest/howto/status.html.



**Attributes:**

- <b>`NOT_STARTED`</b>: The cloud-init script has not yet been started.
- <b>`RUNNING`</b>: The cloud-init script is running.
- <b>`DONE`</b>: The cloud-init script has completed successfully.
- <b>`ERROR`</b>: There was an error while running the cloud-init script.
- <b>`DEGRADED`</b>: There was a non-critical issue while running the cloud-inits script.
- <b>`DISABLED`</b>: Cloud init was disabled by other system configurations.





---

<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L124"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GitHubRunnerConfig`
Configuration for GitHub runner spawned.

Expand Down Expand Up @@ -81,7 +107,7 @@ __init__(github_path: GitHubOrg | GitHubRepo, labels: list[str]) → None

---

<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L110"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L137"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `SupportServiceConfig`
Configuration for supporting services for runners.
Expand Down Expand Up @@ -118,7 +144,7 @@ __init__(

---

<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L127"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L154"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `CloudRunnerInstance`
Information on the runner on the cloud.
Expand Down Expand Up @@ -155,7 +181,7 @@ __init__(

---

<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L144"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L171"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `CloudRunnerManager`
Manage runner instance on cloud.
Expand All @@ -177,7 +203,7 @@ Get the name prefix of the self-hosted runners.

---

<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L200"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L227"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `cleanup`

Expand All @@ -197,7 +223,7 @@ Perform health check on runner and delete the runner if it fails.

---

<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L156"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L183"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `create_runner`

Expand All @@ -215,7 +241,7 @@ Create a self-hosted runner.

---

<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L181"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L208"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `delete_runner`

Expand All @@ -234,7 +260,7 @@ Delete self-hosted runner.

---

<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L190"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L217"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `flush_runners`

Expand All @@ -253,7 +279,7 @@ Stop all runners.

---

<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L164"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L191"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_runner`

Expand All @@ -271,7 +297,7 @@ Get a self-hosted runner by instance id.

---

<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L172"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/cloud_runner_manager.py#L199"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_runners`

Expand Down
14 changes: 5 additions & 9 deletions src-docs/manager.runner_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Configuration for the runner manager.

**Attributes:**

- <b>`name`</b>: A name to identify this manager.
- <b>`token`</b>: GitHub personal access token to query GitHub API.
- <b>`path`</b>: Path to GitHub repository or organization to registry the runners.

Expand All @@ -85,7 +86,7 @@ Configuration for the runner manager.
### <kbd>method</kbd> `__init__`

```python
__init__(token: str, path: GitHubOrg | GitHubRepo) → None
__init__(name: str, token: str, path: GitHubOrg | GitHubRepo) → None
```


Expand All @@ -98,7 +99,7 @@ __init__(token: str, path: GitHubOrg | GitHubRepo) → None

---

<a href="../src/github_runner_manager/manager/runner_manager.py#L94"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/runner_manager.py#L96"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `RunnerManager`
Manage the runners.
Expand All @@ -110,16 +111,12 @@ Manage the runners.
- <b>`manager_name`</b>: A name to identify this manager.
- <b>`name_prefix`</b>: The name prefix of the runners.

<a href="../src/github_runner_manager/manager/runner_manager.py#L102"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/runner_manager.py#L104"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

```python
__init__(
manager_name: str,
cloud_runner_manager: CloudRunnerManager,
config: RunnerManagerConfig
)
__init__(cloud_runner_manager: CloudRunnerManager, config: RunnerManagerConfig)
```

Construct the object.
Expand All @@ -128,7 +125,6 @@ Construct the object.

**Args:**

- <b>`manager_name`</b>: A name to identify this manager.
- <b>`cloud_runner_manager`</b>: For managing the cloud instance of the runner.
- <b>`config`</b>: Configuration of this class.

Expand Down
19 changes: 11 additions & 8 deletions src-docs/manager.runner_scaler.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Module for scaling the runners amount.

---

<a href="../src/github_runner_manager/manager/runner_scaler.py#L23"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/runner_scaler.py#L26"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `RunnerInfo`
Information on the runners.
Expand Down Expand Up @@ -50,17 +50,20 @@ __init__(

---

<a href="../src/github_runner_manager/manager/runner_scaler.py#L44"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/runner_scaler.py#L47"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `RunnerScaler`
Manage the reconcile of runners.

<a href="../src/github_runner_manager/manager/runner_scaler.py#L47"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/runner_scaler.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

```python
__init__(runner_manager: RunnerManager, reactive_config: ReactiveConfig | None)
__init__(
runner_manager: RunnerManager,
reactive_runner_config: RunnerConfig | None
)
```

Construct the object.
Expand All @@ -70,14 +73,14 @@ Construct the object.
**Args:**

- <b>`runner_manager`</b>: The RunnerManager to perform runner reconcile.
- <b>`reactive_config`</b>: Reactive runner configuration.
- <b>`reactive_runner_config`</b>: Reactive runner configuration.




---

<a href="../src/github_runner_manager/manager/runner_scaler.py#L93"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/runner_scaler.py#L98"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `flush`

Expand All @@ -100,7 +103,7 @@ Flush the runners.

---

<a href="../src/github_runner_manager/manager/runner_scaler.py#L57"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/runner_scaler.py#L62"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_runner_info`

Expand All @@ -117,7 +120,7 @@ Get information on the runners.

---

<a href="../src/github_runner_manager/manager/runner_scaler.py#L111"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/github_runner_manager/manager/runner_scaler.py#L116"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `reconcile`

Expand Down
Loading

0 comments on commit e46ebc4

Please sign in to comment.