Lint on GitHub Actions (#196)
- Lint with pre-commit on GitHub Actions, - Add some handy pre-hooks, - Configure Ruff lint rules (https://github.com/astral-sh/ruff). --------- Co-authored-by: Marc Wrobel <marc.wrobel@gmail.com>
This commit is contained in:
committed by
GitHub
parent
0d17306872
commit
8870ab5e28
20
.github/workflows/lint.yml
vendored
Normal file
20
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: Lint
|
||||
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
|
||||
env:
|
||||
FORCE_COLOR: 1
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
- uses: pre-commit/action@v3.0.0
|
||||
26
.pre-commit-config.yaml
Normal file
26
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.1.6
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: [--fix, --exit-non-zero-on-fix]
|
||||
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.5.0
|
||||
hooks:
|
||||
- id: check-case-conflict
|
||||
- id: check-merge-conflict
|
||||
- id: check-json
|
||||
- id: check-yaml
|
||||
- id: debug-statements
|
||||
- id: end-of-file-fixer
|
||||
exclude: releases/.*
|
||||
- id: trailing-whitespace
|
||||
|
||||
- repo: meta
|
||||
hooks:
|
||||
- id: check-hooks-apply
|
||||
- id: check-useless-excludes
|
||||
|
||||
ci:
|
||||
autoupdate_schedule: quarterly
|
||||
13
.ruff.toml
Normal file
13
.ruff.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
select = [
|
||||
"E", # pycodestyle errors
|
||||
"F", # pyflakes errors
|
||||
"ISC", # flake8-implicit-str-concat
|
||||
"PGH", # pygrep-hooks
|
||||
"RUF100", # unused noqa (yesqa)
|
||||
"UP", # pyupgrade
|
||||
"W", # pycodestyle warnings
|
||||
"YTT", # flake8-2020
|
||||
]
|
||||
extend-ignore = [
|
||||
"E501", # Line too long
|
||||
]
|
||||
@@ -8,7 +8,7 @@ count = 0
|
||||
count_auto = 0
|
||||
products_dir = sys.argv[1] if len(sys.argv) > 1 else 'website/products/'
|
||||
for product_file in sorted(list(glob(f'{products_dir}/*.md'))):
|
||||
with open(product_file, "r") as f:
|
||||
with open(product_file) as f:
|
||||
data = frontmatter.load(f)
|
||||
count += 1
|
||||
title = data['title']
|
||||
|
||||
@@ -17,3 +17,4 @@ requests==2.31.0
|
||||
requests-html==0.10.0
|
||||
requests-futures==1.0.1
|
||||
regex==2023.10.3
|
||||
pre-commit==3.5.0
|
||||
|
||||
@@ -16,7 +16,7 @@ USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/1
|
||||
def load_product(product_name, pathname="website/products") -> frontmatter.Post:
|
||||
"""Load the product's file frontmatter.
|
||||
"""
|
||||
with open(f"{pathname}/{product_name}.md", "r") as f:
|
||||
with open(f"{pathname}/{product_name}.md") as f:
|
||||
return frontmatter.load(f)
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ def list_products(method, products_filter=None, pathname="website/products") ->
|
||||
if products_filter and product_name != products_filter:
|
||||
continue
|
||||
|
||||
with open(product_file, "r") as f:
|
||||
with open(product_file) as f:
|
||||
data = frontmatter.load(f)
|
||||
if "auto" in data:
|
||||
configs = list(filter(
|
||||
|
||||
@@ -36,7 +36,7 @@ query($endCursor: String) {
|
||||
}
|
||||
}
|
||||
}' --jq '.data.repository.releases.edges.[].node | select(.isPrerelease == false) | [.name, .publishedAt] | join(",")'
|
||||
""" % (repo, owner)
|
||||
""" % (repo, owner) # noqa: UP031
|
||||
|
||||
child = subprocess.Popen(query, shell=True, stdout=subprocess.PIPE)
|
||||
return child.communicate()[0].decode('utf-8')
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import re
|
||||
from bs4 import BeautifulSoup
|
||||
from common import dates
|
||||
from common import endoflife
|
||||
|
||||
Reference in New Issue
Block a user