Skip to content

Commit 32960d6

Browse files
committed
ci: add lint + test + PyPI publish workflows; fix all ruff violations
- Add .github/workflows/ci.yml: ruff lint gate + pytest on Python 3.9-3.12 - Add .github/workflows/publish.yml: build & publish to PyPI on tag push (OIDC) - Add ruff and pytest to dev dependencies in pyproject.toml - Fix all ruff E701/E741/F841/F811 violations across orca_cli/ and tests/ - Remove duplicate backup command block in volume.py
1 parent a090231 commit 32960d6

86 files changed

Lines changed: 428 additions & 532 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
name: Lint (ruff)
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.11"
19+
20+
- name: Install ruff
21+
run: pip install ruff
22+
23+
- name: Run ruff
24+
run: ruff check .
25+
26+
test:
27+
name: Tests (Python ${{ matrix.python-version }})
28+
runs-on: ubuntu-latest
29+
needs: lint
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
python-version: ["3.9", "3.10", "3.11", "3.12"]
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
42+
- name: Install dependencies
43+
run: |
44+
pip install poetry
45+
poetry install --with dev
46+
47+
- name: Run tests
48+
run: poetry run pytest tests/ -v --tb=short

.github/workflows/publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
ci:
10+
name: Lint + Tests
11+
uses: ./.github/workflows/ci.yml
12+
13+
publish:
14+
name: Build & Publish
15+
runs-on: ubuntu-latest
16+
needs: ci
17+
environment: pypi
18+
permissions:
19+
id-token: write # required for OIDC trusted publisher
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.11"
27+
28+
- name: Install poetry
29+
run: pip install poetry
30+
31+
- name: Set version from tag
32+
run: |
33+
TAG=${GITHUB_REF#refs/tags/v}
34+
poetry version "$TAG"
35+
36+
- name: Build package
37+
run: poetry build
38+
39+
- name: Publish to PyPI
40+
uses: pypa/gh-action-pypi-publish@release/v1

orca_cli/commands/aggregate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import click
66

77
from orca_cli.core.context import OrcaContext
8-
from orca_cli.core.output import output_options, print_list, print_detail, console
8+
from orca_cli.core.output import console, output_options, print_detail, print_list
99

1010

1111
def _nova(client) -> str:

orca_cli/commands/application_credential.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import click
66

77
from orca_cli.core.context import OrcaContext
8-
from orca_cli.core.output import output_options, print_list, print_detail, console
8+
from orca_cli.core.output import console, output_options, print_detail, print_list
99

1010

1111
def _iam(client) -> str:
@@ -98,7 +98,7 @@ def app_credential_create(ctx, name, description, secret, expires_at, unrestrict
9898
console.print(f"[green]Application credential '{a.get('name')}' ({a.get('id')}) created.[/green]")
9999
if a.get("secret"):
100100
console.print(f" [cyan]Secret:[/cyan] {a['secret']}")
101-
console.print(f" [bold yellow]This secret will NOT be shown again.[/bold yellow]")
101+
console.print(" [bold yellow]This secret will NOT be shown again.[/bold yellow]")
102102

103103

104104
@application_credential.command("delete")

orca_cli/commands/audit.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from orca_cli.core.context import OrcaContext
88
from orca_cli.core.output import console
99

10-
1110
_DANGEROUS_PORTS = {22, 3389, 3306, 5432, 6379, 27017, 9200, 11211}
1211
_DANGEROUS_LABELS = {
1312
22: "SSH", 3389: "RDP", 3306: "MySQL", 5432: "PostgreSQL",
@@ -88,7 +87,7 @@ def audit(ctx: click.Context) -> None:
8887
# Server in error
8988
if srv.get("status") == "ERROR":
9089
findings.append(("LOW", f"Server: {srv_name}", srv_id,
91-
f"Server in ERROR state"))
90+
"Server in ERROR state"))
9291

9392
# Check if server has floating IP (publicly reachable)
9493
has_floating = False

orca_cli/commands/auth.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
import click
88

99
from orca_cli.core.config import (
10-
load_config,
10+
_find_clouds_yaml,
11+
_load_clouds_yaml,
1112
config_is_complete,
1213
get_active_profile_name,
1314
list_profiles,
14-
_find_clouds_yaml,
15-
_load_clouds_yaml,
15+
load_config,
1616
)
1717
from orca_cli.core.context import OrcaContext
18-
from orca_cli.core.output import console, output_options, print_detail
18+
from orca_cli.core.output import console
1919

2020

2121
@click.group()
@@ -122,7 +122,6 @@ def auth_token_debug(ctx: click.Context, raw: bool) -> None:
122122

123123
from rich.table import Table
124124
from rich.tree import Tree
125-
from rich.text import Text
126125

127126
user = td.get("user", {})
128127
project = td.get("project", {})

orca_cli/commands/backup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import click
66

77
from orca_cli.core.context import OrcaContext
8-
from orca_cli.core.output import output_options, print_list, print_detail, console
8+
from orca_cli.core.output import console, output_options, print_detail, print_list
99

1010

1111
def _freezer(client) -> str:
@@ -172,10 +172,10 @@ def job_show(ctx: click.Context, job_id: str, output_format: str,
172172
for i, a in enumerate(actions):
173173
fa = a.get("freezer_action", {})
174174
fields.append((f" Action {i + 1}", fa.get("action", "")))
175-
fields.append((f" Path", fa.get("path_to_backup", "") or fa.get("restore_abs_path", "") or "—"))
176-
fields.append((f" Container", fa.get("container", "") or "—"))
177-
fields.append((f" Storage", fa.get("storage", "") or "—"))
178-
fields.append((f" Mode", fa.get("mode", "") or "—"))
175+
fields.append((" Path", fa.get("path_to_backup", "") or fa.get("restore_abs_path", "") or "—"))
176+
fields.append((" Container", fa.get("container", "") or "—"))
177+
fields.append((" Storage", fa.get("storage", "") or "—"))
178+
fields.append((" Mode", fa.get("mode", "") or "—"))
179179

180180
print_detail(fields, output_format=output_format, fit_width=fit_width,
181181
max_width=max_width, noindent=noindent, columns=columns)

orca_cli/commands/catalog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import click
66

77
from orca_cli.core.context import OrcaContext
8-
from orca_cli.core.output import output_options, print_list, console
8+
from orca_cli.core.output import console, output_options, print_list
99

1010

1111
@click.command("catalog")

orca_cli/commands/cluster.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import click
66

77
from orca_cli.core.context import OrcaContext
8-
from orca_cli.core.output import output_options, print_list, print_detail, console
9-
from orca_cli.core.validators import validate_id
8+
from orca_cli.core.output import console, output_options, print_detail, print_list
109

1110

1211
def _magnum(client) -> str:
@@ -253,7 +252,7 @@ def template_create(ctx: click.Context, name: str, image_id: str, external_netwo
253252
if docker_volume_size:
254253
body["docker_volume_size"] = docker_volume_size
255254
if labels:
256-
body["labels"] = dict(l.split("=", 1) for l in labels)
255+
body["labels"] = dict(item.split("=", 1) for item in labels)
257256

258257
data = client.post(f"{_magnum(client)}/clustertemplates", json=body)
259258
console.print(f"[green]Template '{data.get('name')}' ({data.get('uuid')}) created.[/green]")

orca_cli/commands/compute_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import click
66

77
from orca_cli.core.context import OrcaContext
8-
from orca_cli.core.output import console, output_options, print_detail, print_list
8+
from orca_cli.core.output import console, output_options, print_list
99

1010

1111
@click.group("compute-service")

0 commit comments

Comments
 (0)