Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #10

Merged
merged 4 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.2.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
71 changes: 37 additions & 34 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,39 +78,42 @@ skip-string-normalization = true
[tool.ruff]
target-version = "py39"
line-length = 100

[tool.ruff.lint]
select = [
"A", # flake8-builtins
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"A", # flake8-builtins
"ASYNC", # flake8-async
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"C",
"C4", # flake8-comprehensions
"COM", # flake8-commas
"DTZ", # flake8-datetimez
"E", # pycodestyle Error
"EM", # flake8-errmsg
"F", # Pyflakes
"FBT", # flake8-boolean-trap
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"PERF", # Perflint
"PIE", # flake8-pie
"PLC", # Pylint Convention
"PLE", # Pylint Error
"PLR", # Pylint Refactor
"PLW", # Pylint Warning
"Q", # flake8-quotes
"RET", # flake8-return
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"C4", # flake8-comprehensions
"COM", # flake8-commas
"DTZ", # flake8-datetimez
"E", # pycodestyle Error
"EM", # flake8-errmsg
"F", # Pyflakes
"FBT", # flake8-boolean-trap
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"PERF", # Perflint
"PIE", # flake8-pie
"PLC", # Pylint Convention
"PLE", # Pylint Error
"PLR", # Pylint Refactor
"PLW", # Pylint Warning
"Q", # flake8-quotes
"RET", # flake8-return
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"T",
"TID", # flake8-tidy-imports
"UP", # pyupgrade
"W", # pycodestyle Warning
"YTT", # flake8-2020
"TID", # flake8-tidy-imports
"UP", # pyupgrade
"W", # pycodestyle Warning
"YTT", # flake8-2020
]
ignore = [
# Allow non-abstract empty methods in abstract base classes
Expand All @@ -131,15 +134,15 @@ allowed-confusables = [
"‹", "›",
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["validation"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "google"
12 changes: 10 additions & 2 deletions src/validation/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
@click.version_option(prog_name="validation")
def validation():
loop = asyncio.get_event_loop()
tasks = set()

# GitHub
if getenv("GITHUB_TOKEN"):
logging.info("Running validation for GitHub.")
loop.create_task(GithubTests().run())
task = loop.create_task(GithubTests().run())

tasks.add(task)
task.add_done_callback(tasks.discard)
else:
logging.info("GITHUB_TOKEN not set, skipping the validation for GitHub.")

Expand All @@ -46,12 +51,15 @@ def validation():
continue

logging.info("Running validation for GitLab instance: %s", instance_url)
loop.create_task(
task = loop.create_task(
GitlabTests(
instance_url=instance_url,
namespace=namespace,
token_name=token,
).run(),
)

tasks.add(task)
task.add_done_callback(tasks.discard)

loop.run_forever()
24 changes: 20 additions & 4 deletions src/validation/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class Tests:

async def run(self):
loop = asyncio.get_event_loop()
tasks = set()

prs_for_comment = [
pr for pr in self.project.get_pr_list() if pr.title.startswith("Test VM Image builds")
]
Expand All @@ -32,7 +34,7 @@ async def run(self):
)
logging.warning(msg)
for pr in prs_for_comment:
loop.create_task(
task = loop.create_task(
self.test_case_kls(
project=self.project,
pr=pr,
Expand All @@ -42,6 +44,9 @@ async def run(self):
).run_test(),
)

tasks.add(task)
task.add_done_callback(tasks.discard)

prs_for_comment = [
pr for pr in self.project.get_pr_list() if pr.title.startswith("Basic test case:")
]
Expand All @@ -57,7 +62,7 @@ async def run(self):
)
logging.warning(msg)
for pr in prs_for_comment:
loop.create_task(
task = loop.create_task(
self.test_case_kls(
project=self.project,
pr=pr,
Expand All @@ -66,6 +71,9 @@ async def run(self):
).run_test(),
)

tasks.add(task)
task.add_done_callback(tasks.discard)

pr_for_push = [
pr
for pr in self.project.get_pr_list()
Expand All @@ -83,7 +91,7 @@ async def run(self):
)
logging.warning(msg)
if pr_for_push:
loop.create_task(
task = loop.create_task(
self.test_case_kls(
project=self.project,
pr=pr_for_push[0],
Expand All @@ -92,9 +100,17 @@ async def run(self):
).run_test(),
)

tasks.add(task)
task.add_done_callback(tasks.discard)

msg = (
"Run testcase where the build is triggered by opening "
f"a new PR {self.project.service.instance_url}"
)
logging.info(msg)
loop.create_task(self.test_case_kls(project=self.project, deployment=DEPLOYMENT).run_test())

task = loop.create_task(
self.test_case_kls(project=self.project, deployment=DEPLOYMENT).run_test(),
)
tasks.add(task)
task.add_done_callback(tasks.discard)
Loading