Skip to content

Commit 214c6f4

Browse files
Merge pull request #48 from ivyleavedtoadflax/feature/improve-ci-pipeline
feat: Improve CI/CD pipeline with test coverage
2 parents 227a2f8 + 9bc93ab commit 214c6f4

File tree

14 files changed

+2504
-42
lines changed

14 files changed

+2504
-42
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ jobs:
3333
run: |
3434
uv run ruff format --check .
3535
36-
- name: Run tests with pytest
36+
- name: Run tests with pytest and coverage
3737
run: |
38-
uv run pytest -v --tb=short
38+
uv run pytest -v --tb=short --cov=remotepy --cov-report=term-missing
3939
env:
4040
AWS_DEFAULT_REGION: us-east-1
4141
AWS_ACCESS_KEY_ID: dummy

.pre-commit-config.yaml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
default_stages: [pre-push]
2-
3-
repos:
4-
- repo: https://github.com/astral-sh/ruff-pre-commit
5-
rev: v0.8.4
6-
hooks:
7-
# 1. Ruff lint (check-only)
8-
- id: ruff
9-
name: ruff-check
10-
args: []
11-
12-
# 2. Ruff fix (format)
13-
- id: ruff
14-
name: ruff-fix
15-
args: [--fix]
16-
stages: [manual] # only runs if you explicitly run it
17-
18-
# 3. Ruff formatter
19-
- id: ruff-format
20-
stages: [manual] # also opt-in, to avoid auto-formatting on push
21-
22-
- repo: local
23-
hooks:
24-
- id: pytest
25-
name: pytest
26-
entry: uv run pytest
27-
language: system
28-
pass_filenames: false
29-
always_run: true
30-
stages: [pre-push]
31-
1+
default_stages: [pre-push]
2+
3+
repos:
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
rev: v0.8.4
6+
hooks:
7+
# 1. Ruff lint (check-only)
8+
- id: ruff
9+
name: ruff-check
10+
args: []
11+
12+
# 2. Ruff fix (format)
13+
- id: ruff
14+
name: ruff-fix
15+
args: [--fix]
16+
stages: [manual] # only runs if you explicitly run it
17+
18+
# 3. Ruff formatter
19+
- id: ruff-format
20+
stages: [pre-push] # automatically format on push
21+
22+
- repo: local
23+
hooks:
24+
- id: pytest
25+
name: pytest
26+
entry: uv run pytest
27+
language: system
28+
pass_filenames: false
29+
always_run: true
30+
stages: [pre-push]
31+

pyproject.toml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,66 @@ line-ending = "auto"
7676
dev = [
7777
"pre-commit>=4.2.0",
7878
"pytest>=8.4.1",
79+
"pytest-cov>=6.2.1",
7980
"pytest-mock>=3.14.1",
8081
"ruff>=0.12.0",
8182
"tox>=4.27.0",
8283
]
8384

8485
[tool.ruff.lint.isort]
8586
known-first-party = ["src"]
87+
88+
# ============================================================================
89+
# Test Coverage Configuration
90+
# ============================================================================
91+
92+
[tool.coverage.run]
93+
source = ["remotepy"]
94+
omit = [
95+
"tests/*",
96+
"remotepy/__init__.py",
97+
"*/__pycache__/*",
98+
"*/migrations/*",
99+
"*/venv/*",
100+
"*/.venv/*",
101+
]
102+
103+
[tool.coverage.report]
104+
exclude_lines = [
105+
"pragma: no cover",
106+
"def __repr__",
107+
"if self.debug:",
108+
"if settings.DEBUG",
109+
"raise AssertionError",
110+
"raise NotImplementedError",
111+
"if 0:",
112+
"if __name__ == .__main__.:",
113+
"class .*\bProtocol\\):",
114+
"@(abc\\.)?abstractmethod",
115+
]
116+
show_missing = true
117+
skip_covered = false
118+
skip_empty = false
119+
120+
# Minimum coverage thresholds - fail if below these percentages
121+
fail_under = 85
122+
precision = 1
123+
124+
[tool.coverage.html]
125+
directory = "htmlcov"
126+
title = "RemotePy Test Coverage Report"
127+
128+
[tool.coverage.xml]
129+
output = "coverage.xml"
130+
131+
# Per-module minimum coverage requirements
132+
[tool.coverage.report.coverage_thresholds]
133+
# Core modules should maintain high coverage
134+
"remotepy/utils.py" = 95
135+
"remotepy/config.py" = 90
136+
"remotepy/ecs.py" = 95
137+
"remotepy/instance.py" = 60 # Allow lower for now due to complex CLI interactions
138+
"remotepy/ami.py" = 95
139+
"remotepy/volume.py" = 90
140+
"remotepy/snapshot.py" = 90
141+
"remotepy/__main__.py" = 90

remotepy/ami.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ def launch(
188188
"""
189189

190190
# if no launch template is specified, list all the launch templates
191-
192191
if not launch_template:
193192
typer.secho("Please specify a launch template", fg=typer.colors.RED)
194193
typer.secho("Available launch templates:", fg=typer.colors.YELLOW)
@@ -205,9 +204,12 @@ def launch(
205204
fg=typer.colors.YELLOW,
206205
)
207206
typer.secho(f"Launching instance based on launch template {launch_template_name}")
207+
else:
208+
# launch template name was provided, get the ID and set variables
209+
launch_template_name = launch_template
210+
launch_template_id = get_launch_template_id(launch_template)
208211

209212
# if no name is specified, ask the user for the name
210-
211213
if not name:
212214
random_string = "".join(random.choices(string.ascii_letters + string.digits, k=6))
213215
name_suggestion = launch_template_name + "-" + random_string

0 commit comments

Comments
 (0)