From 7cb3501540a8396c992b1d5184c891dfe96322e0 Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 7 Sep 2021 22:56:35 +0200 Subject: [PATCH 1/4] Rename scripts/ to tools/ --- .github/workflows/tools.yml | 2 +- install | 2 +- {scripts => tools}/Makefile | 2 +- {scripts => tools}/README.md | 2 +- {scripts => tools}/__init__.py | 0 {scripts => tools}/packages.py | 0 {scripts => tools}/packages_test.py | 0 {scripts => tools}/requirements-dev.txt | 0 8 files changed, 4 insertions(+), 4 deletions(-) rename {scripts => tools}/Makefile (93%) rename {scripts => tools}/README.md (85%) rename {scripts => tools}/__init__.py (100%) rename {scripts => tools}/packages.py (100%) rename {scripts => tools}/packages_test.py (100%) rename {scripts => tools}/requirements-dev.txt (100%) diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml index 44f1f97a3..a91064143 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/tools.yml @@ -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 diff --git a/install b/install index 9661a7a7e..4fc6391ba 100755 --- a/install +++ b/install @@ -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 diff --git a/scripts/Makefile b/tools/Makefile similarity index 93% rename from scripts/Makefile rename to tools/Makefile index bc226fd86..4c32ea86f 100644 --- a/scripts/Makefile +++ b/tools/Makefile @@ -12,7 +12,7 @@ venv: pip install -r requirements-dev.txt lint: venv - pylint scripts + pylint tools test: venv pytest -n ${CPU_CORES} --color=yes -v . diff --git a/scripts/README.md b/tools/README.md similarity index 85% rename from scripts/README.md rename to tools/README.md index 2b553b0fd..bbceacedf 100644 --- a/scripts/README.md +++ b/tools/README.md @@ -1,3 +1,3 @@ -# Scripts +# Tools This folder contains scripts/tools to manage the project. diff --git a/scripts/__init__.py b/tools/__init__.py similarity index 100% rename from scripts/__init__.py rename to tools/__init__.py diff --git a/scripts/packages.py b/tools/packages.py similarity index 100% rename from scripts/packages.py rename to tools/packages.py diff --git a/scripts/packages_test.py b/tools/packages_test.py similarity index 100% rename from scripts/packages_test.py rename to tools/packages_test.py diff --git a/scripts/requirements-dev.txt b/tools/requirements-dev.txt similarity index 100% rename from scripts/requirements-dev.txt rename to tools/requirements-dev.txt From 4724a309376e4c2b5b6914afcb94b143400710fb Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 7 Sep 2021 23:09:53 +0200 Subject: [PATCH 2/4] Fix tools makefile --- tools/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/Makefile b/tools/Makefile index 4c32ea86f..511ba08af 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -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 + source venv/bin/activate pylint tools test: venv + source venv/bin/activate pytest -n ${CPU_CORES} --color=yes -v . + +clean: + rm -Rf venv From 14d4012e8e024ca57c119928764b7dc43a900a98 Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 7 Sep 2021 23:10:21 +0200 Subject: [PATCH 3/4] Fix tools linting --- tools/.pylintrc | 3 +++ tools/packages.py | 5 +---- tools/packages_test.py | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 tools/.pylintrc diff --git a/tools/.pylintrc b/tools/.pylintrc new file mode 100644 index 000000000..b274cc0fe --- /dev/null +++ b/tools/.pylintrc @@ -0,0 +1,3 @@ +[MESSAGES CONTROL] +disable=missing-module-docstring, + missing-function-docstring diff --git a/tools/packages.py b/tools/packages.py index e6a235d99..ed5c32a26 100755 --- a/tools/packages.py +++ b/tools/packages.py @@ -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", diff --git a/tools/packages_test.py b/tools/packages_test.py index bdd9edb06..f4d095f74 100644 --- a/tools/packages_test.py +++ b/tools/packages_test.py @@ -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 From 7f1c368c1366e17967d27c97c58344f756638ee9 Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 7 Sep 2021 23:10:34 +0200 Subject: [PATCH 4/4] Run tools CI job --- .github/workflows/test.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 34be5f7cc..bab069b74 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: