From 7c31d4774550bab7c8f39563eba1da3adb61ec5b Mon Sep 17 00:00:00 2001 From: Bart Ribbers <bribbers@disroot.org> Date: Mon, 6 Jan 2020 18:25:27 +0100 Subject: [PATCH] CI: skip linting check for temp/ folder (!864) Since we copy these aports directly from Alpine and try to keep them in sync, we don't want to differ from upstream because our CI doesn't pass on linting. If the APKBUILD should be improved, it should be done upstream which is then synced back to us. --- .gitlab-ci.yml | 5 +++-- .gitlab-ci/apkbuild-linting.py | 30 ++++++++++++++++++++++++++++++ .gitlab-ci/common.py | 7 +++++-- 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100755 .gitlab-ci/apkbuild-linting.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9f9027a7c..9e8ea127a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -83,9 +83,10 @@ aports-static: # APKBUILD linting aport-lint: stage: first - image: alpinelinux/apkbuild-lint-tools:latest + before_script: + - apk -q add git atools python3 script: - - changed-aports $CI_MERGE_REQUEST_TARGET_BRANCH_NAME | lint + - .gitlab-ci/apkbuild-linting.py only: - merge_requests diff --git a/.gitlab-ci/apkbuild-linting.py b/.gitlab-ci/apkbuild-linting.py new file mode 100755 index 000000000..985d01a93 --- /dev/null +++ b/.gitlab-ci/apkbuild-linting.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0-or-later + +import common +import subprocess +import sys + +if __name__ == "__main__": + common.add_upstream_git_remote() + packages = common.get_changed_packages(with_directory=True) + + if len(packages) < 1: + print("No APKBUILDs to lint") + sys.exit(0) + + issues = [] + for package in packages: + if "temp/" in package: + continue + + result = subprocess.run(["apkbuild-lint", package], capture_output=True) + if len(result.stdout) > 0: + issues.append([package, result.stdout.decode("utf-8")]) + + if len(issues) > 0: + print("Linting issues found:") + for issue in issues: + print(issue[0] + ": " + issue[1]) + + sys.exit(1) diff --git a/.gitlab-ci/common.py b/.gitlab-ci/common.py index 6059e0592..d0cd62d5f 100755 --- a/.gitlab-ci/common.py +++ b/.gitlab-ci/common.py @@ -108,7 +108,7 @@ def get_changed_packages_sanity_check(count): sys.exit(1) -def get_changed_packages(): +def get_changed_packages(with_directory=False): files = get_changed_files() ret = set() for file in files: @@ -120,7 +120,10 @@ def get_changed_packages(): continue # Add to the ret set (removes duplicated automatically) - ret.add(file.split("/")[1]) + if with_directory: + ret.add(file) + else: + ret.add(file.split("/")[1]) return ret