Skip to content

Commit

Permalink
chore: flake8 fixes (#248)
Browse files Browse the repository at this point in the history
* chore: reorder config alphabetically

* chore: add openstack-cloud-yaml config option

* chore: reorder charm state alphabetically

* chore: reorder charm state alphabetically

* chore: reorder requirements.txt alphabetically

* feat: initialize openstack connection

* ensure cloud config dir is present

* test microstack installation on gh hosted ones

* test microstack installation on gh hosted ones

* use two-xlarge

* use one step

* checkin current workflow

* Add integration test

* Specify microk8s-addons (disable rbac)

* bootstrap lxd controller

* give a try with xlarge

* Refactor and add unit tests

* Add call to test connection

* Move openstack check to __init__

* Revert "Move openstack check to __init__"

This reverts commit 103123d.

* Remove status in wait_for_idle

* Rename config name

* Cleanup

* update script

* update script with shellcheck directive

* Fix requirements

* Use clouds.yaml for integration test

* Generate clouds.yaml using sunbeam

* Fix openstack connect test in setup

* chore: ignore testing clouds.yaml

* chore: validate input type

* chore: move type validation to charm state module

* feat: initial openstack build image

* feat: reduce image size

* feat: create instance w/ cloud-init userdata script

* chore: define literal types for runner application

* chore: cloudimg multiarch support

* chore: factor out get runner application func

* chore: type hint openstack clouds yaml dict

* chore: build on test mode only

* chore: refactor too inject github client than instantiate from token

* test: test for openstack servers

* test: openstack integration test

* test: use only openstack

* fix: helpers import

* fix:connect cloud

* debug

* chore: remove unattended upgrades

* fix: use vm w/ machine constraints

* fix: use units in mem/disk size

* fix: translate to gigabytes

* fix: increase mem

* fix: increase timeout

* chore remove tmate debug

* chore: don't use lxd profile for openstack test

* chore: run modeprobe br_netfilter before lxc launch

* chore: revert image brnetfilter changes

* feat: on_install for openstack mode

* test: add additional charm config

* chore: move openstack handle to on_install hook

* chore: block all hooks on openstack config

* fix: add back e2e test run workflow

* chore: proxy configs

* chore: wait for server creation

* fix: create flavor

* chore: test flavour to small

* debug

* fix: add retry

* fix: use bootstrapped microstack for image buildtesting

* chore: add comment to reemove cluster bootstrap

* fix: sunbeam user show (user list permission denied)

* fix: stringify proxy vars

* test: unit tests for openstack manager

* add retry

* Revert "test: use only openstack"

This reverts commit cd8f391.

* remove tmate debug

* add back license

* remove extra line

* lint & test fixes

* refactor openstack_manager to openstack_cloud module

* refactor block_on_openstack_config

* update keyerror message

* test: fix test for updated error message

* fix: pass state to block_on_openstack_config

* refactor get_runner_applications

* add pipefail for build images

* add cloudconfig type

* refactor modules for unit testing

* fix style issues

* rename build image to build lxd image

* check for different subprocess error

* conditional /etc/environment update

* use already defined constant

* charm config to constants

* flake8 setup

* use field validator instead of root validator (cryptic error message _-root__)

* use factory dict instead of config instance method

* update pyproject

* fix docstring issues

* fix docstring issues(complete)

* docstrings-complete issues

* fs mock exc call issues

* flake8 decorator issues

* refactor too-complex charm state

* merge conflict fixes

* openstack build_image too complex refactor

* runner remove too complex refactor

* runner manager reconcile too complex refactor

* shared_fs delete too complex refactor

* type annotations

* no immediate re-raise

* lower coverage

* ignore whitelist

* false lint alarm

* remove merge conflicts

* typo fixes

* import from errors

* pylint ignore direct raise

* chore: remove duplicate logs

* replace generic type to actual type

* update docstring ignores desription

---------

Co-authored-by: Christopher Bartz <[email protected]>
  • Loading branch information
yanksyoon and cbartz authored Apr 9, 2024
1 parent 6415859 commit 35b79da
Show file tree
Hide file tree
Showing 71 changed files with 2,354 additions and 861 deletions.
10 changes: 0 additions & 10 deletions .flake8

This file was deleted.

6 changes: 3 additions & 3 deletions .woke.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ignore_files:
# Ignore pylintrc as it uses non compliant terminology: whitelist
- .pylintrc
rules:
# Ignore whitelist - we are using it to ignore pydantic in pyproject.toml and pylintrc
- name: whitelist
24 changes: 17 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,34 @@
[tool.bandit]
exclude_dirs = ["/venv/"]
[tool.bandit.assert_used]
skips = ["*/*test.py", "*/test_*.py"]
skips = ["*/*test.py", "*/test_*.py", "*tests/*.py"]

# Testing tools configuration
[tool.coverage.run]
branch = true
omit = [
# Contains interface for calling LXD. Tested in integration tests and end to end tests.
"src/lxd.py",
# Contains interface for calling repo policy compliance service. Tested in integration test and end to end tests.
# Contains interface for calling repo policy compliance service. Tested in integration test
# and end to end tests.
"src/repo_policy_compliance_client.py",
]

[tool.coverage.report]
fail_under = 38
fail_under = 83
show_missing = true


[tool.pytest.ini_options]
minversion = "6.0"
log_cli_level = "INFO"

[tool.pylint.'MESSAGES CONTROL']
extension-pkg-whitelist = "pydantic"

# Formatting tools configuration
[tool.black]
line-length = 99
target-version = ["py310"]

[tool.isort]
line_length = 99
Expand All @@ -43,15 +47,21 @@ select = ["E", "W", "F", "C", "N", "R", "D", "H"]
# Ignore W503, E501 because using black creates errors with this
# Ignore D107 Missing docstring in __init__
ignore = ["W503", "E501", "D107"]
# D100, D101, D102, D103: Ignore missing docstrings in tests
per-file-ignores = ["tests/*:D100,D101,D102,D103,D104"]
# D100, D101, D102, D103, D104: Ignore docstring style issues in tests
per-file-ignores = ["tests/*:D100,D101,D102,D103,D104,D205,D212"]
docstring-convention = "google"
# Check for properly formatted copyright header in each file
copyright-check = "True"
copyright-author = "Canonical Ltd."
copyright-regexp = "Copyright\\s\\d{4}([-,]\\d{4})*\\s+%(author)s"

[tool.mypy]
ignore_missing_imports = true
check_untyped_defs = true
disallow_untyped_defs = true
explicit_package_bases = true
ignore_missing_imports = true
namespace_packages = true

[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false
41 changes: 32 additions & 9 deletions src-docs/charm.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@ Charm for creating and managing GitHub self-hosted runner instances.
**Global Variables**
---------------
- **DEBUG_SSH_INTEGRATION_NAME**
- **GROUP_CONFIG_NAME**
- **LABELS_CONFIG_NAME**
- **PATH_CONFIG_NAME**
- **RECONCILE_INTERVAL_CONFIG_NAME**
- **TEST_MODE_CONFIG_NAME**
- **TOKEN_CONFIG_NAME**
- **RECONCILE_RUNNERS_EVENT**

---

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

## <kbd>function</kbd> `catch_charm_errors`

```python
catch_charm_errors(
func: Callable[[~CharmT, ~EventT], NoneType]
) → Callable[[~CharmT, ~EventT], NoneType]
func: Callable[[ForwardRef('GithubRunnerCharm'), ~EventT], NoneType]
) → Callable[[ForwardRef('GithubRunnerCharm'), ~EventT], NoneType]
```

Catch common errors in charm.
Expand All @@ -39,14 +44,14 @@ Catch common errors in charm.

---

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

## <kbd>function</kbd> `catch_action_errors`

```python
catch_action_errors(
func: Callable[[~CharmT, ActionEvent], NoneType]
) → Callable[[~CharmT, ActionEvent], NoneType]
func: Callable[[ForwardRef('GithubRunnerCharm'), ActionEvent], NoneType]
) → Callable[[ForwardRef('GithubRunnerCharm'), ActionEvent], NoneType]
```

Catch common errors in actions.
Expand All @@ -68,12 +73,24 @@ Catch common errors in actions.
## <kbd>class</kbd> `GithubRunnerCharm`
Charm for managing GitHub self-hosted runners.

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


**Attributes:**

- <b>`service_token_path`</b>: The path to token to access local services.
- <b>`repo_check_web_service_path`</b>: The path to repo-policy-compliance service directory.
- <b>`repo_check_web_service_script`</b>: The path to repo-policy-compliance web service script.
- <b>`repo_check_systemd_service`</b>: The path to repo-policy-compliance unit file.
- <b>`juju_storage_path`</b>: The path to juju storage.
- <b>`ram_pool_path`</b>: The path to memdisk storage.
- <b>`kernel_module_path`</b>: The path to kernel modules.

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

### <kbd>function</kbd> `__init__`

```python
__init__(*args, **kargs) → None
__init__(*args: Any, **kwargs: Any) → None
```

Construct the charm.
Expand All @@ -83,7 +100,13 @@ Construct the charm.
**Args:**

- <b>`args`</b>: List of arguments to be passed to the `CharmBase` class.
- <b>`kargs`</b>: List of keyword arguments to be passed to the `CharmBase` class.
- <b>`kwargs`</b>: List of keyword arguments to be passed to the `CharmBase` class.



**Raises:**

- <b>`RuntimeError`</b>: If invalid test configuration was detected.


---
Expand Down
Loading

0 comments on commit 35b79da

Please sign in to comment.