← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~paride/autopkgtest-cloud:ci_drop_lint_test into autopkgtest-cloud:master

 

Paride Legovini has proposed merging ~paride/autopkgtest-cloud:ci_drop_lint_test into autopkgtest-cloud:master.

Commit message:
ci: drop lint_test, now fully covered by pre-commit

Also: fix the .launchopad.yaml permission, which for some reason was
chmod 755.


Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~paride/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/445774
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~paride/autopkgtest-cloud:ci_drop_lint_test into autopkgtest-cloud:master.
diff --git a/.launchpad.yaml b/.launchpad.yaml
old mode 100755
new mode 100644
index ee74e0f..9befb4f
--- a/.launchpad.yaml
+++ b/.launchpad.yaml
@@ -42,8 +42,3 @@ jobs:
       - name: charmcraft
         classic: true
     run: ./ci/build_charms
-  lint_test:
-    series: focal
-    architectures: amd64
-    packages: [pylint, python3, shellcheck, yamllint]
-    run: ./ci/lint_test
diff --git a/ci/lint_test b/ci/lint_test
deleted file mode 100755
index 3fee7f5..0000000
--- a/ci/lint_test
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/usr/bin/python3
-# pylint: disable = invalid-name, broad-except, subprocess-run-check
-"""
-Script to lint the scripts in the autopkgtest-cloud repository in CI
-"""
-import logging
-import os
-import pathlib
-import subprocess
-import sys
-
-
-def check_for_extension(input_list, output_list, extension):
-    """
-    Checks filepaths in a list for a given extension
-    """
-    for a in input_list:
-        if os.path.isfile(a):
-            # if str(a)[-3:] == extension:
-            if extension in str(a)[-6:]:
-                output_list.append(str(a))
-    return output_list
-
-
-def check_for_shebang(input_list, output_list, shebang):
-    """
-    Checks filepaths in a given list for a given shebang
-    """
-    for b in input_list:
-        if os.path.isfile(b):
-            try:
-                with open(b, "r", encoding="utf-8") as myfile:
-                    file = myfile.read()
-                    into_list = file.splitlines()
-                    if len(into_list) > 1:
-                        if into_list[0] == shebang:
-                            output_list.append(str(b))
-            except Exception as _:
-                pass
-    return output_list
-
-
-def remove_list_from_list(input_list, remove_list):
-    """
-    Removes elements from remove_list from input_list
-    """
-    for ff in input_list:
-        if os.path.isfile(ff):
-            if str(ff) in remove_list:
-                input_list.remove(ff)
-    return input_list
-
-
-def run_lint_command(files_to_lint, lint_command, arguments=None):
-    """
-    Runs a given lint command over a list of filepaths and stores output
-    and exit code
-    """
-    exit_codes = 0
-    lint_output = ""
-    # check lint command exists
-    for f in files_to_lint:
-        if arguments is None:
-            cmd = [lint_command, f]
-            result = subprocess.run(cmd, stdout=subprocess.PIPE)
-        else:
-            cmd = [lint_command]
-            for arg in arguments.split(" "):
-                cmd.append(arg)
-            cmd.append(f)
-            result = subprocess.run(cmd, stdout=subprocess.PIPE)
-        lint_output += result.stdout.decode("utf-8") + "\n"
-        exit_codes += result.returncode
-    return lint_output, exit_codes
-
-
-if __name__ == "__main__":
-    logging.basicConfig(level=logging.INFO)
-    logger = logging.getLogger("autopkgtest-cloud-linter")
-
-    start_dir = "../"
-    repo_dir = pathlib.Path(start_dir)
-    repo_dir.rglob("*")
-
-    final_list_of_python_files = []
-    all_files = list(repo_dir.rglob("*"))
-
-    data = {
-        "pylint": {
-            "files": [],
-            "extensions": [".py"],
-            "shebangs": ["#!/usr/bin/python3"],
-            "args": None,
-            "output": "",
-            "code": 0,
-        },
-    }
-
-    for key, item in data.items():
-        if item["extensions"] is not None:
-            for extension in item["extensions"]:
-                data[key]["files"] = check_for_extension(
-                    all_files, data[key]["files"], extension
-                )
-                all_files = remove_list_from_list(
-                    all_files, data[key]["files"]
-                )
-        if item["shebangs"] is not None:
-            for shebang in item["shebangs"]:
-                data[key]["files"] = check_for_shebang(
-                    all_files, data[key]["files"], shebang
-                )
-                all_files = remove_list_from_list(
-                    all_files, data[key]["files"]
-                )
-        data[key]["output"], data[key]["code"] = run_lint_command(
-            data[key]["files"], key, data[key]["args"]
-        )
-    ecodesum = 0
-    for _, oec in data.items():
-        ecodesum += oec["code"]
-    if ecodesum > 0:
-        for key, item in data.items():
-            if item["code"] > 0:
-                # logger.info("%s output: \n%s", key, item["output"])
-                logger.info("%s failed!", key)
-        # sys.exit(1)
-        # temporary exit code, will be set back to 1 when python and bash scripts have been linted
-        # right now we are just checking yaml files
-        if key == "yamllint" and item["code"] != 0:
-            sys.exit(1)
-        sys.exit(0)
-    sys.exit(0)