Merge pull request #1332 from jooola/feat/enhance_scripts_tools

Enhance scripts tools
This commit is contained in:
Kyle Robbertze 2021-09-08 06:13:53 +00:00 committed by GitHub
commit e2aabfe580
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 27 additions and 14 deletions

View File

@ -36,6 +36,14 @@ jobs:
- run: SEVERITY=warning make shell-check
test-tools:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: make all
working-directory: tools
test-legacy:
strategy:
matrix:

View File

@ -41,7 +41,7 @@ jobs:
- name: Generate packages list
run: |
scripts/packages.py --dev --format line ${{ matrix.release }} \
tools/packages.py --dev --format line ${{ matrix.release }} \
python_apps/airtime_analyzer \
python_apps/pypo \
> packages.list

View File

@ -764,7 +764,7 @@ if [ "$ignore_dependencies" = "f" ]; then
set -e
package_list=$(
"${SCRIPT_DIR}/scripts/packages.py" --format=line "${code}" "${packages_files[@]}" ||
"${SCRIPT_DIR}/tools/packages.py" --format=line "${code}" "${packages_files[@]}" ||
(echo "ERROR: could not generate packages list" >&2 && exit 1)
)
set +e

3
tools/.pylintrc Normal file
View File

@ -0,0 +1,3 @@
[MESSAGES CONTROL]
disable=missing-module-docstring,
missing-function-docstring

View File

@ -8,11 +8,16 @@ all: lint test
venv:
python3 -m venv venv
source venv/bin/active
source venv/bin/activate
pip install -r requirements-dev.txt
lint: venv
pylint scripts
source venv/bin/activate
pylint tools
test: venv
source venv/bin/activate
pytest -n ${CPU_CORES} --color=yes -v .
clean:
rm -Rf venv

View File

@ -1,3 +1,3 @@
# Scripts
# Tools
This folder contains scripts/tools to manage the project.

View File

@ -1,10 +1,7 @@
#!/usr/bin/env python3
import json
import sys
from argparse import ArgumentParser
from configparser import ConfigParser
from os import PathLike
from pathlib import Path
from typing import Iterator, Set
@ -62,7 +59,7 @@ def run():
choices=FORMATS,
help="print packages list in a specific format.",
default="list",
),
)
parser.add_argument(
"-d",
"--dev",

View File

@ -1,8 +1,8 @@
from pathlib import Path
from .packages import list_packages, load_packages
from tools.packages import list_packages, load_packages
package_ini = """
PACKAGE_INI = """
[common]
postgresql = buster
# Some comment
@ -20,13 +20,13 @@ result2 = {"apache2", "curl", "ffmpeg"}
def test_load_packages():
assert load_packages(package_ini, "buster", False) == result1
assert load_packages(package_ini, "bionic", True) == result2
assert load_packages(PACKAGE_INI, "buster", False) == result1
assert load_packages(PACKAGE_INI, "bionic", True) == result2
def test_list_packages(tmp_path: Path):
package_file = tmp_path / "packages.ini"
package_file.write_text(package_ini)
package_file.write_text(PACKAGE_INI)
assert list_packages([tmp_path, package_file], "buster", False) == result1
assert list_packages([tmp_path, package_file], "bionic", True) == result2