Skip to content
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
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Test Polymath Code Standard

on:
push:
branches: [main]
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest
name: standardize thyself
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: '3.10'
- uses: pre-commit/action@v3.0.1

pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- run: uv sync
- run: uv run pytest
28 changes: 26 additions & 2 deletions polymath_code_standard/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,32 @@ def run_group_markdown(files: list[str]) -> list[Result]:


def run_group_yaml(files: list[str]) -> list[Result]:
# pre-commit hook definition carries exclude: '\.gitlab-ci\.yml$'
return [_check('yamllint', ['-d', '{extends: default, rules: {line-length: {max: 256}, commas: false}}'], files)]
from .yaml_format import format_yaml_files

if not files:
return [Result(name='yamlfix', passed=True, skipped=True)]
errors = []
changed = []
for filepath, was_changed, error in format_yaml_files(files):
if error:
errors.append(f'{filepath}: {error}')
elif was_changed:
changed.append(filepath)
results = []
if errors:
results.append(Result(name='yamlfix', passed=False, output='\n'.join(errors)))
if changed:
changed_list = '\n'.join(f' {f}' for f in changed)
results.append(
Result(
name='yamlfix',
passed=False,
output=f'Files reformatted — please re-stage and recommit:\n{changed_list}',
)
)
if not results:
results.append(Result(name='yamlfix', passed=True))
return results


def run_group_toml(files: list[str]) -> list[Result]:
Expand Down
Loading
Loading