Add python linting in CI with Ruff. Fix the on: push/pull_request for other actions.

This commit is contained in:
Félix Piédallu 2024-03-14 13:08:31 +01:00
parent c4bccf86ed
commit 751ff67fd9
4 changed files with 36 additions and 7 deletions

View file

@ -1,8 +1,9 @@
name: Check / auto apply Black name: Check / auto apply Black
on: on:
push: push:
branches: branches:
- master - master
jobs: jobs:
black: black:
name: Check / auto apply black name: Check / auto apply black

25
.github/workflows/python_lint.yml vendored Normal file
View file

@ -0,0 +1,25 @@
name: Python Ruff Lint and commit
on:
push:
branches: [master]
pull_request:
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install Ruff
run: pip install ruff
- name: Ruff check and fix
run: |
ruff check .
ruff fix .
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'Python style fixes from Ruff'

View file

@ -2,6 +2,7 @@ name: Run Shellcheck on push and PR
on: on:
push: push:
branches: [master]
pull_request: pull_request:
jobs: jobs:

View file

@ -1,13 +1,14 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys
import os
import json import json
import toml import os
import yaml import sys
import time import time
from collections import OrderedDict from collections import OrderedDict
import toml
import yaml
CATALOG_LIST_PATH = "/etc/yunohost/apps_catalog.yml" CATALOG_LIST_PATH = "/etc/yunohost/apps_catalog.yml"
assert os.path.exists( assert os.path.exists(
CATALOG_LIST_PATH CATALOG_LIST_PATH
@ -44,7 +45,8 @@ def build(folder=DEFAULT_APPS_FOLDER):
apps[app_dict["id"]] = app_dict apps[app_dict["id"]] = app_dict
# We also remove the app install question and resources parts which aint needed anymore by webadmin etc (or at least we think ;P) # We also remove the app install question and resources parts which aint needed
# anymore by webadmin etc (or at least we think ;P)
for app in apps.values(): for app in apps.values():
if "manifest" in app and "install" in app["manifest"]: if "manifest" in app and "install" in app["manifest"]:
del app["manifest"]["install"] del app["manifest"]["install"]